Skip to content

fix(service): put trace ids on Service JSON log lines - #4511

Merged
dan-petty merged 2 commits into
mainfrom
fix/4510-service-log-trace-ids
Nov 11, 2026
Merged

dan-petty merged 2 commits into
mainfrom
fix/4510-service-log-trace-ids

Conversation

@dan-petty

Copy link
Copy Markdown
Owner

A roadmap Service log line in Loki now leads to its trace in Tempo. Before this change, 0 of 7,251 roadmap-service lines in 6 hours carried a trace id.

  • The json handler of service_log_config gets TraceCorrelationFilter. The filter on the root logger did not run for Service records: the devops_cli and uvicorn loggers do not propagate, and a logger filter does not run for a propagated record.
  • JsonLogFormatter writes trace_id and span_id when they are not empty: the ids of the open span of the own tracer, else of the current OpenTelemetry span.
  • The Loki data source in k8s/monitoring/grafana-values.yaml has a regex derived field that also matches "trace_id":"<id>", and a new label derived field that reads the trace_id structured metadata of OTLP log records.

Closes #4510

Change: openspec/changes/archive/2026-11-11-4510-put-trace-ids-on-service-json/

@dan-petty dan-petty added type/bug Type bug: the code does not do what it must scope/service The long-running devops Service and its lanes labels Nov 11, 2026
@dan-petty

Copy link
Copy Markdown
Owner Author

Fail-to-pass

uv run devops ci fail-to-pass --base origin/main (head dee7567c):

failed on base: test_grafana_links_a_service_json_line_and_an_otlp_record_to_their_trace (assert ([], 0) == (['4bf92f3577...0e0e4736'], 1))
passed on base: test_a_line_written_outside_a_span_has_no_trace_keys
failed on base: test_a_line_written_in_an_opentelemetry_span_names_that_spans_ids (assert [(None, None)] == [...])
failed on base: test_a_line_written_in_a_span_names_that_spans_trace_and_span_ids (assert [('Round done..., None, None)] == [...])
3 failed on base (3 failed and 1 passed in tests/server/test_service_log_trace_ids.py; 0 errored).

The test that passes on base is the guard: a line with no open span has no trace_id key and no span_id key.

On the head: tests/server/test_service_log_trace_ids.py, tests/server/test_server.py, tests/server/test_server_service.py, tests/telemetry/test_telemetry_logging_bridge.py and tests/commands/k8s/test_k8s_tempo.py: 121 passed.

Check after the release (target: 90 % or more)

The share of Service job lines that carry a trace_id, over 6 hours. Job lines are the lines of the devops_cli.roadmap.*, devops_cli.github.*, devops_cli.ai.* and devops_cli.server.service loggers. Today: 0 of 1,703 lines (2026-11-11).

(sum(count_over_time({service_name="roadmap-service", stream="stdout"} | json | __error__="" | logger=~"devops_cli[.](roadmap|github|ai)[.].*|devops_cli[.]server[.]service" | trace_id!="" [6h])) or vector(0))
/
sum(count_over_time({service_name="roadmap-service", stream="stdout"} | json | __error__="" | logger=~"devops_cli[.](roadmap|github|ai)[.].*|devops_cli[.]server[.]service" [6h]))

Run it as an instant query 6 hours after the new Service image runs. uvicorn.access lines are not in the count: most are probe requests, which open no span, and uvicorn writes the line after the middleware span closes.

Live steps

  • No manual step. The Argo CD app grafana syncs k8s/monitoring/grafana-values.yaml from main, and the Service gets the code with its next image.
  • To check the link: in Grafana Explore, run {service_name="roadmap-service", stream="stdout"} |= "trace_id" with a limit of 10, open a line, and click the TraceID link. For an OTLP record, run {service_name="devops-cli-job"} with a limit of 10 and click TraceIDMetadata.

@dan-petty
dan-petty marked this pull request as ready for review November 11, 2026 05:52
@dan-petty
dan-petty merged commit 0d7a0d2 into main Nov 11, 2026
32 checks passed
@dan-petty
dan-petty deleted the fix/4510-service-log-trace-ids branch November 11, 2026 05:52
dan-petty pushed a commit that referenced this pull request Nov 11, 2026
🤖 I have created a release *beep* *boop*
---


##
[0.112.0](v0.111.0...v0.112.0)
(2026-11-11)


### Features

* **k8s:** export gateway spans without key metadata
([#4520](#4520))
([7234d71](7234d71))
* **k8s:** set the homelab domain in container env values
([#4608](#4608))
([a3bcf7c](a3bcf7c))
* **telemetry:** send pydantic-ai spans through the exporter seam
([#4538](#4538))
([fcf2a7a](fcf2a7a))


### Bug Fixes

* **ai:** price cached prompt tokens of chat calls
([#4584](#4584))
([f84bbe6](f84bbe6))
* **devcontainer:** stop uv noise lines in agent shells
([#4592](#4592))
([9ba375c](9ba375c))
* **k8s:** delete gateway management bodies from spans
([#4551](#4551))
([b835d3c](b835d3c))
* **k8s:** set the kube context and namespace on devops pods
([#4514](#4514))
([9087b39](9087b39))
* **roadmap:** a refused spec after the archive is a plan defect
([#4549](#4549))
([1db29f7](1db29f7))
* **roadmap:** count and log the reason of a left-out stage item
([#4541](#4541))
([5600179](5600179))
* **roadmap:** default the step ceiling to twice the budget
([#4556](#4556))
([1dfb6c8](1dfb6c8))
* **roadmap:** explain --trace shows the argument digest
([#4526](#4526))
([c92195f](c92195f))
* **roadmap:** explain totals count dropped model events
([#4543](#4543))
([fe0e979](fe0e979))
* **roadmap:** give each eval verify run its own report file
([#4534](#4534))
([ad27f2d](ad27f2d))
* **roadmap:** one event loop and a time limit for decide_all
([#4585](#4585))
([ec51e01](ec51e01))
* **roadmap:** scoped updates send requests with no row scope
([#4531](#4531))
([5f75d25](5f75d25))
* **roadmap:** the caller gate reads an added parameter span
([#4548](#4548))
([1ba07c1](1ba07c1))
* **roadmap:** the implement shell waits for its command
([#4536](#4536))
([571e044](571e044))
* **roadmap:** the module-test and caller gates read imports and calls
([#4490](#4490))
([8a22e82](8a22e82))
* **service:** put trace ids on Service JSON log lines
([#4511](#4511))
([0d7a0d2](0d7a0d2))


### Performance Improvements

* **ai:** keep intake embeddings between CLI runs
([#4546](#4546))
([812871e](812871e))
* **roadmap:** intake reads only the issues that changed
([#4552](#4552))
([7dfd155](7dfd155))

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).

Co-authored-by: dan-petty-release[bot] <346998822+dan-petty-release[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

scope/service The long-running devops Service and its lanes type/bug Type bug: the code does not do what it must

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix(service): put trace ids on Service JSON log lines

1 participant