lib/ddtrace/contrib/sinatra/tracer.rb
# Invoked when a matching route is found.
# This method yields directly to user code.
Invoked when a matching route is found.
This method yields directly to user code.
Invoked when a matching route is found . This method yields directly to user code .
def route_eval
            configuration = Datadog.configuration[:sinatra]
            tracer = configuration[:tracer]
            return super unless tracer.enabled
            Sinatra::Tracer.create_middleware_span(env, configuration) unless Sinatra::Env.datadog_span(env)
            tracer.trace(
              Ext::SPAN_ROUTE,
              service: configuration[:service_name],
              span_type: Datadog::Ext::HTTP::TYPE_INBOUND
            ) do |span|
              span.resource = "#{request.request_method} #{@datadog_route}"
              span.set_tag(Ext::TAG_APP_NAME, settings.name || settings.superclass.name)
              span.set_tag(Ext::TAG_ROUTE_PATH, @datadog_route)
              if request.script_name && !request.script_name.empty?
                span.set_tag(Ext::TAG_SCRIPT_NAME, request.script_name)
              end
              rack_request_span = env[Datadog::Contrib::Rack::TraceMiddleware::RACK_REQUEST_SPAN]
              rack_request_span.resource = span.resource if rack_request_span
              Contrib::Analytics.set_measured(span)
              super
            end
          end
def route_eval configuration = Datadog . configuration [ :sinatra ] tracer = configuration [ :tracer ] return super unless tracer . enabled Sinatra :: Tracer . create_middleware_span ( env , configuration ) unless Sinatra :: Env . datadog_span ( env ) tracer . trace ( Ext :: SPAN_ROUTE , service : configuration [ :service_name ] , span_type : Datadog :: Ext :: HTTP :: TYPE_INBOUND ) do | span | span . resource = "#{request.request_method} #{@datadog_route}" span . set_tag ( Ext :: TAG_APP_NAME , settings . name || settings . superclass . name ) span . set_tag ( Ext :: TAG_ROUTE_PATH , @datadog_route ) if request . script_name && ! request . script_name . empty? span . set_tag ( Ext :: TAG_SCRIPT_NAME , request . script_name ) end rack_request_span = env [ Datadog :: Contrib :: Rack :: TraceMiddleware :: RACK_REQUEST_SPAN ] rack_request_span . resource = span . resource if rack_request_span Contrib :: Analytics . set_measured ( span ) super end end
Invoked when a matching route is found.
Invoked when a matching route is found .
# For initialization of Sinatra middleware span in order # guarantee that the Ext::SPAN_ROUTE span being created below # has the middleware span as its parent.