Skip to content

Commit

Permalink
Fix: XRay propagator null exception (open-telemetry#833)
Browse files Browse the repository at this point in the history
* Fixing XRay propagator null exception

* Add test for missing header

Co-authored-by: Robert <robertlaurin@users.noreply.github.com>
  • Loading branch information
scar-lovevery and robertlaurin committed Jun 24, 2021
1 parent bef61b5 commit 42fa792
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ class TextMapPropagator
# if extraction fails
def extract(carrier, context: Context.current, getter: Context::Propagation.text_map_getter)
header = getter.get(carrier, XRAY_CONTEXT_KEY)
return context unless header

match = parse_header(header)
return context unless match

Expand Down
8 changes: 8 additions & 0 deletions propagator/xray/test/text_map_propagator_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,14 @@

context = propagator.extract(carrier, context: parent_context)

_(context).must_equal(parent_context)
end
it 'handles missing header gracefully' do
parent_context = OpenTelemetry::Context.empty
carrier = {}

context = propagator.extract(carrier, context: parent_context)

_(context).must_equal(parent_context)
end
end
Expand Down

0 comments on commit 42fa792

Please sign in to comment.