-
Notifications
You must be signed in to change notification settings - Fork 833
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
base: main
Are you sure you want to change the base?
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.62% 94.63% +0.01%
==========================================
Files 323 323
Lines 8068 8067 -1
Branches 1637 1637
==========================================
Hits 7634 7634
+ Misses 434 433 -1
|
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: