lib/opentelemetry/adapters/sinatra/middlewares/tracer_middleware.rb in opentelemetry-adapters-sinatra-0.4.0 vs lib/opentelemetry/adapters/sinatra/middlewares/tracer_middleware.rb in opentelemetry-adapters-sinatra-0.4.1
- old
+ new
@@ -15,12 +15,11 @@
end
def call(env)
tracer.in_span(
env['PATH_INFO'],
- attributes: { 'component' => 'http',
- 'http.method' => env['REQUEST_METHOD'],
+ attributes: { 'http.method' => env['REQUEST_METHOD'],
'http.url' => env['PATH_INFO'] },
kind: :server,
with_parent_context: parent_context(env)
) do |span|
app.call(env).tap { |resp| trace_response(span, env, resp) }
@@ -42,10 +41,10 @@
def trace_response(span, env, resp)
status, _headers, _response_body = resp
span.set_attribute('http.status_code', status)
span.set_attribute('http.status_text', ::Rack::Utils::HTTP_STATUS_CODES[status])
- span.set_attribute('http.route', env['sinatra.route'].split.last)
+ span.set_attribute('http.route', env['sinatra.route'].split.last) if env['sinatra.route']
span.status = OpenTelemetry::Trace::Status.http_to_status(status)
end
end
end
end