Skip to content

Log trace context option (v3) - #11

Merged
joseluisq merged 3 commits into
static-web-server:masterfrom
frenzzy:log-trace-context
Nov 24, 2026
Merged

joseluisq merged 3 commits into
static-web-server:masterfrom
frenzzy:log-trace-context

Conversation

@frenzzy

@frenzzy frenzzy commented Sep 28, 2026 •

Copy link
Copy Markdown
Contributor

Description

v3 docs for the --log-trace-context option proposed in static-web-server/static-web-server#760 (issue static-web-server/static-web-server#759). Rebased on the current master.

  • features/logging.md: a new "Logging Trace Context" section. When enabled and a request has a valid W3C traceparent header, the log lines written for the request get the top-level trace_id, span_id and trace_flags fields (OpenTelemetry "Trace Context in Non-OTLP Log Formats"). It covers the per-request response line, the --access-log-format line and the lines logged while the request is handled (e.g. the error_page warning). It also covers the lines logged while the response body is sent. Lines logged outside the request, such as connection errors or the HTTPS redirect listener, are not covered. The section also says that traceparent is taken from any client (unlike the proxy headers, which need --trusted-proxies), so the fields are only reliable behind a proxy that sets or replaces it, and that a version above 00 keeps only the sampled flag. It documents the json log format requirement, the default (disabled) and an example with a 404. The "Per-request logging" section mentions the new fields.
  • configuration/cli.md, configuration/env.md, configuration/file.md: the --log-trace-context option, the SERVER_LOG_TRACE_CONTEXT env and the log-trace-context key under [general]; the CLI help text matches --help.

Please merge this only together with (or after) the code PR.

prettier --check, markdownlint-cli2, vue-tsc and yarn build pass.

Describe the `--log-trace-context` option that adds the trace context of a
valid W3C `traceparent` request header to the JSON log lines written for the
request (the `response` line, the access log format line and the lines
logged while the request is handled), and list it in the CLI, environment
variable and config file references.
Say that `traceparent` is taken from any client, unlike the proxy headers,
so the trace context fields are only reliable behind a proxy that sets or
replaces it; that a version above `00` keeps only the `sampled` flag; and
that lines logged while the response body is sent get the fields too.
@joseluisq joseluisq added v3 enhancement New feature or request labels Nov 24, 2026
@joseluisq
joseluisq merged commit 0d7fd1f into static-web-server:master Nov 24, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request v3

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants