feat(observability): inject traceId/spanId into pino logs for Loki-Tempo correlation (ANGA-1020)#161
Open
anhermon wants to merge 1 commit into
Open
feat(observability): inject traceId/spanId into pino logs for Loki-Tempo correlation (ANGA-1020)#161anhermon wants to merge 1 commit into
anhermon wants to merge 1 commit into
Conversation
…relation (ANGA-1020) Injects the active OpenTelemetry traceId and spanId into every pino log line via a mixin so that Loki log entries can be correlated with Tempo traces by traceId. Adds @opentelemetry/api as a direct server dependency (was previously only an implicit transitive dep of sdk-node); the api package is already resolved at 1.9.1 in the lockfile. Co-Authored-By: Paperclip <noreply@paperclip.ing>
|
✅ Benchmark Score: 86/100 (passing)
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
@opentelemetry/api ^1.9.0as a direct dependency ofserver(was only an implicit transitive dep viasdk-node; making it direct gives a stable import and ensures pnpm links it correctly)mixinto the pino logger inserver/src/middleware/logger.tsthat reads the active OTel span context and injectstraceId+spanIdinto every log linegetTraceContext()returns{}— zero-cost no-op with no performance impactBackground
ANGA-1020 — parent ANGA-384
Work plan items 1–3 (OTel packages,
tracing.ts,initTracing()call) were already merged inc40a3f013. This PR delivers item 4: traceId/spanId correlation in pino logs — the last outstanding piece so Loki log entries can be correlated with Tempo traces by traceId.Changes (2 files)
server/package.json— add@opentelemetry/api ^1.9.0as direct dependencyserver/src/middleware/logger.ts— addgetTraceContext()helper and pinomixinNote: no lockfile changes included — CI owns lockfile updates per policy.
Test plan
tsc --noEmit)docker compose -f docker-compose.yml -f docker-compose.observability.yml up), Loki log lines includetraceId+spanIdfieldsPAPERCLIP_OTEL_ENDPOINT, no trace fields appear and server starts normally🤖 Generated with Claude Code