Skip to content

Commit 82f273c

Browse files
andor44LotharSee
authored andcommitted
Only set trace and parent ID if it's passed
Otherwise we will potentially overwrite an auto-generated random ID
1 parent bdc44ce commit 82f273c

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

ddtrace/contrib/flask/middleware.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -93,8 +93,10 @@ def _start_span(self, trace_id=None, parent_id=None):
9393
service=self._service,
9494
span_type=http.TYPE,
9595
)
96-
g.flask_datadog_span.trace_id = trace_id
97-
g.flask_datadog_span.parent_id = parent_id
96+
if trace_id:
97+
g.flask_datadog_span.trace_id = trace_id
98+
if parent_id:
99+
g.flask_datadog_span.parent_id = parent_id
98100
except Exception:
99101
self.app.logger.exception("error tracing request")
100102

0 commit comments

Comments
 (0)