fix: log span_id next to trace_id#1225
Merged
Merged
Conversation
Signed-off-by: ferhat elmas <elmas.ferhat@gmail.com>
TylerHillery
approved these changes
Jul 9, 2026
Contributor
There was a problem hiding this comment.
Pull request overview
This PR improves tracing-related structured logging by promoting the W3C traceparent span identifier alongside the existing trace_id, and refactors traceparent parsing to reduce intermediate allocations.
Changes:
- Refactor traceparent helper to return the validated full
traceparentvalue (instead of slicing out only the trace id). - Add
spanIdto request log context and promote it to Logflare as top-levelspan_id. - Update request logging + Logflare + helper unit tests to cover
spanIdbehavior.
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| src/internal/monitoring/request-context.ts | Rename/refactor traceparent helper to return validated traceparent string. |
| src/internal/monitoring/request-context.test.ts | Update unit tests for the new traceparent helper behavior. |
| src/internal/monitoring/logger.ts | Extend RequestLog type to include spanId. |
| src/internal/monitoring/logflare.ts | Promote spanId to top-level span_id in Logflare payload preparation. |
| src/internal/monitoring/logflare.test.ts | Update Logflare payload tests to include span_id. |
| src/http/plugins/log-request.ts | Parse span id from trace context and include it in request logs. |
| src/http/plugins/log-request.test.ts | Update request logging tests to validate spanId threading/empty cases. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Coverage Report for CI Build 29050683086Coverage decreased (-0.1%) to 79.325%Details
Uncovered ChangesNo uncovered changes found. Coverage Regressions20 previously-covered lines in 3 files lost coverage.
Coverage Stats💛 - Coveralls |
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.
What kind of change does this PR introduce?
Improvement for tracing logging
What is the current behavior?
#1224 added trace_id logging but it's not enough, because it doesn't know under which span to put logs.
What is the new behavior?
Similar to trace_id, log span_id as top level.
Additional context
For GC pressure, adapt get trace context to return full value and only slice for serialization without interim object.