class RubyLLM::OpenTelemetry
Optional OpenTelemetry tracing through RubyLLM’s instrumentation events. Configure your application’s SDK and exporters before calling .enable.
Public Class Methods
Source
# File lib/ruby_llm/open_telemetry.rb, line 33 def disable @mutex.synchronize { Support::Instrumentation.unsubscribe(@subscriber) if @subscriber } nil end
Disables tracing for new operations without shutting down the SDK. Operations already running finish their spans normally.
Source
# File lib/ruby_llm/open_telemetry.rb, line 19 def enable(content: false) require 'opentelemetry-api' @mutex.synchronize do @content = content @subscriber ||= new Support::Instrumentation.subscribe(@subscriber) end nil rescue LoadError raise LoadError, "OpenTelemetry tracing requires the 'opentelemetry-api' gem. Add it to your Gemfile." end
Enables tracing without replacing the configured instrumenter. Requires the optional opentelemetry-api gem. Repeated calls are harmless. The application owns the tracer provider, SDK, and exporters. With content: true, spans also carry instructions, messages, model output, and tool arguments and results.
RubyLLM::OpenTelemetry.enable RubyLLM::OpenTelemetry.enable(content: true)