feat(sdk-logs)!: invoke exporter forceFlush without first awaiting export#6356
Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #6356 +/- ##
==========================================
- Coverage 95.75% 95.73% -0.03%
==========================================
Files 371 371
Lines 12514 12571 +57
Branches 2962 2971 +9
==========================================
+ Hits 11983 12035 +52
- Misses 531 536 +5
🚀 New features to boost your workflow:
|
0a74514 to
70b80f5
Compare
70b80f5 to
34958de
Compare
Co-authored-by: Trent Mick <trentm@gmail.com>
bf762a0 to
b1e95a5
Compare
|
@trentm - thanks for the review! Issues should be addressed now and the PR is ready for another round :) |
trentm
left a comment
There was a problem hiding this comment.
LGTM, modulo the changelog conflict.
Sorry that I dropped the ball on re-reviewing this for so long.
| } | ||
|
|
||
| if (pendingResources != null && pendingResources.length > 0) { | ||
| await Promise.all(pendingResources); |
There was a problem hiding this comment.
Idle perf thought (not really related to this PR): The common case will be all these logRecord.resource things being the same resource object. I wonder if using a Set to reduce the number of resource objects to Promise.all() on would be faster.
There was a problem hiding this comment.
Good point! Created #6568 to follow up on this :)
Which problem is this PR solving?
This PR tackles two things that are related:
From the Specification:
Makes the
BatchLogRecordProcessor#forceFlush()spec compliant by callingLogRecordExporter#forceFlush()for the export that is currently scheduled, as well as all following exports within the flush operation. CallingforceFlush()means that we tell the exporter to speed up the export, however, we need to make sure we do not await the export before callingforceFlush()as there's little point to that - this is what we're currently doing in the Trace SDK and Metrics SDK. See #6340 for the big picture on how I'm planning to change these.It also adds
LogRecordExporter#forceFlush()so that it can be called in the first place (ref #6352)This was already implemented in the OTLP exporters, since they share the same base exporter with Traces and Metrics, however third-party exporters may not implement this - that's why I marked this change as a breaking change.
The reason why I made this operation requires is this specification:
Additonal info: the motivation for this change is spec compliance, but also to eventually allow cancelling of retries in the OTLP exporter, speeding up shutdown when the OTLP endpoint is not available (ref open-telemetry/opentelemetry-js-contrib#3349).
Fixes #6352
Short description of the changes
Type of change
Please delete options that are not relevant.
How Has This Been Tested?