Skip to content

Commit 26e7402

Browse files
authored
fix: instrument latest aws-sdk response headers (#6911)
Modifies the aws-sdk instrumentation to pass pre-deserialization response headers to account for recently released changes.
1 parent d2208fc commit 26e7402

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

packages/datadog-instrumentations/src/aws-sdk.js

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,11 @@ function wrapRequest (send) {
3434
}
3535
}
3636

37-
function wrapDeserialize (deserialize, channelSuffix) {
37+
function wrapDeserialize (deserialize, channelSuffix, responseIndex = 0) {
3838
const headersCh = channel(`apm:aws:response:deserialize:${channelSuffix}`)
3939

40-
return function (response) {
40+
return function () {
41+
const response = arguments[responseIndex]
4142
if (headersCh.hasSubscribers) {
4243
headersCh.publish({ headers: response.headers })
4344
}
@@ -66,6 +67,12 @@ function wrapSmithySend (send) {
6667

6768
if (typeof command.deserialize === 'function') {
6869
shimmer.wrap(command, 'deserialize', deserialize => wrapDeserialize(deserialize, channelSuffix))
70+
} else if (this.config?.protocol?.deserializeResponse) {
71+
shimmer.wrap(
72+
this.config.protocol,
73+
'deserializeResponse',
74+
deserializeResponse => wrapDeserialize(deserializeResponse, channelSuffix, 2)
75+
)
6976
}
7077

7178
const ctx = {

0 commit comments

Comments
 (0)