Skip to content

Commit 84ced08

Browse files
rustyconoverclaude
andcommitted
Skip worker.invocation span for secondary workers
Secondary workers are now children of the primary's GlobalInit span, so creating a worker.invocation span for them is redundant. Skip it and go directly to the worker.init and worker.process spans. The trace hierarchy is now cleaner: Primary worker.invocation └── Primary worker.init (GlobalInit) ├── Secondary 1 worker.init │ └── worker.process └── Secondary 2 worker.init └── worker.process Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
1 parent 13e21d7 commit 84ced08

1 file changed

Lines changed: 15 additions & 5 deletions

File tree

vgi/worker.py

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1505,11 +1505,21 @@ def _run_loop(self, tracer: Any) -> None:
15051505
)
15061506

15071507
try:
1508-
with tracer.start_as_current_span(
1509-
"worker.invocation",
1510-
kind=tracing.get_span_kind_server(),
1511-
) as invocation_span:
1512-
self._process_invocation(invocation, fn_log, invocation_span)
1508+
if is_secondary:
1509+
# Secondary workers: skip worker.invocation span since
1510+
# they're already children of primary's GlobalInit
1511+
from vgi.tracing import _NoOpSpan
1512+
1513+
self._process_invocation(invocation, fn_log, _NoOpSpan())
1514+
else:
1515+
# Primary workers: create worker.invocation span
1516+
with tracer.start_as_current_span(
1517+
"worker.invocation",
1518+
kind=tracing.get_span_kind_server(),
1519+
) as invocation_span:
1520+
self._process_invocation(
1521+
invocation, fn_log, invocation_span
1522+
)
15131523
finally:
15141524
# Always detach trace context
15151525
tracing.detach_trace_context(trace_token)

0 commit comments

Comments
 (0)