module Datadog::Contrib::Sinatra::Tracer::Base
Method overrides for Sinatra::Base
Public Instance Methods
render(engine, data, *)
click to toggle source
Calls superclass method
# File lib/ddtrace/contrib/sinatra/tracer.rb, line 80 def render(engine, data, *) tracer = Datadog.configuration[:sinatra][:tracer] return super unless tracer.enabled tracer.trace(Ext::SPAN_RENDER_TEMPLATE, span_type: Datadog::Ext::HTTP::TEMPLATE) do |span| span.set_tag(Ext::TAG_TEMPLATE_ENGINE, engine) # If data is a string, it is a literal template and we don't # want to record it. span.set_tag(Ext::TAG_TEMPLATE_NAME, data) if data.is_a? Symbol # Measure service stats Contrib::Analytics.set_measured(span) super end end
route_eval()
click to toggle source
Invoked when a matching route is found. This method yields directly to user code.
Calls superclass method
# File lib/ddtrace/contrib/sinatra/tracer.rb, line 100 def route_eval configuration = Datadog.configuration[:sinatra] tracer = configuration[:tracer] return super unless tracer.enabled tracer.trace( Ext::SPAN_ROUTE, service: configuration[:service_name], span_type: Datadog::Ext::HTTP::TYPE_INBOUND, resource: "#{request.request_method} #{@datadog_route}", ) do |span| span.set_tag(Ext::TAG_APP_NAME, settings.name || settings.superclass.name) span.set_tag(Ext::TAG_ROUTE_PATH, @datadog_route) span.set_tag(Ext::TAG_SCRIPT_NAME, request.script_name) if request.script_name && !request.script_name.empty? rack_request_span = env[Datadog::Contrib::Rack::TraceMiddleware::RACK_REQUEST_SPAN] rack_request_span.resource = span.resource if rack_request_span sinatra_request_span = if self.class <= ::Sinatra::Application # Classic style (top-level) application Sinatra::Env.datadog_span(env, ::Sinatra::Application) else Sinatra::Env.datadog_span(env, self.class) end if sinatra_request_span # DEV: Is it possible for sinatra_request_span to ever be nil here? sinatra_request_span.resource = span.resource end Contrib::Analytics.set_measured(span) super end end