Skip to content

Commit

Permalink
Merge pull request #3 from fidelity/Fix-Issue-1848
Browse files Browse the repository at this point in the history
Fix Issue 1848
  • Loading branch information
jackyshang12321 authored Aug 15, 2022
2 parents d1da1d6 + 51bc047 commit 5b6cc57
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions src/OpenTelemetry.Exporter.Console/ConsoleExporter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ public abstract class ConsoleExporter<T> : BaseExporter<T>
where T : class
{
private readonly ConsoleExporterOptions options;
private bool disposed = false;

protected ConsoleExporter(ConsoleExporterOptions options)
{
Expand All @@ -28,6 +29,11 @@ protected ConsoleExporter(ConsoleExporterOptions options)

protected void WriteLine(string message)
{
if (this.disposed)
{
return;
}

if (this.options.Targets.HasFlag(ConsoleExporterOutputTargets.Console))
{
System.Console.WriteLine(message);
Expand All @@ -38,5 +44,13 @@ protected void WriteLine(string message)
System.Diagnostics.Trace.WriteLine(message);
}
}

protected override void Dispose(bool disposing)
{
if (disposing)
{
this.disposed = true;
}
}
}
}

0 comments on commit 5b6cc57

Please sign in to comment.