lib/opentelemetry/instrumentation/sinatra/middlewares/tracer_middleware.rb in opentelemetry-instrumentation-sinatra-0.7.0 vs lib/opentelemetry/instrumentation/sinatra/middlewares/tracer_middleware.rb in opentelemetry-instrumentation-sinatra-0.7.1
- old
+ new
@@ -13,14 +13,12 @@
def initialize(app)
@app = app
end
def call(env)
- span_name = env['sinatra.route'] || env['PATH_INFO']
-
tracer.in_span(
- span_name,
+ env['PATH_INFO'],
attributes: { 'http.method' => env['REQUEST_METHOD'],
'http.url' => env['PATH_INFO'] },
kind: :server,
with_parent: parent_context(env)
) do |span|
@@ -44,9 +42,10 @@
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) if env['sinatra.route']
+ span.name = env['sinatra.route'] if env['sinatra.route']
span.status = OpenTelemetry::Trace::Status.http_to_status(status)
end
end
end
end