diff --git a/examples/Console/TestJaegerExporter.cs b/examples/Console/TestJaegerExporter.cs index dc8aad47ee2..660723eb1b5 100644 --- a/examples/Console/TestJaegerExporter.cs +++ b/examples/Console/TestJaegerExporter.cs @@ -87,8 +87,8 @@ internal static object RunWithActivity(string host, int port) { sample.Start(); - System.Console.WriteLine("Traces are being created and exported" + - "to Jaeger in the background. Use Jaeger to view them." + + System.Console.WriteLine("Traces are being created and exported " + + "to Jaeger in the background. Use Jaeger to view them. " + "Press ENTER to stop."); System.Console.ReadLine(); } diff --git a/examples/Console/TestOtlpExporter.cs b/examples/Console/TestOtlpExporter.cs index 8fcf9c39782..7002f2a69b6 100644 --- a/examples/Console/TestOtlpExporter.cs +++ b/examples/Console/TestOtlpExporter.cs @@ -73,7 +73,7 @@ private static object RunWithActivitySource(string endpoint) { sample.Start(); - System.Console.WriteLine("Traces are being created and exported" + + System.Console.WriteLine("Traces are being created and exported " + "to the OpenTelemetry Collector in the background. " + "Press ENTER to stop."); System.Console.ReadLine(); diff --git a/examples/Console/TestZipkinExporter.cs b/examples/Console/TestZipkinExporter.cs index 0d5ac8bb5f6..5c750f63aa2 100644 --- a/examples/Console/TestZipkinExporter.cs +++ b/examples/Console/TestZipkinExporter.cs @@ -50,7 +50,7 @@ internal static object Run(string zipkinUri) { sample.Start(); - System.Console.WriteLine("Traces are being created and exported" + + System.Console.WriteLine("Traces are being created and exported " + "to Zipkin in the background. Use Zipkin to view them. " + "Press ENTER to stop."); System.Console.ReadLine(); diff --git a/src/OpenTelemetry/BatchExportProcessor.cs b/src/OpenTelemetry/BatchExportProcessor.cs index 94a529352ad..21e3f1a5bfe 100644 --- a/src/OpenTelemetry/BatchExportProcessor.cs +++ b/src/OpenTelemetry/BatchExportProcessor.cs @@ -186,6 +186,8 @@ protected override bool OnShutdown(int timeoutMilliseconds) this.shutdownDrainTarget = this.circularBuffer.AddedCount; this.shutdownTrigger.Set(); + OpenTelemetrySdkEventSource.Log.DroppedExportProcessorItems(this.GetType().Name, this.exporter.GetType().Name, this.droppedCount); + if (timeoutMilliseconds == Timeout.Infinite) { this.exporterThread.Join(); diff --git a/src/OpenTelemetry/CHANGELOG.md b/src/OpenTelemetry/CHANGELOG.md index 0dd390ad1bd..613a4fa91dd 100644 --- a/src/OpenTelemetry/CHANGELOG.md +++ b/src/OpenTelemetry/CHANGELOG.md @@ -2,6 +2,8 @@ ## Unreleased +* `BatchExportProcessor.OnShutdown` will now log the count of dropped telemetry items. + ([#2331](https://github.com/open-telemetry/opentelemetry-dotnet/pull/2331)) * Changed `CompositeProcessor.OnForceFlush` to meet with the spec requirement. Now the SDK will invoke `ForceFlush` on all registered processors, even if there is a timeout. diff --git a/src/OpenTelemetry/Internal/OpenTelemetrySdkEventSource.cs b/src/OpenTelemetry/Internal/OpenTelemetrySdkEventSource.cs index 7e13a8f6041..19778a7f790 100644 --- a/src/OpenTelemetry/Internal/OpenTelemetrySdkEventSource.cs +++ b/src/OpenTelemetry/Internal/OpenTelemetrySdkEventSource.cs @@ -135,6 +135,25 @@ public void MissingPermissionsToReadEnvironmentVariable(SecurityException ex) } } + [NonEvent] + public void DroppedExportProcessorItems(string exportProcessorName, string exporterName, long droppedCount) + { + if (droppedCount > 0) + { + if (this.IsEnabled(EventLevel.Warning, EventKeywords.All)) + { + this.ExistsDroppedExportProcessorItems(exportProcessorName, exporterName, droppedCount); + } + } + else + { + if (this.IsEnabled(EventLevel.Informational, EventKeywords.All)) + { + this.NoDroppedExportProcessorItems(exportProcessorName, exporterName); + } + } + } + [Event(1, Message = "Span processor queue size reached maximum. Throttling spans.", Level = EventLevel.Warning)] public void SpanProcessorQueueIsExhausted() { @@ -309,6 +328,18 @@ public void MissingPermissionsToReadEnvironmentVariable(string exception) this.WriteEvent(30, exception); } + [Event(31, Message = "'{0}' exporting to '{1}' dropped '0' items.", Level = EventLevel.Informational)] + public void NoDroppedExportProcessorItems(string exportProcessorName, string exporterName) + { + this.WriteEvent(31, exportProcessorName, exporterName); + } + + [Event(32, Message = "'{0}' exporting to '{1}' dropped '{2}' item(s) due to buffer full.", Level = EventLevel.Warning)] + public void ExistsDroppedExportProcessorItems(string exportProcessorName, string exporterName, long droppedCount) + { + this.WriteEvent(32, exportProcessorName, exporterName, droppedCount); + } + #if DEBUG public class OpenTelemetryEventListener : EventListener {