Skip to content

Commit

Permalink
Fix missing request_id on event
Browse files Browse the repository at this point in the history
  • Loading branch information
TonyCTHsu committed Sep 19, 2024
1 parent 34416f3 commit 93438f4
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
5 changes: 3 additions & 2 deletions lib/datadog/tracing/contrib/stripe/request.rb
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,9 @@ def tag_span(span, event)

# Measure service stats
Contrib::Analytics.set_measured(span)

span.set_tag(Ext::TAG_REQUEST_ID, event.request_id)
# `5.38.0` Add request_id to RequestEndEvent
# https://github.com/stripe/stripe-ruby/blob/master/CHANGELOG.md#5380---2021-08-10
span.set_tag(Ext::TAG_REQUEST_ID, event.request_id) if event.respond_to?(:request_id)
span.set_tag(Ext::TAG_REQUEST_HTTP_STATUS, event.http_status.to_s)
span.set_tag(Ext::TAG_REQUEST_METHOD, event.method)
span.set_tag(Ext::TAG_REQUEST_PATH, event.path)
Expand Down
8 changes: 6 additions & 2 deletions spec/datadog/tracing/contrib/stripe/request_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,9 @@
expect(spans).to have(1).items
expect(span.name).to eq('stripe.request')
expect(span.resource).to eq('stripe.request')
expect(span.get_tag('stripe.request.id')).to eq('abc-123-def-456')
if Gem::Version.new(Stripe::VERSION) >= Gem::Version.new('5.38.0')
expect(span.get_tag('stripe.request.id')).to eq('abc-123-def-456')
end
expect(span.get_tag('stripe.request.http_status')).to eq('200')
expect(span.get_tag('stripe.request.method')).to eq('get')
expect(span.get_tag('stripe.request.path')).to eq('/v1/customers/cus_123')
Expand Down Expand Up @@ -69,7 +71,9 @@ def object_name
expect(spans).to have(1).items
expect(span.name).to eq('stripe.request')
expect(span.resource).to eq('stripe.customer')
expect(span.get_tag('stripe.request.id')).to eq('abc-123-def-456')
if Gem::Version.new(Stripe::VERSION) >= Gem::Version.new('5.38.0')
expect(span.get_tag('stripe.request.id')).to eq('abc-123-def-456')
end
expect(span.get_tag('stripe.request.http_status')).to eq('200')
expect(span.get_tag('stripe.request.method')).to eq('get')
expect(span.get_tag('stripe.request.path')).to eq('/v1/customers/cus_123')
Expand Down

0 comments on commit 93438f4

Please sign in to comment.