fix(tracing): preserve upload causality during watchdog republication

This commit is contained in:
2026-11-20 21:14:51 +03:00
parent 45cf1532aa
commit 7511db034a
3 changed files with 963 additions and 1 deletions
+7 -1
View File
@@ -108,7 +108,13 @@ def event(conn, job_id, name, detail=None):
def enqueue(conn, job_id):
row = conn.execute("SELECT * FROM jobs WHERE id=%s", (job_id,)).fetchone()
context = telemetry.carrier()
if not context and row.get("traceparent"):
retained = row.get("traceparent", "")
# A watchdog DB span may start an unrelated trace. Keep the upload's
# causal trace; an actual retry in that same trace may advance its parent.
if retained and (
context.get("traceparent", "").split("-")[1:2]
!= retained.split("-")[1:2]
):
context = {"traceparent": row["traceparent"]}
if row.get("tracestate"):
context["tracestate"] = row["tracestate"]