Class: DSPy::Subscribers::OtelSubscriber

Inherits:
Object
  • Object
show all
Extended by:
T::Sig
Defined in:
lib/dspy/subscribers/otel_subscriber.rb

Overview

OpenTelemetry subscriber that creates spans and metrics for DSPy operations Provides comprehensive tracing for optimization operations and LM calls

Defined Under Namespace

Classes: OtelConfig

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(config: nil) ⇒ OtelSubscriber

Returns a new instance of OtelSubscriber.



85
86
87
88
89
90
91
92
93
94
# File 'lib/dspy/subscribers/otel_subscriber.rb', line 85

def initialize(config: nil)
  @config = config || OtelConfig.new
  @tracer = T.let(nil, T.nilable(T.untyped))
  @meter = T.let(nil, T.nilable(T.untyped))
  @optimization_spans = T.let({}, T::Hash[String, T.untyped])
  @trial_spans = T.let({}, T::Hash[String, T.untyped])
  
  setup_opentelemetry if @config.enabled
  setup_event_subscriptions
end

Instance Attribute Details

#configObject (readonly)

Returns the value of attribute config.



82
83
84
# File 'lib/dspy/subscribers/otel_subscriber.rb', line 82

def config
  @config
end