Skip to content

Commit 706ce5b

Browse files
committed
chore: Remove isShutdownRequested
It's a duplicate of cancellationToken.IsCancellationRequested
1 parent 526657e commit 706ce5b

File tree

1 file changed

+2
-10
lines changed

1 file changed

+2
-10
lines changed

src/OpenTelemetry/Internal/PeriodicExportingMetricReaderTaskWorker.cs

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ internal sealed class PeriodicExportingMetricReaderTaskWorker : PeriodicExportin
1515
private readonly SemaphoreSlim exportTrigger = new(0, 1);
1616
private readonly TaskCompletionSource<bool> shutdownCompletionSource = new();
1717
private Task? workerTask;
18-
private volatile bool isShutdownRequested;
1918
private bool disposed;
2019

2120
/// <summary>
@@ -69,8 +68,6 @@ public override bool TriggerExport()
6968
/// <inheritdoc/>
7069
public override bool Shutdown(int timeoutMilliseconds)
7170
{
72-
this.isShutdownRequested = true;
73-
7471
try
7572
{
7673
this.cancellationTokenSource.Cancel();
@@ -123,7 +120,7 @@ private async Task ExporterProcAsync()
123120

124121
try
125122
{
126-
while (!cancellationToken.IsCancellationRequested && !this.isShutdownRequested)
123+
while (!cancellationToken.IsCancellationRequested)
127124
{
128125
var timeout = (int)(this.exportIntervalMilliseconds - (sw.ElapsedMilliseconds % this.exportIntervalMilliseconds));
129126

@@ -138,15 +135,10 @@ private async Task ExporterProcAsync()
138135
}
139136
catch (OperationCanceledException)
140137
{
141-
if (this.isShutdownRequested)
142-
{
143-
break;
144-
}
145-
146138
// Continue to check if shutdown was requested
147139
}
148140

149-
if (cancellationToken.IsCancellationRequested || this.isShutdownRequested)
141+
if (cancellationToken.IsCancellationRequested)
150142
{
151143
OpenTelemetrySdkEventSource.Log.MetricReaderEvent("PeriodicExportingMetricReader calling MetricReader.Collect because Shutdown was triggered.");
152144
this.metricReader.Collect(this.exportTimeoutMilliseconds);

0 commit comments

Comments
 (0)