You've already forked opentelemetry-go
							
							
				mirror of
				https://github.com/open-telemetry/opentelemetry-go.git
				synced 2025-10-31 00:07:40 +02:00 
			
		
		
		
	Fix flaky test TestBufferExporter/Shutdown/ContextCancelled (#5261)
This commit is contained in:
		| @@ -378,6 +378,13 @@ func TestBufferExporter(t *testing.T) { | ||||
| 		}) | ||||
|  | ||||
| 		t.Run("ContextCancelled", func(t *testing.T) { | ||||
| 			// Discard error logs. | ||||
| 			defer func(orig otel.ErrorHandler) { | ||||
| 				otel.SetErrorHandler(orig) | ||||
| 			}(otel.GetErrorHandler()) | ||||
| 			handler := otel.ErrorHandlerFunc(func(err error) {}) | ||||
| 			otel.SetErrorHandler(handler) | ||||
|  | ||||
| 			exp := newTestExporter(assert.AnError) | ||||
| 			t.Cleanup(exp.Stop) | ||||
|  | ||||
| @@ -386,6 +393,9 @@ func TestBufferExporter(t *testing.T) { | ||||
| 			t.Cleanup(func() { close(trigger) }) | ||||
| 			e := newBufferExporter(exp, 1) | ||||
|  | ||||
| 			// Make sure there is something to flush. | ||||
| 			require.True(t, e.EnqueueExport(make([]Record, 1))) | ||||
|  | ||||
| 			ctx, cancel := context.WithCancel(context.Background()) | ||||
| 			cancel() | ||||
|  | ||||
|   | ||||
		Reference in New Issue
	
	Block a user