Sha256: 87f4ae81be4a24e5646d3f27eda3fb9c0330e84885b85258c6a3c6e0a400ad3d

Contents?: true

Size: 1.24 KB

Versions: 13

Compression:

Stored size: 1.24 KB

Contents

# This file is distributed under New Relic's license terms.
# See https://github.com/newrelic/newrelic-ruby-agent/blob/main/LICENSE for complete details.
# frozen_string_literal: true

require_relative 'ruby_openai/instrumentation'
require_relative 'ruby_openai/chain'
require_relative 'ruby_openai/prepend'

DependencyDetection.defer do
  named :'ruby_openai'

  depends_on do
    NewRelic::Agent.config[:'ai_monitoring.enabled'] &&
      defined?(OpenAI) && defined?(OpenAI::Client) &&
      Gem::Version.new(OpenAI::VERSION) >= Gem::Version.new('3.4.0')
  end

  executes do
    if use_prepend?
      # TODO: Remove condition when we drop support for versions below 5.0.0
      if Gem::Version.new(OpenAI::VERSION) >= Gem::Version.new('5.0.0')
        prepend_instrument OpenAI::Client,
          NewRelic::Agent::Instrumentation::OpenAI::Prepend,
          NewRelic::Agent::Instrumentation::OpenAI::VENDOR
      else
        prepend_instrument OpenAI::Client.singleton_class,
          NewRelic::Agent::Instrumentation::OpenAI::Prepend,
          NewRelic::Agent::Instrumentation::OpenAI::VENDOR
      end
    else
      chain_instrument NewRelic::Agent::Instrumentation::OpenAI::Chain,
        NewRelic::Agent::Instrumentation::OpenAI::VENDOR
    end
  end
end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
newrelic_rpm-9.17.0 lib/new_relic/agent/instrumentation/ruby_openai.rb
newrelic_rpm-9.16.1 lib/new_relic/agent/instrumentation/ruby_openai.rb
newrelic_rpm-9.16.0 lib/new_relic/agent/instrumentation/ruby_openai.rb
newrelic_rpm-9.15.0 lib/new_relic/agent/instrumentation/ruby_openai.rb
newrelic_rpm-9.14.0 lib/new_relic/agent/instrumentation/ruby_openai.rb
newrelic_rpm-9.13.0 lib/new_relic/agent/instrumentation/ruby_openai.rb
newrelic_rpm-9.12.0 lib/new_relic/agent/instrumentation/ruby_openai.rb
newrelic_rpm-9.11.0 lib/new_relic/agent/instrumentation/ruby_openai.rb
newrelic_rpm-9.10.2 lib/new_relic/agent/instrumentation/ruby_openai.rb
newrelic_rpm-9.10.1 lib/new_relic/agent/instrumentation/ruby_openai.rb
newrelic_rpm-9.10.0 lib/new_relic/agent/instrumentation/ruby_openai.rb
newrelic_rpm-9.9.0 lib/new_relic/agent/instrumentation/ruby_openai.rb
newrelic_rpm-9.8.0 lib/new_relic/agent/instrumentation/ruby_openai.rb