@@ -15,7 +15,6 @@ internal sealed class PeriodicExportingMetricReaderTaskWorker : PeriodicExportin
15
15
private readonly SemaphoreSlim exportTrigger = new ( 0 , 1 ) ;
16
16
private readonly TaskCompletionSource < bool > shutdownCompletionSource = new ( ) ;
17
17
private Task ? workerTask ;
18
- private volatile bool isShutdownRequested ;
19
18
private bool disposed ;
20
19
21
20
/// <summary>
@@ -69,8 +68,6 @@ public override bool TriggerExport()
69
68
/// <inheritdoc/>
70
69
public override bool Shutdown ( int timeoutMilliseconds )
71
70
{
72
- this . isShutdownRequested = true ;
73
-
74
71
try
75
72
{
76
73
this . cancellationTokenSource . Cancel ( ) ;
@@ -123,7 +120,7 @@ private async Task ExporterProcAsync()
123
120
124
121
try
125
122
{
126
- while ( ! cancellationToken . IsCancellationRequested && ! this . isShutdownRequested )
123
+ while ( ! cancellationToken . IsCancellationRequested )
127
124
{
128
125
var timeout = ( int ) ( this . exportIntervalMilliseconds - ( sw . ElapsedMilliseconds % this . exportIntervalMilliseconds ) ) ;
129
126
@@ -138,15 +135,10 @@ private async Task ExporterProcAsync()
138
135
}
139
136
catch ( OperationCanceledException )
140
137
{
141
- if ( this . isShutdownRequested )
142
- {
143
- break ;
144
- }
145
-
146
138
// Continue to check if shutdown was requested
147
139
}
148
140
149
- if ( cancellationToken . IsCancellationRequested || this . isShutdownRequested )
141
+ if ( cancellationToken . IsCancellationRequested )
150
142
{
151
143
OpenTelemetrySdkEventSource . Log . MetricReaderEvent ( "PeriodicExportingMetricReader calling MetricReader.Collect because Shutdown was triggered." ) ;
152
144
this . metricReader . Collect ( this . exportTimeoutMilliseconds ) ;
0 commit comments