Skip to content

Commit d00c291

Browse files
committed
Expose metric for log export failure (#6709)
1 parent b927d9d commit d00c291

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

sdk/logs/src/main/java/io/opentelemetry/sdk/logs/export/BatchLogRecordProcessor.java

+14
Original file line numberDiff line numberDiff line change
@@ -141,8 +141,10 @@ private static final class Worker implements Runnable {
141141
private static final Logger logger = Logger.getLogger(Worker.class.getName());
142142

143143
private final LongCounter processedLogsCounter;
144+
private final LongCounter logsExportFailureCounter;
144145
private final Attributes droppedAttrs;
145146
private final Attributes exportedAttrs;
147+
private final Attributes exportFailureAttrs;
146148

147149
private final LogRecordExporter logRecordExporter;
148150
private final long scheduleDelayNanos;
@@ -197,6 +199,13 @@ private Worker(
197199
"The number of logs processed by the BatchLogRecordProcessor. "
198200
+ "[dropped=true if they were dropped due to high throughput]")
199201
.build();
202+
logsExportFailureCounter =
203+
meter
204+
.counterBuilder("logsExportFailure")
205+
.setUnit("1")
206+
.setDescription(
207+
"Logs export failure in BatchLogRecordProcessor.")
208+
.build();
200209
droppedAttrs =
201210
Attributes.of(
202211
LOG_RECORD_PROCESSOR_TYPE_LABEL,
@@ -209,6 +218,10 @@ private Worker(
209218
LOG_RECORD_PROCESSOR_TYPE_VALUE,
210219
LOG_RECORD_PROCESSOR_DROPPED_LABEL,
211220
false);
221+
exportFailureAttrs =
222+
Attributes.of(
223+
LOG_RECORD_PROCESSOR_TYPE_LABEL,
224+
LOG_RECORD_PROCESSOR_TYPE_VALUE);
212225

213226
this.batch = new ArrayList<>(this.maxExportBatchSize);
214227
}
@@ -324,6 +337,7 @@ private void exportCurrentBatch() {
324337
processedLogsCounter.add(batch.size(), exportedAttrs);
325338
} else {
326339
logger.log(Level.FINE, "Exporter failed");
340+
logsExportFailureCounter.add(1, exportFailureAttrs);
327341
}
328342
} catch (RuntimeException e) {
329343
logger.log(Level.WARNING, "Exporter threw an Exception", e);

0 commit comments

Comments
 (0)