From 12ece53bad436b5d71d2355e442b20631ebfeefc Mon Sep 17 00:00:00 2001 From: Helen <56097766+heyams@users.noreply.github.com> Date: Wed, 24 Jul 2024 08:01:46 -0700 Subject: [PATCH] Skip verbose logs when logger names start with our exporter package name (#40615) * Skip export log when logger names start with our exporter package name * Rename constant * Add a todo --- .../exporter/AzureMonitorLogRecordExporter.java | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/sdk/monitor/azure-monitor-opentelemetry-exporter/src/main/java/com/azure/monitor/opentelemetry/exporter/AzureMonitorLogRecordExporter.java b/sdk/monitor/azure-monitor-opentelemetry-exporter/src/main/java/com/azure/monitor/opentelemetry/exporter/AzureMonitorLogRecordExporter.java index 30b8360ac979e..95ee8cba955ce 100644 --- a/sdk/monitor/azure-monitor-opentelemetry-exporter/src/main/java/com/azure/monitor/opentelemetry/exporter/AzureMonitorLogRecordExporter.java +++ b/sdk/monitor/azure-monitor-opentelemetry-exporter/src/main/java/com/azure/monitor/opentelemetry/exporter/AzureMonitorLogRecordExporter.java @@ -26,6 +26,7 @@ */ class AzureMonitorLogRecordExporter implements LogRecordExporter { + private static final String EXPORTER_LOGGER_PREFIX = "com.azure.monitor.opentelemetry.exporter"; private static final ClientLogger LOGGER = new ClientLogger(AzureMonitorLogRecordExporter.class); private static final OperationLogger OPERATION_LOGGER = new OperationLogger(AzureMonitorLogRecordExporter.class, "Exporting log"); @@ -54,6 +55,10 @@ public CompletableResultCode export(Collection logs) { List telemetryItems = new ArrayList<>(); for (LogRecordData log : logs) { + // TODO (heya) consider using suppress_instrumentation https://github.com/open-telemetry/opentelemetry-java/pull/6546 later when available + if (log.getInstrumentationScopeInfo().getName().startsWith(EXPORTER_LOGGER_PREFIX)) { + continue; + } LOGGER.verbose("exporting log: {}", log); try { String stack = log.getAttributes().get(SemanticAttributes.EXCEPTION_STACKTRACE);