-
Notifications
You must be signed in to change notification settings - Fork 14
feat: trace queue worker transactions + structured span test infrastructure #465
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 all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
2540588
feat: wrap cds.Service.prototype.tx for queue worker tracing; replace…
sjvans 73e2210
test: skip queue-worker tracing suites on sqlite pending cds spawn fix
sjvans 55b89e2
test: address PR review — explicit Number() version compare, dedup re…
sjvans 74d924a
docs: changelog entry for queue worker tracing
sjvans 545e15b
test: drop redundant outboxed-and-inboxed messaging test
sjvans 7bac504
Merge branch 'develop' into improve-tracing-and-test-infrastructure
sjvans 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,59 @@ | ||
| // In-memory span exporter for tests. Spans are accumulated in a module-level array that | ||
| // tests can import directly via `require('./lib/MyInMemorySpanExporter').captured`. | ||
| // Wired into the tracer provider via .cdsrc.json profile config (no provider-poking from tests). | ||
|
|
||
| const { ExportResultCode } = require('@opentelemetry/core') | ||
|
|
||
| const captured = [] | ||
|
|
||
| class MyInMemorySpanExporter { | ||
| export(spans, resultCallback) { | ||
| captured.push(...spans) | ||
| resultCallback({ code: ExportResultCode.SUCCESS }) | ||
| } | ||
|
|
||
| shutdown() { | ||
| return Promise.resolve() | ||
| } | ||
|
|
||
| forceFlush() { | ||
| return Promise.resolve() | ||
| } | ||
| } | ||
|
|
||
| // Returns the captured spans grouped by traceId, each group is a hierarchy: | ||
| // { traceId, root, all, byParent } | ||
| // `root` is the span with no parent inside the group (the visible root for the exporter's | ||
| // "elapsed times:" primer logic — i.e. spans whose parentSpanId is not present in this group). | ||
| function groupedByTrace() { | ||
| const byTrace = new Map() | ||
| for (const s of captured) { | ||
| const tid = s.spanContext().traceId | ||
| if (!byTrace.has(tid)) byTrace.set(tid, []) | ||
| byTrace.get(tid).push(s) | ||
| } | ||
|
|
||
| return [...byTrace.entries()].map(([traceId, all]) => { | ||
| const ids = new Set(all.map(s => s.spanContext().spanId)) | ||
| const roots = all.filter(s => !s.parentSpanContext?.spanId || !ids.has(s.parentSpanContext.spanId)) | ||
| const byParent = new Map() | ||
| for (const s of all) { | ||
| const pid = s.parentSpanContext?.spanId | ||
|
sjvans marked this conversation as resolved.
|
||
| if (!byParent.has(pid)) byParent.set(pid, []) | ||
| byParent.get(pid).push(s) | ||
| } | ||
| return { traceId, root: roots[0], roots, all, byParent } | ||
| }) | ||
| } | ||
|
|
||
| // Returns just the visible "root" spans across all captured traces. These correspond 1:1 to | ||
| // "elapsed times:" primers our ConsoleSpanExporter would emit for the same data. | ||
| function rootSpans() { | ||
| return groupedByTrace().flatMap(g => g.roots) | ||
| } | ||
|
|
||
| function reset() { | ||
| captured.length = 0 | ||
| } | ||
|
|
||
| module.exports = { MyInMemorySpanExporter, captured, groupedByTrace, rootSpans, reset } | ||
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.
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.
Uh oh!
There was an error while loading. Please reload this page.