Skip to content

Add W3C Trace Context propagation#284

Merged
JE-Chen merged 2 commits into
devfrom
feat/trace-context-batch
Jun 21, 2026
Merged

Add W3C Trace Context propagation#284
JE-Chen merged 2 commits into
devfrom
feat/trace-context-batch

Conversation

@JE-Chen

@JE-Chen JE-Chen commented Jun 21, 2026

Copy link
Copy Markdown
Member

What

Adds the W3C Trace Context standard so spans, logs, and downstream services share one trace/span lineage across HTTP boundaries. The existing observability tracer and agent_trace spans carried no IDs and could not be correlated across a call.

  • SpanContext (immutable trace_id/span_id/trace_flags/tracestate).
  • new_root_context / child_context; parse_traceparent / format_traceparent (version-00, rejects bad version / malformed / all-zero IDs with TraceContextError); parse_tracestate / format_tracestate.
  • inject_context / extract_context over a headers dict (case-insensitive extract).
  • ID generation takes an injectable RNG → deterministic IDs in CI.

Layers

  • Headless core: utils/trace_context/ (pure stdlib os/re, zero PySide6).
  • Facade: 12 symbols exported from je_auto_control + __all__.
  • Executor: AC_trace_inject, AC_trace_extract.
  • MCP: ac_trace_inject, ac_trace_extract (read-only).
  • Script Builder: both under Data.
  • Tests: test/unit_test/headless/test_trace_context_batch.py (14 tests, no Qt/network).
  • Docs: v76_features_doc.rst (EN + Zh) + toctrees + 3 README What's-new sections.

Verification

  • pytest test/unit_test/headless/test_trace_context_batch.py → 14 passed.
  • ruff check je_auto_control/ clean; pylint 10.00/10; bandit clean; radon CC clean.
  • Package stays Qt-free.

The observability tracer and agent_trace spans carried no IDs, so a span
on one side of an HTTP call could not be correlated with the work it
triggered downstream. Add the W3C Trace Context standard: generate, parse,
and propagate traceparent / tracestate headers with an injectable RNG for
deterministic IDs under test. Wired through facade, executor
(AC_trace_inject / AC_trace_extract), MCP, and the Script Builder with a
headless test batch and EN/Zh docs.
@codacy-production

codacy-production Bot commented Jun 21, 2026

Copy link
Copy Markdown

Up to standards ✅

🟢 Issues 0 issues

Results:
0 new issues

View in Codacy

🟢 Metrics 61 complexity · 0 duplication

Metric Results
Complexity 61
Duplication 0

View in Codacy

NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes.

@JE-Chen JE-Chen merged commit d3b2389 into dev Jun 21, 2026
16 checks passed
@JE-Chen JE-Chen deleted the feat/trace-context-batch branch June 21, 2026 13:52
@sonarqubecloud

Copy link
Copy Markdown

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant