Repository navigation
Description
Problem Description
The roadmap Service writes its logs as JSON lines to stdout. No line carries a trace id, so you cannot go from a Service log line to its trace in Tempo.
Three causes:
JsonLogFormatterwrites only the keys inCONTEXT_LOG_KEYS(src/devops_cli/server/json_logs.py).trace_idandspan_idare not in it.- No record that the
jsonhandler gets goes throughTraceCorrelationFilter.attach_otel_logging_handler()puts the filter on the root logger, and a logger filter runs only for records logged on that logger. The Service log config setsdevops_clianduvicorntopropagate: False. Also,dictConfigreplaces the root handlers with["json"], so the Service has no OTLP log handler. - The Grafana Loki derived field regex is
(?:trace_id|traceId|traceID)[=:]\s*"?([a-f0-9]+)"?(k8s/monitoring/grafana-values.yaml). In a JSON line a"comes after the key and before:, so the regex does not match"trace_id":"...".
Reproduction Steps
- Run a Loki query over 6 hours:
sum(count_over_time({service_name="roadmap-service"} |~ "trace_?[iI]d" [6h])). - Compare it with
sum(count_over_time({service_name="roadmap-service"} [6h])).
Expected vs Actual Behavior
Expected: each Service JSON line that is written while a span is open carries trace_id and span_id, and Grafana shows a Tempo link on that line. Target: 90 % of job lines carry a trace_id.
Actual: 0 of 7,251 roadmap-service lines in 6 hours carry a trace id (2026-11-11).
Environment Diagnostics
roadmap-service on the homelab cluster, image from main on 2026-11-11. Loki 3.7.9, Grafana Loki data source from k8s/monitoring/grafana-values.yaml.
Logs, Traces, or Terminal Output
Evidence from the observability study of 2026-11-11 (practice P12, skeptic correction of P12). OTLP log records from runner Jobs do carry trace_id as structured metadata, but none come from roadmap-service.
Proposed fix
- Put
TraceCorrelationFilteron thejsonhandler (a handler filter runs for each record the handler gets). - Write
trace_idandspan_idinJsonLogFormatteronly when they are not empty. - Change the derived field regex so it also matches a JSON key, and add a second derived field that reads the
trace_idstructured metadata of OTLP log records. Do not maketrace_ida Loki stream label.
Pre-Submission Checklist
- I searched for duplicates (
trace_id json log,derived field loki,trace ids log lines,JsonLogFormatter,TraceCorrelationFilter). Closed feat(telemetry): send devops-cli logs with trace ids to Loki #813 built the OTLP log bridge; this item fixes the stdout JSON path.
Activity
dan-petty commentedon Nov 11, 2026
Intake placed this item to the backlog: intake puts every new item in the backlog. A person plans the milestones.
fixprefix of the title gives the type.server, and .github/labels.yml declares no scope/server label. Add the label to the file to give the scope to this item.Zero of 7251 service log lines carry a trace id, blocking trace correlation, but the service still functions.Enables debugging by linking service log lines to Tempo traces, a core observability need.Three small changes: move the filter to the handler, add two keys to the formatter, and fix one regex.Both add trace ids to logs in Loki, but #813 delivers the OTLP collector path while this item fixes the Service stdout JSON line path and the Grafana derived field regex.[-]fix(server): put trace ids on Service JSON log lines[/-][+]fix(service): put trace ids on Service JSON log lines[/+]devops-cli-service commentedon Nov 11, 2026
Released in v0.112.0: https://github.com/dan-petty/devops-cli/releases/tag/v0.112.0
devops-cli-service commentedon Nov 11, 2026
Live since 2026-11-11 14:13 UTC