Skip to content

Commit

Permalink
Expose metric for log export failure (open-telemetry#6709)
Browse files Browse the repository at this point in the history
  • Loading branch information
harshitrjpt committed Oct 10, 2024
1 parent b927d9d commit d00c291
Showing 1 changed file with 14 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -141,8 +141,10 @@ private static final class Worker implements Runnable {
private static final Logger logger = Logger.getLogger(Worker.class.getName());

private final LongCounter processedLogsCounter;
private final LongCounter logsExportFailureCounter;
private final Attributes droppedAttrs;
private final Attributes exportedAttrs;
private final Attributes exportFailureAttrs;

private final LogRecordExporter logRecordExporter;
private final long scheduleDelayNanos;
Expand Down Expand Up @@ -197,6 +199,13 @@ private Worker(
"The number of logs processed by the BatchLogRecordProcessor. "
+ "[dropped=true if they were dropped due to high throughput]")
.build();
logsExportFailureCounter =
meter
.counterBuilder("logsExportFailure")
.setUnit("1")
.setDescription(
"Logs export failure in BatchLogRecordProcessor.")
.build();
droppedAttrs =
Attributes.of(
LOG_RECORD_PROCESSOR_TYPE_LABEL,
Expand All @@ -209,6 +218,10 @@ private Worker(
LOG_RECORD_PROCESSOR_TYPE_VALUE,
LOG_RECORD_PROCESSOR_DROPPED_LABEL,
false);
exportFailureAttrs =
Attributes.of(
LOG_RECORD_PROCESSOR_TYPE_LABEL,
LOG_RECORD_PROCESSOR_TYPE_VALUE);

this.batch = new ArrayList<>(this.maxExportBatchSize);
}
Expand Down Expand Up @@ -324,6 +337,7 @@ private void exportCurrentBatch() {
processedLogsCounter.add(batch.size(), exportedAttrs);
} else {
logger.log(Level.FINE, "Exporter failed");
logsExportFailureCounter.add(1, exportFailureAttrs);
}
} catch (RuntimeException e) {
logger.log(Level.WARNING, "Exporter threw an Exception", e);
Expand Down

0 comments on commit d00c291

Please sign in to comment.