Skip to content

Commit

Permalink
aws-sdk: fix request_id tag for errors (#4101)
Browse files Browse the repository at this point in the history
Co-authored-by: Ilya Priven <[email protected]>
  • Loading branch information
2 people authored and uurien committed Mar 5, 2024
1 parent 3bb7bbe commit 978cac0
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
5 changes: 3 additions & 2 deletions packages/datadog-plugin-aws-sdk/src/base.js
Original file line number Diff line number Diff line change
Expand Up @@ -126,8 +126,9 @@ class BaseAwsSdkPlugin extends ClientPlugin {
if (err) {
span.setTag('error', err)

if (err.requestId) {
span.addTags({ 'aws.response.request_id': err.requestId })
const requestId = err.RequestId || err.requestId
if (requestId) {
span.addTags({ 'aws.response.request_id': requestId })
}
}

Expand Down
11 changes: 9 additions & 2 deletions packages/datadog-plugin-aws-sdk/test/aws-sdk.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ describe('Plugin', () => {

expect(span).to.include({
name: 'aws.request',
resource: 'completeMultipartUpload',
resource: 'completeMultipartUpload my-bucket',
service: 'test-aws-s3'
})

Expand All @@ -132,9 +132,16 @@ describe('Plugin', () => {
[ERROR_STACK]: error.stack,
'component': 'aws-sdk'
})
if (semver.intersects(version, '>=2.3.4')) {
expect(span.meta['aws.response.request_id']).to.match(/[\w]{8}(-[\w]{4}){3}-[\w]{12}/)
}
}).then(done, done)

s3.completeMultipartUpload('invalid', e => {
s3.completeMultipartUpload({
Bucket: 'my-bucket',
Key: 'my-key',
UploadId: 'my-upload-id'
}, e => {
error = e
})
})
Expand Down

0 comments on commit 978cac0

Please sign in to comment.