Skip to content

Commit 3782cee

Browse files
author
Peter Giacomo Lombardo
authored
boto3: Add collection safeties and limits (#278)
* Better arg extraction * Pymongo: Remove unused KV * Limit collected KVs
1 parent 554ea2f commit 3782cee

File tree

3 files changed

+7
-13
lines changed

3 files changed

+7
-13
lines changed

instana/instrumentation/boto3_inst.py

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -100,18 +100,13 @@ def s3_inject_method_with_instana(wrapped, instance, arg_list, kwargs):
100100
scope.span.set_tag('http.url', instance._endpoint.host + ':443/' + operation)
101101
scope.span.set_tag('http.method', 'POST')
102102

103-
index = 1
104-
payload = {}
105103
arg_length = len(arg_list)
106-
107-
for arg_name in fas_args:
108-
payload[arg_name] = arg_list[index-1]
109-
110-
index += 1
111-
if index > arg_length:
112-
break
113-
114-
scope.span.set_tag('payload', payload)
104+
if arg_length > 0:
105+
payload = {}
106+
for index in range(arg_length):
107+
if fas_args[index] in ['Filename', 'Bucket', 'Key']:
108+
payload[fas_args[index]] = arg_list[index]
109+
scope.span.set_tag('payload', payload)
115110
except Exception as exc:
116111
logger.debug("s3_inject_method_with_instana: collect error", exc_info=True)
117112

instana/instrumentation/pymongo.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,6 @@ def failed(self, event):
4848
def _collect_connection_tags(self, span, event):
4949
(host, port) = event.connection_id
5050

51-
span.set_tag("driver", "pymongo")
5251
span.set_tag("host", host)
5352
span.set_tag("port", str(port))
5453
span.set_tag("db", event.database_name)

tests/clients/boto3/test_boto3_s3.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@ def test_s3_upload_file_obj(s3):
187187
assert(boto_span.data['boto3']['op'] == 'upload_fileobj')
188188
assert(boto_span.data['boto3']['ep'] == 'https://s3.amazonaws.com')
189189
assert(boto_span.data['boto3']['reg'] == 'us-east-1')
190-
payload = {'Fileobj': "<_io.BufferedReader name='%s'>" % upload_filename, 'Bucket': 'aws_bucket_name', 'Key': 'aws_key_name'}
190+
payload = {'Bucket': 'aws_bucket_name', 'Key': 'aws_key_name'}
191191
assert boto_span.data['boto3']['payload'] == payload
192192
assert boto_span.data['http']['method'] == 'POST'
193193
assert boto_span.data['http']['url'] == 'https://s3.amazonaws.com:443/upload_fileobj'

0 commit comments

Comments
 (0)