Skip to content

Commit c22c1e4

Browse files
committed
shut down logger
1 parent e19d0e5 commit c22c1e4

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

aws-opentelemetry-distro/tests/amazon/opentelemetry/distro/test_aws_opentelementry_configurator.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
22
# SPDX-License-Identifier: Apache-2.0
3+
import logging
34
import os
45
import time
56
from unittest import TestCase
@@ -87,6 +88,18 @@ def setUpClass(cls):
8788
def tearDown(self):
8889
os.environ.pop("OTEL_AWS_APPLICATION_SIGNALS_ENABLED", None)
8990
os.environ.pop("OTEL_AWS_APPLICATION_SIGNALS_RUNTIME_ENABLED", None)
91+
root_logger = logging.getLogger()
92+
for handler in root_logger.handlers[:]:
93+
handler.close()
94+
root_logger.removeHandler(handler)
95+
96+
# Shut down any active exporters
97+
try:
98+
from opentelemetry.sdk._logs import _internal
99+
100+
_internal.get_log_provider().shutdown()
101+
except (ImportError, AttributeError):
102+
pass
90103

91104
# The probability of this passing once without correct IDs is low, 20 times is inconceivable.
92105
def test_provide_generate_xray_ids(self):

0 commit comments

Comments
 (0)