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 lock and update changelog #9

Merged
merged 1 commit into from
Aug 31, 2022
Merged
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
remove lock and update changelog
jackyshang12321 committed Aug 31, 2022
commit 407b85ae8147fc305d7a70529a018e101d1aef57
6 changes: 3 additions & 3 deletions src/OpenTelemetry.Exporter.Console/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -2,9 +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 dropped and nothing will be output.
* Changed error handling, `ConsoleExporter` will output error messages,
tell user where dispose happened and drop the data
if `Export` is invoked after the exporter is disposed.
([#1848](https://github.com/open-telemetry/opentelemetry-dotnet/issues/1848))

## 1.4.0-alpha.2
31 changes: 9 additions & 22 deletions src/OpenTelemetry.Exporter.Console/ConsoleLogRecordExporter.cs
Original file line number Diff line number Diff line change
@@ -24,10 +24,9 @@ namespace OpenTelemetry.Exporter
public class ConsoleLogRecordExporter : ConsoleExporter<LogRecord>
{
private const int RightPaddingLength = 35;
private readonly object disposeLockObj = new();
private bool disposed = false;
private bool disposed;
private string disposedStackTrace;
private bool isDisposeMessageSent = false;
private bool isDisposeMessageSent;

public ConsoleLogRecordExporter(ConsoleExporterOptions options)
: base(options)
@@ -40,17 +39,11 @@ public override ExportResult Export(in Batch<LogRecord> batch)
{
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);
}
}
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 + "Dispose was called on the following stack trace:");
this.WriteLine(this.disposedStackTrace);
}

return ExportResult.Failure;
@@ -159,14 +152,8 @@ protected override void Dispose(bool disposing)
{
if (!this.disposed)
{
lock (this.disposeLockObj)
{
if (!this.disposed)
{
this.disposed = true;
this.disposedStackTrace = Environment.StackTrace;
}
}
this.disposed = true;
this.disposedStackTrace = Environment.StackTrace;
}

base.Dispose(disposing);