forked from open-telemetry/opentelemetry-python
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added a warning log when the existing TracerProvider and MeterProvide…
…r are overridden (open-telemetry#856)
- Loading branch information
Showing
5 changed files
with
50 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
# type:ignore | ||
import unittest | ||
from logging import WARNING | ||
|
||
from opentelemetry import metrics | ||
from opentelemetry.sdk.metrics import MeterProvider | ||
|
||
|
||
class TestGlobals(unittest.TestCase): | ||
def test_meter_provider_override_warning(self): | ||
"""metrics.set_meter_provider should throw a warning when overridden""" | ||
metrics.set_meter_provider(MeterProvider()) | ||
with self.assertLogs(level=WARNING) as test: | ||
metrics.set_meter_provider(MeterProvider()) | ||
self.assertEqual( | ||
test.output, | ||
[ | ||
( | ||
"WARNING:opentelemetry.metrics:Overriding current " | ||
"MeterProvider" | ||
) | ||
], | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters