Skip to content

Commit ad09cc9

Browse files
committed
remove self.already_submitted_errors_metric_before flag and set_traceback on span
1 parent de5aba0 commit ad09cc9

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

datadog_lambda/wrapper.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,6 @@ def __init__(self, func):
110110
os.environ.get("DD_TRACE_MANAGED_SERVICES", "true").lower() == "true"
111111
)
112112
self.response = None
113-
self.already_submitted_errors_metric_before = False
114113

115114
if self.extractor_env:
116115
extractor_parts = self.extractor_env.rsplit(".", 1)
@@ -144,7 +143,6 @@ def __call__(self, event, context, **kwargs):
144143
return self.response
145144
except Exception:
146145
submit_errors_metric(context)
147-
self.already_submitted_errors_metric_before = True
148146
if self.span:
149147
self.span.set_traceback()
150148
raise
@@ -192,9 +190,10 @@ def _after(self, event, context):
192190
status_code = extract_http_status_code_tag(self.trigger_tags, self.response)
193191
if status_code:
194192
self.trigger_tags["http.status_code"] = status_code
195-
if not self.already_submitted_errors_metric_before:
196-
if len(status_code) == 3 and status_code.startswith("5"):
197-
submit_errors_metric(context)
193+
if len(status_code) == 3 and status_code.startswith("5"):
194+
submit_errors_metric(context)
195+
if self.span:
196+
self.span.set_traceback()
198197
# Create a new dummy Datadog subsegment for function trigger tags so we
199198
# can attach them to X-Ray spans when hybrid tracing is used
200199
if self.trigger_tags:

0 commit comments

Comments
 (0)