Module: Datadog::Contrib::Sinatra::Tracer::Base
- Defined in:
- lib/ddtrace/contrib/sinatra/tracer.rb
Overview
Method overrides for Sinatra::Base
Instance Method Summary collapse
- #render(engine, data) ⇒ Object
-
#route_eval ⇒ Object
Invoked when a matching route is found.
Instance Method Details
#render(engine, data) ⇒ Object
79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 |
# File 'lib/ddtrace/contrib/sinatra/tracer.rb', line 79 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 ⇒ Object
Invoked when a matching route is found. This method yields directly to user code.
99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 |
# File 'lib/ddtrace/contrib/sinatra/tracer.rb', line 99 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 ) 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 |