Skip to content

logger: correlation_id has no single definition across six sites #1069

Description

@gaborage

correlation_id is a framework-wide log field with no single definition. It is written as a string literal at six non-test sites, so nothing enforces the invariant that [C60.7] just documented — that on both messaging lanes correlation_id carries the framework trace ID and nothing else.

The six sites

  • messaging/internal/delivery/delivery.go — the shared outcome spine (AppendOutcome)
  • messaging/registry.go:836logProcessing
  • messaging/registry.go:869, :885ackMessage, nackMessage
  • scheduler/module.go:819
  • server/logger.go:231

Why it is worth doing

The rename in #1068 exists precisely because two different ids were being stamped under one key on the same line. That class of collision is invisible to review as long as the key is a literal repeated across packages — and the atom that documents the invariant cannot be enforced by anything but prose.

There is a second, related asymmetry: correlation_id is the framework's own cross-service id (from X-Request-ID, else derived from a traceparent, else a minted UUID), while trace_id/span_id come from the OTel span and appear only when a tracer provider is registered. They hold different values by design, and no document says so.

Shape worth discussing

A logger-level shared vocabulary — exported field-name constants, or a small helper that stamps identity fields — so the key has one definition and the two identifier spaces are named in one place. Deliberately not scoped here; the right altitude is the open question.

Raised by an altitude reviewer during #1068 and deferred as out of scope for that PR.

Metadata

Metadata

Assignees

No one assigned

    Labels

    area/loggerAffects the logger packagekind/refactorStructural improvement, no behavior changeneeds-triageAwaiting maintainer triage

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions