Sha256: f86972ba6778bb3854986c9e5c76917f28c8325b00e553e50ad14e53a8e0a7cc

Contents?: true

Size: 1.7 KB

Versions: 2

Compression:

Stored size: 1.7 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 'sinatra/transaction_namer'
require_relative 'sinatra/ignorer'
require_relative 'sinatra/instrumentation'
require_relative 'sinatra/chain'
require_relative 'sinatra/prepend'

DependencyDetection.defer do
  named :sinatra

  depends_on { defined?(Sinatra) && defined?(Sinatra::Base) }
  depends_on { Sinatra::Base.private_method_defined?(:dispatch!) }
  depends_on { Sinatra::Base.private_method_defined?(:process_route) }
  depends_on { Sinatra::Base.private_method_defined?(:route_eval) }

  executes do
    if use_prepend?
      prepend_instrument Sinatra::Base, NewRelic::Agent::Instrumentation::Sinatra::Prepend
    else
      chain_instrument NewRelic::Agent::Instrumentation::Sinatra::Chain
    end

    Sinatra::Base.class_eval { register NewRelic::Agent::Instrumentation::Sinatra::Ignorer }
    Sinatra.module_eval { register NewRelic::Agent::Instrumentation::Sinatra::Ignorer }
  end

  executes do
    supportability_name = NewRelic::Agent::Instrumentation::Sinatra::Tracer::INSTRUMENTATION_NAME
    # These requires are inside an executes block because they require rack, and
    # we can't be sure that rack is available when this file is first required.
    require 'new_relic/rack/agent_hooks'
    require 'new_relic/rack/browser_monitoring'
    if use_prepend?
      prepend_instrument Sinatra::Base.singleton_class, NewRelic::Agent::Instrumentation::Sinatra::Build::Prepend, supportability_name
    else
      chain_instrument NewRelic::Agent::Instrumentation::Sinatra::Build::Chain, supportability_name
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
newrelic_rpm-9.16.0 lib/new_relic/agent/instrumentation/sinatra.rb
newrelic_rpm-9.15.0 lib/new_relic/agent/instrumentation/sinatra.rb