Module: Braintrust::Contrib::Support::OTel

Defined in:
lib/braintrust/contrib/support/otel.rb

Overview

OpenTelemetry utilities shared across all integrations.

Class Method Summary collapse

Class Method Details

.set_json_attr(span, attr_name, obj) ⇒ void

This method returns an undefined value.

Helper to safely set a JSON attribute on a span Only sets the attribute if obj is present

Parameters:

  • span (OpenTelemetry::Trace::Span)

    the span to set attribute on

  • attr_name (String)

    the attribute name (e.g., “braintrust.output_json”)

  • obj (Object)

    the object to serialize to JSON



16
17
18
19
# File 'lib/braintrust/contrib/support/otel.rb', line 16

def self.set_json_attr(span, attr_name, obj)
  return unless obj
  span.set_attribute(attr_name, JSON.generate(obj))
end