Skip to content
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’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Log dropped telemetry item count on shutdown #2331

Merged
merged 17 commits into from
Sep 21, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions examples/Console/TestJaegerExporter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
Expand Down
2 changes: 1 addition & 1 deletion examples/Console/TestOtlpExporter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
2 changes: 1 addition & 1 deletion examples/Console/TestZipkinExporter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
2 changes: 2 additions & 0 deletions src/OpenTelemetry/BatchExportProcessor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
2 changes: 2 additions & 0 deletions src/OpenTelemetry/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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<T>.OnForceFlush` to meet with the spec
requirement. Now the SDK will invoke `ForceFlush` on all registered
processors, even if there is a timeout.
Expand Down
31 changes: 31 additions & 0 deletions src/OpenTelemetry/Internal/OpenTelemetrySdkEventSource.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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()
{
Expand Down Expand Up @@ -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
{
Expand Down