Skip to content

Commit

Permalink
Merge pull request #8 from fidelity/Fix-Issue-1848
Browse files Browse the repository at this point in the history
remove the SendDisposedMessage method
  • Loading branch information
jackyshang12321 authored Aug 31, 2022
2 parents 3690c47 + 0b7aea7 commit 41ce82d
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 21 deletions.
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);
}
}
}
}
}
}

0 comments on commit 41ce82d

Please sign in to comment.