@@ -146,6 +146,10 @@ public async Task SEAStatement_QueryEmitsTelemetry()
146146 statement . Dispose ( ) ;
147147 }
148148
149+ // Dispose connection to trigger telemetry flush
150+ connection . Dispose ( ) ;
151+ connection = null ;
152+
149153 // Wait for telemetry to be emitted
150154 var logs = await TelemetryTestHelpers . WaitForTelemetryEvents ( exporter , expectedCount : 1 ) ;
151155
@@ -191,6 +195,13 @@ public async Task SEAStatement_OperationTypeIsExecuteStatementAsync()
191195 statement . Dispose ( ) ;
192196 }
193197
198+ // Dispose connection to trigger telemetry flush
199+ connection . Dispose ( ) ;
200+ connection = null ;
201+
202+ // Small delay to ensure async flush completes
203+ await Task . Delay ( 500 ) ;
204+
194205 // Wait for telemetry to be emitted
195206 var logs = await TelemetryTestHelpers . WaitForTelemetryEvents ( exporter , expectedCount : 1 ) ;
196207
@@ -235,6 +246,13 @@ public async Task SEAStatement_ExecutionResultMatchesDisposition()
235246 statement . Dispose ( ) ;
236247 }
237248
249+ // Dispose connection to trigger telemetry flush
250+ connection . Dispose ( ) ;
251+ connection = null ;
252+
253+ // Small delay to ensure async flush completes
254+ await Task . Delay ( 500 ) ;
255+
238256 // Wait for telemetry to be emitted
239257 var logs = await TelemetryTestHelpers . WaitForTelemetryEvents ( exporter , expectedCount : 1 ) ;
240258
@@ -294,6 +312,13 @@ public async Task SEAStatement_ErrorInfoForFailedQueries()
294312 statement . Dispose ( ) ;
295313 }
296314
315+ // Dispose connection to trigger telemetry flush
316+ connection . Dispose ( ) ;
317+ connection = null ;
318+
319+ // Small delay to ensure async flush completes
320+ await Task . Delay ( 500 ) ;
321+
297322 // Wait for telemetry to be emitted
298323 var logs = await TelemetryTestHelpers . WaitForTelemetryEvents ( exporter , expectedCount : 1 ) ;
299324
@@ -338,6 +363,13 @@ public async Task SEAStatement_OperationLatencyIsPositive()
338363 statement . Dispose ( ) ;
339364 }
340365
366+ // Dispose connection to trigger telemetry flush
367+ connection . Dispose ( ) ;
368+ connection = null ;
369+
370+ // Small delay to ensure async flush completes
371+ await Task . Delay ( 500 ) ;
372+
341373 // Wait for telemetry to be emitted
342374 var logs = await TelemetryTestHelpers . WaitForTelemetryEvents ( exporter , expectedCount : 1 ) ;
343375
@@ -386,6 +418,10 @@ public async Task SEAStatement_AllExitCriteriaMet()
386418 statement . Dispose ( ) ;
387419 }
388420
421+ // Dispose connection to trigger telemetry flush before checking first query
422+ connection . Dispose ( ) ;
423+ connection = null ;
424+
389425 // Wait for telemetry to be emitted
390426 var logs = await TelemetryTestHelpers . WaitForTelemetryEvents ( exporter , expectedCount : 1 ) ;
391427
@@ -413,8 +449,9 @@ public async Task SEAStatement_AllExitCriteriaMet()
413449 OutputHelper ? . WriteLine ( $ "✓ Exit criterion 5: operation_latency_ms = { protoLog . OperationLatencyMs } ms") ;
414450
415451 // Exit criterion 4: Error telemetry works for SEA failures
416- // Reset exporter for error test
452+ // Reset exporter for error test and create new connection
417453 exporter . Reset ( ) ;
454+ ( connection , exporter ) = CreateRestConnectionWithCapturingTelemetry ( ) ;
418455
419456 using ( var statement = connection . CreateStatement ( ) )
420457 {
@@ -434,6 +471,10 @@ public async Task SEAStatement_AllExitCriteriaMet()
434471 statement . Dispose ( ) ;
435472 }
436473
474+ // Dispose connection to trigger telemetry flush
475+ connection . Dispose ( ) ;
476+ connection = null ;
477+
437478 // Wait for telemetry
438479 var errorLogs = await TelemetryTestHelpers . WaitForTelemetryEvents ( exporter , expectedCount : 1 ) ;
439480 Assert . NotEmpty ( errorLogs ) ;
0 commit comments