diff --git a/lib/datadog/tracing/contrib/stripe/request.rb b/lib/datadog/tracing/contrib/stripe/request.rb index a05a52cd4c..ac295b3af4 100644 --- a/lib/datadog/tracing/contrib/stripe/request.rb +++ b/lib/datadog/tracing/contrib/stripe/request.rb @@ -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) diff --git a/spec/datadog/tracing/contrib/stripe/request_spec.rb b/spec/datadog/tracing/contrib/stripe/request_spec.rb index 5159d07bde..2a8f522c1e 100644 --- a/spec/datadog/tracing/contrib/stripe/request_spec.rb +++ b/spec/datadog/tracing/contrib/stripe/request_spec.rb @@ -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') @@ -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')