Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Backport Rack proxy event to middleware #764

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,8 @@ def call(env)
tracer.in_span(request_span_name,
attributes: request_span_attributes(env: env),
kind: request_span_kind) do |request_span|
request_start_time = OpenTelemetry::Instrumentation::Rack::Util::QueueTime.get_request_start(env)
request_span.add_event('http.proxy.request.started', timestamp: request_start_time) unless request_start_time.nil?
OpenTelemetry::Instrumentation::Rack.with_span(request_span) do
@app.call(env).tap do |status, headers, response|
set_attributes_after_request(request_span, status, headers, response)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
let(:exporter) { EXPORTER }
let(:finished_spans) { exporter.finished_spans }
let(:first_span) { exporter.finished_spans.first }
let(:proxy_event) { first_span.events&.first }

let(:default_config) { {} }
let(:config) { default_config }
Expand Down Expand Up @@ -84,6 +85,15 @@
end
end

describe 'given request proxy headers' do
let(:env) { Hash('HTTP_X_REQUEST_START' => '1677723466') }

it 'records an event' do
_(proxy_event.name).must_equal 'http.proxy.request.started'
_(proxy_event.timestamp).must_equal 1_677_723_466_000_000_000
end
end

describe 'config[:untraced_endpoints]' do
describe 'when an array is passed in' do
let(:config) { { untraced_endpoints: ['/ping'] } }
Expand Down