Module: Braintrust::Trace::Contrib::Github::Crmne::RubyLLM

Defined in:
lib/braintrust/contrib/ruby_llm/deprecated.rb

Class Method Summary collapse

Class Method Details

.unwrap(chat = nil) ⇒ RubyLLM::Chat?

Unwrap RubyLLM to disable Braintrust tracing. This is the legacy API - uses the Context pattern to disable tracing.

Note: Prepended modules cannot be truly removed in Ruby. This method sets ‘enabled: false` in the Context, which the instrumentation checks before creating spans.

Parameters:

  • chat (RubyLLM::Chat, nil) (defaults to: nil)

    the chat instance to unwrap (if nil, unwraps the class)

Returns:

  • (RubyLLM::Chat, nil)

    the chat instance



33
34
35
36
37
38
39
# File 'lib/braintrust/contrib/ruby_llm/deprecated.rb', line 33

def self.unwrap(chat = nil)
  Log.warn("Braintrust::Trace::Contrib::Github::Crmne::RubyLLM.unwrap() is deprecated and will be removed in a future version.")

  target = chat || ::RubyLLM::Chat
  Braintrust::Contrib::Context.set!(target, enabled: false)
  chat
end

.wrap(chat = nil, tracer_provider: nil) ⇒ RubyLLM::Chat?

Wrap RubyLLM to automatically create spans for chat requests. This is the legacy API - delegates to the new contrib framework.

Parameters:

  • chat (RubyLLM::Chat, nil) (defaults to: nil)

    the chat instance to wrap (if nil, wraps the class)

  • tracer_provider (OpenTelemetry::SDK::Trace::TracerProvider) (defaults to: nil)

    the tracer provider

Returns:

  • (RubyLLM::Chat, nil)

    the wrapped chat instance



18
19
20
21
22
# File 'lib/braintrust/contrib/ruby_llm/deprecated.rb', line 18

def self.wrap(chat = nil, tracer_provider: nil)
  Log.warn("Braintrust::Trace::Contrib::Github::Crmne::RubyLLM.wrap() is deprecated and will be removed in a future version: use Braintrust.instrument!() instead.")
  Braintrust.instrument!(:ruby_llm, target: chat, tracer_provider: tracer_provider)
  chat
end