Module: Braintrust::Trace::AlexRudall::RubyOpenAI

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

Class Method Summary collapse

Class Method Details

.wrap(client, tracer_provider: nil) ⇒ OpenAI::Client

Wrap an OpenAI::Client (ruby-openai gem) to automatically create spans. This is the legacy API - delegates to the new contrib framework.

Parameters:

  • client (OpenAI::Client)

    the OpenAI client to wrap

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

    the tracer provider (defaults to global)

Returns:

  • (OpenAI::Client)

    the wrapped client



16
17
18
19
20
# File 'lib/braintrust/contrib/ruby_openai/deprecated.rb', line 16

def self.wrap(client, tracer_provider: nil)
  Log.warn("Braintrust::Trace::AlexRudall::RubyOpenAI.wrap() is deprecated and will be removed in a future version: use Braintrust.instrument!() instead.")
  Braintrust.instrument!(:ruby_openai, target: client, tracer_provider: tracer_provider)
  client
end