Skip to content

Commit fb99de7

Browse files
committed
Cleanup exception handling code
1 parent 3f6a056 commit fb99de7

File tree

1 file changed

+8
-11
lines changed
  • src/instana/instrumentation/aws

1 file changed

+8
-11
lines changed

src/instana/instrumentation/aws/s3.py

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
# (c) Copyright Instana Inc. 2020
33

44
try:
5-
import contextlib
65
from typing import TYPE_CHECKING, Any, Callable, Dict, Sequence, Type
76

87
from instana.span_context import SpanContext
@@ -58,21 +57,19 @@ def collect_s3_injected_attributes(
5857
with tracer.start_as_current_span("s3", span_context=parent_context) as span:
5958
try:
6059
span.set_attribute("s3.op", operations[wrapped.__name__])
61-
# Suppress key/index errors to all the function to still happen
62-
with contextlib.suppress(IndexError, KeyError):
63-
if "Bucket" in kwargs:
64-
span.set_attribute("s3.bucket", kwargs["Bucket"])
65-
elif wrapped.__name__ in ["download_file", "download_fileobj"]:
66-
span.set_attribute("s3.bucket", args[0])
67-
else:
68-
span.set_attribute("s3.bucket", args[1])
69-
return wrapped(*args, **kwargs)
60+
if "Bucket" in kwargs:
61+
span.set_attribute("s3.bucket", kwargs["Bucket"])
62+
elif wrapped.__name__ in ["download_file", "download_fileobj"]:
63+
span.set_attribute("s3.bucket", args[0])
64+
else:
65+
span.set_attribute("s3.bucket", args[1])
7066
except Exception as exc:
7167
span.record_exception(exc)
7268
logger.debug(
7369
"collect_s3_injected_attributes: collect error", exc_info=True
7470
)
75-
raise exc
71+
72+
return wrapped(*args, **kwargs)
7673

7774
for method in [
7875
"upload_file",

0 commit comments

Comments
 (0)