-
Notifications
You must be signed in to change notification settings - Fork 1k
Record processed logs before export complete and reject on shutdown #8698
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鈥檒l occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -85,28 +85,29 @@ public static SimpleLogRecordProcessorBuilder builder(LogRecordExporter exporter | |
|
|
||
| @Override | ||
| public void onEmit(Context context, ReadWriteLogRecord logRecord) { | ||
| if (isShutdown.get()) { | ||
| logProcessorInstrumentation.dropLogsAlreadyShutdown(1); | ||
| return; | ||
| } | ||
|
|
||
| try { | ||
| List<LogRecordData> logs = Collections.singletonList(logRecord.toLogRecordData()); | ||
| CompletableResultCode result; | ||
|
|
||
| synchronized (exporterLock) { | ||
| // We always increment for every export invocation, so we increment before the export call | ||
| // to make sure thrown errors don't affect it. | ||
| logProcessorInstrumentation.finishLogs(1); | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. |
||
| result = logRecordExporter.export(logs); | ||
| } | ||
|
|
||
| pendingExports.add(result); | ||
| result.whenComplete( | ||
| () -> { | ||
| pendingExports.remove(result); | ||
| String error = null; | ||
| if (!result.isSuccess()) { | ||
| logger.log(Level.FINE, "Exporter failed"); | ||
| if (result.getFailureThrowable() != null) { | ||
| error = result.getFailureThrowable().getClass().getName(); | ||
| } else { | ||
| error = "export_failed"; | ||
| } | ||
| } | ||
| logProcessorInstrumentation.finishLogs(1, error); | ||
| }); | ||
| } catch (RuntimeException e) { | ||
| logger.log(Level.WARNING, "Exporter threw an Exception", e); | ||
|
|
||
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.
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()?