File tree Expand file tree Collapse file tree 2 files changed +7
-0
lines changed
src/opentelemetry/sdk/metrics/export Expand file tree Collapse file tree 2 files changed +7
-0
lines changed Original file line number Diff line number Diff line change @@ -44,6 +44,8 @@ def run(self):
44
44
45
45
def shutdown (self ):
46
46
self .finished .set ()
47
+ # Run one more collection pass to flush metrics batched in the meter
48
+ self .tick ()
47
49
self .exporter .shutdown ()
48
50
if self ._atexit_handler is not None :
49
51
atexit .unregister (self ._atexit_handler )
Original file line number Diff line number Diff line change @@ -597,10 +597,15 @@ def test_push_controller(self):
597
597
controller = PushController (meter , exporter , 5.0 )
598
598
meter .collect .assert_not_called ()
599
599
exporter .export .assert_not_called ()
600
+
600
601
controller .shutdown ()
601
602
self .assertTrue (controller .finished .isSet ())
602
603
exporter .shutdown .assert_any_call ()
603
604
605
+ # shutdown should flush the meter
606
+ self .assertEqual (meter .collect .call_count , 1 )
607
+ self .assertEqual (exporter .export .call_count , 1 )
608
+
604
609
def test_push_controller_suppress_instrumentation (self ):
605
610
meter = mock .Mock ()
606
611
exporter = mock .Mock ()
You can’t perform that action at this time.
0 commit comments