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

remove the SendDisposedMessage method #8

Merged
merged 1 commit into from
Aug 31, 2022
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
5 changes: 3 additions & 2 deletions src/OpenTelemetry.Exporter.Console/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@

## Unreleased

* Changed error handling, `ConsoleExporter` will only output an error message with two call stacks the first time,
then the data will simply be deleted and nothing will be output.
* Changed error handling, `ConsoleExporter` will only output an error message
with two call stacks the first time,
then the data will simply be dropped and nothing will be output.
([#1848](https://github.com/open-telemetry/opentelemetry-dotnet/issues/1848))

## 1.4.0-alpha.2
Expand Down
34 changes: 15 additions & 19 deletions src/OpenTelemetry.Exporter.Console/ConsoleLogRecordExporter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,21 @@ public override ExportResult Export(in Batch<LogRecord> batch)
{
if (this.disposed)
{
this.SendDisposedMessage();
if (!this.isDisposeMessageSent)
{
lock (this.disposeLockObj)
{
if (!this.isDisposeMessageSent)
{
this.isDisposeMessageSent = true;
this.WriteLine("The console exporter is still being invoked after it has been disposed. This could be the result of invalid lifecycle management of the OpenTelemetry .NET SDK.");
this.WriteLine(Environment.StackTrace);
this.WriteLine(Environment.NewLine + "The console exporter has been disposed");
this.WriteLine(this.disposedStackTrace);
}
}
}

return ExportResult.Failure;
}

Expand Down Expand Up @@ -157,23 +171,5 @@ protected override void Dispose(bool disposing)

base.Dispose(disposing);
}

private void SendDisposedMessage()
{
if (!this.isDisposeMessageSent)
{
lock (this.disposeLockObj)
{
if (!this.isDisposeMessageSent)
{
this.isDisposeMessageSent = true;
this.WriteLine("The console exporter is still being invoked after it has been disposed. This could be the result of invalid lifecycle management of the OpenTelemetry .NET SDK.");
this.WriteLine(Environment.StackTrace);
this.WriteLine(Environment.NewLine + "The console exporter has been disposed");
this.WriteLine(this.disposedStackTrace);
}
}
}
}
}
}