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 2 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: 1 addition & 1 deletion src/OpenTelemetry/BatchExportProcessor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ protected override bool OnShutdown(int timeoutMilliseconds)
this.shutdownDrainTarget = this.circularBuffer.AddedCount;
this.shutdownTrigger.Set();

OpenTelemetrySdkEventSource.Log.DroppedExportProcessorItems(this.droppedCount);
OpenTelemetrySdkEventSource.Log.DroppedExportProcessorItems(this.droppedCount, this.GetType());
mic-max marked this conversation as resolved.
Show resolved Hide resolved

if (timeoutMilliseconds == Timeout.Infinite)
{
Expand Down
28 changes: 25 additions & 3 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, Type type)
{
if (this.IsEnabled(EventLevel.Informational, EventKeywords.All) && droppedCount <= 0)
mic-max marked this conversation as resolved.
Show resolved Hide resolved
{
this.ZeroDroppedExportProcessorItems();
return;
}

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

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

[Event(31, Message = "Telemetry items dropped since the start due to a full buffer: '{0}'.", Level = EventLevel.Informational)]
public void DroppedExportProcessorItems(long droppedCount)
[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(31, droppedCount);
this.WriteEvent(32, droppedCount, type);
}

#if DEBUG
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,9 @@ public void OtlpExporterOptions_SetterOverridesEnvironmentVariable()
Environment.SetEnvironmentVariable(OtlpExporterOptions.HeadersEnvVarName, "A=2,B=3");
Environment.SetEnvironmentVariable(OtlpExporterOptions.TimeoutEnvVarName, "2000");

// If your application is targeting .NET Core 3.1, and you are using an insecure (HTTP) endpoint, the following switch must be set before adding OtlpExporter.
mic-max marked this conversation as resolved.
Show resolved Hide resolved
// AppContext.SetSwitch("System.Net.Http.SocketsHttpHandler.Http2UnencryptedSupport", true);

var options = new OtlpExporterOptions
{
Endpoint = new Uri("http://localhost:200"),
Expand Down