Skip to content

Commit 89dd102

Browse files
GSVarshapvital
authored andcommitted
refactor(s3): Fix exception handling and logging
Signed-off-by: Varsha GS <[email protected]>
1 parent 1541e9f commit 89dd102

File tree

1 file changed

+14
-7
lines changed
  • src/instana/instrumentation/aws

1 file changed

+14
-7
lines changed

src/instana/instrumentation/aws/s3.py

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -59,17 +59,24 @@ def collect_s3_injected_attributes(
5959
span.set_attribute("s3.op", operations[wrapped.__name__])
6060
if "Bucket" in kwargs:
6161
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])
62+
elif len(args) > 1:
63+
if wrapped.__name__ in ["download_file", "download_fileobj"]:
64+
span.set_attribute("s3.bucket", args[0])
65+
else:
66+
span.set_attribute("s3.bucket", args[1])
67+
except Exception:
68+
logger.debug(
69+
f"collect_s3_injected_attributes collect error: {wrapped.__name__}", exc_info=True
70+
)
71+
72+
try:
73+
return wrapped(*args, **kwargs)
6674
except Exception as exc:
6775
span.record_exception(exc)
6876
logger.debug(
69-
"collect_s3_injected_attributes: collect error", exc_info=True
77+
f"collect_s3_injected_attributes error: {wrapped.__name__}", exc_info=True
7078
)
71-
72-
return wrapped(*args, **kwargs)
79+
raise
7380

7481
for method in [
7582
"upload_file",

0 commit comments

Comments
 (0)