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 9 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
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.droppedCount, this);

if (timeoutMilliseconds == Timeout.Infinite)
{
this.exporterThread.Join();
Expand Down
3 changes: 3 additions & 0 deletions src/OpenTelemetry/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@

## Unreleased

* `BatchExportProcessor.OnShutdown` will now log the count of dropped telemetry items.
([#2331](https://github.com/open-telemetry/opentelemetry-dotnet/pull/2331))

## 1.2.0-alpha3

Released 2021-Sep-13
Expand Down
28 changes: 28 additions & 0 deletions src/OpenTelemetry/Internal/OpenTelemetrySdkEventSource.cs
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,22 @@ public void MissingPermissionsToReadEnvironmentVariable(SecurityException ex)
}
}

[NonEvent]
public void DroppedExportProcessorItems(long droppedCount, object exporter)
{
if (droppedCount <= 0 && this.IsEnabled(EventLevel.Informational, EventKeywords.All))
{
this.ZeroDroppedExportProcessorItems();
return;
}

// Positive number of dropped items
if (this.IsEnabled(EventLevel.Warning, EventKeywords.All))
{
this.ExistsDroppedExportProcessorItems(droppedCount, exporter.GetType());
}
}

[Event(1, Message = "Span processor queue size reached maximum. Throttling spans.", Level = EventLevel.Warning)]
public void SpanProcessorQueueIsExhausted()
{
Expand Down Expand Up @@ -309,6 +325,18 @@ public void MissingPermissionsToReadEnvironmentVariable(string exception)
this.WriteEvent(30, exception);
}

[Event(31, Message = "Zero telemetry items were dropped.", Level = EventLevel.Informational)]
public void ZeroDroppedExportProcessorItems()
{
this.WriteEvent(31);
}

[Event(32, Message = "Telemetry items dropped: '{0}', type: '{1}'.", Level = EventLevel.Warning)]
public void ExistsDroppedExportProcessorItems(long droppedCount, Type type)
{
this.WriteEvent(32, droppedCount, type.ToString());
}

#if DEBUG
public class OpenTelemetryEventListener : EventListener
{
Expand Down