Skip to content

Commit 9d73007

Browse files
authored
guard against missing botocore response metadata (#1264)
* guard against missing botocore response metadata as is done for request_id * avoid omitting false-y values
1 parent 218b16e commit 9d73007

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

ddtrace/contrib/botocore/patch.py

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -70,12 +70,15 @@ def patched_api_call(original_func, instance, args, kwargs):
7070
result = original_func(*args, **kwargs)
7171

7272
response_meta = result['ResponseMetadata']
73-
span.set_tag(http.STATUS_CODE, response_meta['HTTPStatusCode'])
74-
span.set_tag('retry_attempts', response_meta['RetryAttempts'])
7573

76-
request_id = response_meta.get('RequestId')
77-
if request_id:
78-
span.set_tag('aws.requestid', request_id)
74+
if 'HTTPStatusCode' in response_meta:
75+
span.set_tag(http.STATUS_CODE, response_meta['HTTPStatusCode'])
76+
77+
if 'RetryAttempts' in response_meta:
78+
span.set_tag('retry_attempts', response_meta['RetryAttempts'])
79+
80+
if 'RequestId' in response_meta:
81+
span.set_tag('aws.requestid', response_meta['RequestId'])
7982

8083
# set analytics sample rate
8184
span.set_tag(

0 commit comments

Comments
 (0)