Module: Langfuse::Masking Private

Defined in:
lib/langfuse/masking.rb

Overview

This module is part of a private API. You should avoid using this module if possible, as it may be removed or be changed in the future.

Central masking chokepoint for tracing payload fields.

Applies a user-provided mask callable to input, output, and metadata before serialization. Fail-closed: if the mask raises, the entire field is replaced with FALLBACK.

Constant Summary collapse

FALLBACK =

This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.

Replacement string used when the mask callable raises

"<fully masked due to failed mask function>"

Class Method Summary collapse

Class Method Details

.apply(data, mask:) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Apply the mask callable to a data value.

Parameters:

  • data (Object, nil)

    The value to mask (input, output, or metadata)

  • mask (#call, nil)

    Callable receiving ‘data:` keyword; nil disables masking

Returns:

  • (Object)

    Masked data, original data (when mask is nil/data is nil), or FALLBACK



20
21
22
23
24
25
26
27
# File 'lib/langfuse/masking.rb', line 20

def self.apply(data, mask:)
  return data if mask.nil? || data.nil?

  mask.call(data: data)
rescue StandardError => e
  Langfuse.configuration.logger.warn("Langfuse: Mask function failed: #{e.message}")
  FALLBACK
end