-
Notifications
You must be signed in to change notification settings - Fork 2
Enable Cloudflare tracing + bind rayId/traceparent/instanceId onto logs #111
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 6 commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
8271b6d
feat(logger): add parseTraceparent helper for W3C trace context
26d70aa
test(logger): expand parseTraceparent edge-case coverage
f9344e9
feat(main): bind rayId and W3C trace context onto request logger
c8f7ee0
test(main): use afterEach restoreAllMocks for tracing spy cleanup
9a087ee
feat(workflow): bind instanceId onto TaskRunnerWorkflow logger
41a467a
chore(wrangler): enable tracing and invocation logs observability
4e37842
docs(logger): note why parseTraceparent is rolled inline
e579334
feat(trace): propagate rayId/traceId/spanId from Worker into Workflow
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
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
Oops, something went wrong.
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Cloudflare doesn't have some open source library to help with this? Feels like a thing that we shouldn't have to implement from scratch
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looked into this. Summary of what's on the shelf today:
[observability.traces]is on, the runtime auto-propagatestraceparenton outboundfetch, but the parsed context is only exposed to Tail Workers (SpanContextin workers-types is Tail-only). To puttraceId/spanIdinto our structured logs in thefetchhandler, we have to pull it off the incoming header ourselves.@opentelemetry/core— exportsW3CTraceContextPropagatorpublicly, but to use it you build aContext+ aTextMapGetteradapter just to read two hex strings. TheparseTraceParent(header)helper that would be a clean fit is an internal export, not a public API. Plus@opentelemetry/apipeer dep + bundle weight for ~15 lines of work.tctx(maraisr) — cleanest API match (traceparent.parse(header)), MIT, zero deps. But ~2.5k weekly downloads, single maintainer — supply-chain trade for 20 LOC feels lopsided.traceparent(elastic) — inactive, no release in the last year.@microlabs/otel-cf-workers/cloudflare/workers-honeycomb-logger— the Workers-community references I looked at either hand-roll extraction or go through the full OTel stack. No one's pulling a small dedicated parser.I left the 20-line inline parser in place and added a comment at
src/utils/logger.ts:60noting the options I evaluated and why, plus a link to W3C Trace Context §3.2 so the validation rules are traceable. Happy to swap totctxif you'd rather lean on a package — just want to flag the DL/maintainer profile first. If/when Cloudflare exposes the parsed context in the request path, the right move is to delete the helper, not to swap in a library.Pushed in 4e37842.