lib/opentelemetry/instrumentation/rack/middlewares/tracer_middleware.rb in opentelemetry-instrumentation-rack-0.12.0 vs lib/opentelemetry/instrumentation/rack/middlewares/tracer_middleware.rb in opentelemetry-instrumentation-rack-0.13.0

- old
+ new

@@ -99,16 +99,17 @@ def tracer OpenTelemetry::Instrumentation::Rack::Instrumentation.instance.tracer end def request_span_attributes(env:) - { + attributes = { 'http.method' => env['REQUEST_METHOD'], 'http.host' => env['HTTP_HOST'] || 'unknown', 'http.scheme' => env['rack.url_scheme'], - 'http.target' => fullpath(env), - 'http.user_agent' => env['HTTP_USER_AGENT'] - }.merge(allowed_request_headers(env)) + 'http.target' => fullpath(env) + } + attributes['http.user_agent'] = env['HTTP_USER_AGENT'] if env['HTTP_USER_AGENT'] + attributes.merge(allowed_request_headers(env)) end # e.g., "/webshop/articles/4?s=1": def fullpath(env) query_string = env['QUERY_STRING']