lib/opentelemetry/instrumentation/rack/middlewares/tracer_middleware.rb in opentelemetry-instrumentation-rack-0.20.0 vs lib/opentelemetry/instrumentation/rack/middlewares/tracer_middleware.rb in opentelemetry-instrumentation-rack-0.20.1
- old
+ new
@@ -16,11 +16,17 @@
# by way of its middleware system
class TracerMiddleware # rubocop:disable Metrics/ClassLength
class << self
def allowed_rack_request_headers
@allowed_rack_request_headers ||= Array(config[:allowed_request_headers]).each_with_object({}) do |header, memo|
- memo["HTTP_#{header.to_s.upcase.gsub(/[-\s]/, '_')}"] = build_attribute_name('http.request.headers.', header)
+ key = header.to_s.upcase.gsub(/[-\s]/, '_')
+ case key
+ when 'CONTENT_TYPE', 'CONTENT_LENGTH'
+ memo[key] = build_attribute_name('http.request.headers.', header)
+ else
+ memo["HTTP_#{key}"] = build_attribute_name('http.request.headers.', header)
+ end
end
end
def allowed_response_headers
@allowed_response_headers ||= Array(config[:allowed_response_headers]).each_with_object({}) do |header, memo|
@@ -60,11 +66,11 @@
end
original_env = env.dup
extracted_context = OpenTelemetry.propagation.extract(
env,
- getter: OpenTelemetry::Context::Propagation.rack_env_getter
+ getter: OpenTelemetry::Common::Propagation.rack_env_getter
)
frontend_context = create_frontend_span(env, extracted_context)
# restore extracted context in this process:
OpenTelemetry::Context.with_current(frontend_context || extracted_context) do
@@ -99,12 +105,10 @@
return unless config[:record_frontend_span] && !request_start_time.nil?
span = tracer.start_span('http_server.proxy',
with_parent: extracted_context,
- attributes: {
- 'start_time' => request_start_time.to_f
- },
+ start_timestamp: request_start_time,
kind: :server)
OpenTelemetry::Trace.context_with_span(span, parent_context: extracted_context)
end