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

Fix: Logs could be exported via ConsoleExporter after LoggerFactory is disposed #1848 #3578

Merged
merged 23 commits into from
Sep 2, 2022
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
51bc047
Fix Issue 1848
jackyshang12321 Aug 15, 2022
5b6cc57
Merge pull request #3 from fidelity/Fix-Issue-1848
jackyshang12321 Aug 15, 2022
d44c7a8
add the new function to publicAPI doc
jackyshang12321 Aug 15, 2022
2157ebb
Merge pull request #4 from fidelity/Fix-Issue-1848
jackyshang12321 Aug 15, 2022
699472c
rather than stop exporting data, added a special message telling user…
jackyshang12321 Aug 15, 2022
72a9f5c
Merge pull request #5 from fidelity/Fix-Issue-1848
jackyshang12321 Aug 15, 2022
14e2ff8
Merge branch 'open-telemetry:main' into main
brianwarner Aug 25, 2022
a0e25ba
1. Record the callstack when the ConsoleExporter is disposed.
jackyshang12321 Aug 29, 2022
f2c5b49
Merge pull request #6 from fidelity/Fix-Issue-1848
jackyshang12321 Aug 29, 2022
d455131
Double-checking locking
jackyshang12321 Aug 30, 2022
5b3e2bf
update changelog
jackyshang12321 Aug 30, 2022
3690c47
Merge pull request #7 from fidelity/Fix-Issue-1848
jackyshang12321 Aug 30, 2022
0b7aea7
remove the SendDisposedMessage method
jackyshang12321 Aug 31, 2022
41ce82d
Merge pull request #8 from fidelity/Fix-Issue-1848
jackyshang12321 Aug 31, 2022
407b85a
remove lock and update changelog
jackyshang12321 Aug 31, 2022
505921d
Merge pull request #9 from fidelity/Fix-Issue-1848
jackyshang12321 Aug 31, 2022
eb4c64e
fix code bugs and update changelog
jackyshang12321 Sep 1, 2022
2033c64
Merge pull request #10 from fidelity/Fix-Issue-1848
jackyshang12321 Sep 1, 2022
1d17a21
Update src/OpenTelemetry.Exporter.Console/CHANGELOG.md
jackyshang12321 Sep 1, 2022
96f94e8
Merge branch 'open-telemetry:main' into main
jackyshang12321 Sep 2, 2022
8a1038f
Merge branch 'main' into main
jackyshang12321 Sep 2, 2022
eaadf27
Merge branch 'main' into main
jackyshang12321 Sep 2, 2022
915bce2
make it more clear who is at fault
jackyshang12321 Sep 2, 2022
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
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
override OpenTelemetry.Exporter.ConsoleLogRecordExporter.Dispose(bool disposing) -> void
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
override OpenTelemetry.Exporter.ConsoleLogRecordExporter.Dispose(bool disposing) -> void
14 changes: 14 additions & 0 deletions src/OpenTelemetry.Exporter.Console/ConsoleLogRecordExporter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ namespace OpenTelemetry.Exporter
public class ConsoleLogRecordExporter : ConsoleExporter<LogRecord>
{
private const int RightPaddingLength = 35;
private bool disposed = false;

public ConsoleLogRecordExporter(ConsoleExporterOptions options)
: base(options)
Expand All @@ -33,6 +34,11 @@ public override ExportResult Export(in Batch<LogRecord> batch)
{
foreach (var logRecord in batch)
{
if (this.disposed)
{
this.WriteLine("Something is wrong: the ConsoleLogger has been disposed.");
}

this.WriteLine($"{"LogRecord.Timestamp:",-RightPaddingLength}{logRecord.Timestamp:yyyy-MM-ddTHH:mm:ss.fffffffZ}");

if (logRecord.TraceId != default)
Expand Down Expand Up @@ -129,5 +135,13 @@ void ProcessScope(LogRecordScope scope, ConsoleLogRecordExporter exporter)

return ExportResult.Success;
}

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