Skip to content

Record processed logs before export complete and reject on shutdown - #8698

Open
anuraaga wants to merge 3 commits into
open-telemetry:mainfrom
anuraaga:log-processor-beforeexport
Open

Record processed logs before export complete and reject on shutdown#8698
anuraaga wants to merge 3 commits into
open-telemetry:mainfrom
anuraaga:log-processor-beforeexport

Conversation

@anuraaga

@anuraaga anuraaga commented Aug 6, 2026

Copy link
Copy Markdown
Contributor

#8680

I will apply the same to spans after this one to confirm the pattern

On top of changing the order of recording, this implements handling of shutdown processor to emit already_shutdown and reject the log (a non-metric behavior change). For what it's worth, the behavior would have been less confusing if that error.type was there at the time 😂

@anuraaga
anuraaga requested a review from a team as a code owner August 6, 2026 03:05
@opentelemetry-pr-dashboard

opentelemetry-pr-dashboard Bot commented Aug 6, 2026

Copy link
Copy Markdown

Pull request dashboard status

Waiting on the author · refreshed 2026-08-07 03:06 UTC

Respond to 2 review items (e.g. link a commit, explain why not, ask a follow-up):

  • Inline threads: 1, 2
Status above doesn't look right?
  • Just replied or pushed? Anything around or after the refresh time above may not be picked up yet — give it a few minutes.
  • Should this be with reviewers? Comment /dashboard route:reviewers to route it to them.
  • Anything wrong — including the routing? Report it with what you expected; it helps us improve the dashboard.

CompletableResultCode result;

synchronized (exporterLock) {
logProcessorInstrumentation.finishLogs(1);

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I put it before the export call to match what languages with synchronous export like Go and Python must be doing

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Calling it before does also mitigate against the risk of export throwing synchronously.

Probably worth a comment since the placement seems unintuitive at first glance.

"simple_log_processor")))));

// Logs rejected after to call to shutdown, regardless of completion so no join.
processor.shutdown();

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Interestingly, provider.shutdown() causes loggers to reject immediately it seems, I guess the processor's handling will be for that small race within emitLog itself (emitLog started, logger and processor disabled from other thread, emitLog finishes)

@codecov

codecov Bot commented Aug 6, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 95.65217% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 91.66%. Comparing base (48b0185) to head (85a7b3f).
⚠️ Report is 2 commits behind head on main.

Files with missing lines Patch % Lines
...xport/LegacyLogRecordProcessorInstrumentation.java 50.00% 1 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##               main    #8698      +/-   ##
============================================
+ Coverage     91.62%   91.66%   +0.03%     
- Complexity    10328    10349      +21     
============================================
  Files          1003     1003              
  Lines         27140    27205      +65     
  Branches       3188     3198      +10     
============================================
+ Hits          24868    24937      +69     
+ Misses         1566     1564       -2     
+ Partials        706      704       -2     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

private final AtomicInteger logsNeeded = new AtomicInteger(Integer.MAX_VALUE);
private final BlockingQueue<Boolean> signal;
private final AtomicReference<CompletableResultCode> flushRequested = new AtomicReference<>();
private final AtomicBoolean isShutdown = new AtomicBoolean(false);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The BatchLogRecordProcessor also has an isShutdown field. Since we need it down in the Worker for instrumentation, can we get rid of it in the parent and just delegate BatchLogRecordProcessor#shutdown to Worker#shutdown()?

CompletableResultCode result;

synchronized (exporterLock) {
logProcessorInstrumentation.finishLogs(1);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Calling it before does also mitigate against the risk of export throwing synchronously.

Probably worth a comment since the placement seems unintuitive at first glance.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants