Skip to content
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
11 changes: 4 additions & 7 deletions src/OpenTelemetry/Logs/LoggerProviderSdk.cs
Original file line number Diff line number Diff line change
Expand Up @@ -217,16 +217,13 @@ protected override void Dispose(bool disposing)
{
if (disposing)
{
if (this.instrumentations != null)
foreach (var item in this.instrumentations)
{
foreach (var item in this.instrumentations)
{
(item as IDisposable)?.Dispose();
}

this.instrumentations.Clear();
(item as IDisposable)?.Dispose();
}

this.instrumentations.Clear();

// Wait for up to 5 seconds grace period
this.Processor?.Shutdown(5000);
this.Processor?.Dispose();
Expand Down
11 changes: 4 additions & 7 deletions src/OpenTelemetry/Metrics/MeterProviderSdk.cs
Original file line number Diff line number Diff line change
Expand Up @@ -451,16 +451,13 @@ protected override void Dispose(bool disposing)
{
if (disposing)
{
if (this.instrumentations != null)
foreach (var item in this.instrumentations)
{
foreach (var item in this.instrumentations)
{
(item as IDisposable)?.Dispose();
}

this.instrumentations.Clear();
(item as IDisposable)?.Dispose();
}

this.instrumentations.Clear();

// Wait for up to 5 seconds grace period
this.reader?.Shutdown(5000);
this.reader?.Dispose();
Expand Down
25 changes: 9 additions & 16 deletions src/OpenTelemetry/Trace/TracerProviderSdk.cs
Original file line number Diff line number Diff line change
Expand Up @@ -352,18 +352,14 @@ internal bool OnForceFlush(int timeoutMilliseconds)
internal bool OnShutdown(int timeoutMilliseconds)
{
// TO DO Put OnShutdown logic in a task to run within the user provider timeOutMilliseconds
bool? result;
if (this.instrumentations != null)
foreach (var item in this.instrumentations)
{
foreach (var item in this.instrumentations)
{
(item as IDisposable)?.Dispose();
}

this.instrumentations.Clear();
(item as IDisposable)?.Dispose();
}

result = this.processor?.Shutdown(timeoutMilliseconds);
this.instrumentations.Clear();

bool? result = this.processor?.Shutdown(timeoutMilliseconds);
this.listener?.Dispose();
return result ?? true;
}
Expand All @@ -374,16 +370,13 @@ protected override void Dispose(bool disposing)
{
if (disposing)
{
if (this.instrumentations != null)
foreach (var item in this.instrumentations)
{
foreach (var item in this.instrumentations)
{
(item as IDisposable)?.Dispose();
}

this.instrumentations.Clear();
(item as IDisposable)?.Dispose();
}

this.instrumentations.Clear();

(this.sampler as IDisposable)?.Dispose();

// Wait for up to 5 seconds grace period
Expand Down
Loading