-
Notifications
You must be signed in to change notification settings - Fork 847
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
fix(sdk-trace-base): always wait on pending export in SimpleSpanProcessor #5303
fix(sdk-trace-base): always wait on pending export in SimpleSpanProcessor #5303
Conversation
…impleSpanProcessor
@@ -38,16 +38,16 @@ import { Resource } from '@opentelemetry/resources'; | |||
*/ | |||
export class SimpleSpanProcessor implements SpanProcessor { | |||
private _shutdownOnce: BindOnceFuture<void>; | |||
private _unresolvedExports: Set<Promise<void>>; | |||
private _pendingExports: Set<Promise<void>>; |
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.
unresolved seemed to be referring specifically to the resource so I renamed to pending to be more generic
@@ -81,26 +86,17 @@ export class SimpleSpanProcessor implements SpanProcessor { | |||
globalErrorHandler(error); | |||
}); | |||
|
|||
// Avoid scheduling a promise to make the behavior more predictable and easier to test |
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.
Removed this since it seemed to be misleading - a promise is scheduled by doExport
anyways so there's no way to avoid scheduling one
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #5303 +/- ##
=======================================
Coverage 94.77% 94.78%
=======================================
Files 309 309
Lines 7967 7958 -9
Branches 1678 1674 -4
=======================================
- Hits 7551 7543 -8
+ Misses 416 415 -1
|
Can anyone review this PR? @trentm maybe? |
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.
struggling with the correct comments, so feel free to drop them as necessary.
exportPromise = doExport(); | ||
} | ||
|
||
// store the unresolved exports |
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.
// store the unresolved exports | |
// If async, enqueue this export to the pending list |
…y-js into simplespanprocessor-waitalways
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.
LGTM. A couple nits, and one suggestion to add the _
prefix.
packages/opentelemetry-sdk-trace-base/src/export/SimpleSpanProcessor.ts
Outdated
Show resolved
Hide resolved
packages/opentelemetry-sdk-trace-base/src/export/SimpleSpanProcessor.ts
Outdated
Show resolved
Hide resolved
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.
Thanks, applied cleanups
…y-js into simplespanprocessor-waitalways
cc @mikeldking suspect y'all will appreciate this! |
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.
Nice fix. Just the one request to move the changelog entry down to the "Bugs" section.
…y-js into simplespanprocessor-waitalways
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.
LGTM.
Which problem is this PR solving?
It isn't possible to know when a
SimpleSpanProcessor
has finished exporting spans, e.g. before asserting on spans in a unit test. AFAIK unit tests are mostly required to useBatchSpanProcessor
because of this.Fixes #1841
Short description of the changes
Tracks pending exports always in
SimpleSpanProcessor
, not only when async resource is used. This is because export itself is async and has the same need for tracking as the async resource path. There isn't a way to avoid "scheduling a promise" if export itself is a promise.Type of change
Please delete options that are not relevant.
How Has This Been Tested?
Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce. Please also list any relevant details for your test configuration
Checklist: