Skip to content

Commit

Permalink
test: validate empty propagators for OTEL_PROPAGATORS="none"
Browse files Browse the repository at this point in the history
  • Loading branch information
Annosha committed Oct 25, 2024
1 parent 883f296 commit 5cbe62f
Showing 1 changed file with 14 additions and 7 deletions.
21 changes: 14 additions & 7 deletions opentelemetry-api/tests/propagators/test_propagators.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,14 +52,21 @@ def test_propagators(propagators):
@patch.dict(environ, {OTEL_PROPAGATORS: "none"})
@patch("opentelemetry.propagators.composite.CompositePropagator")
def test_no_propagators_loaded(self, mock_compositehttppropagator):
def test_propagators(propagators):
self.assertEqual(
propagators, []
) # Expecting an empty list of propagators
# Verify if exception is raised without the fix
with self.assertRaises(Exception):
from opentelemetry.propagate import get_global_textmap

mock_compositehttppropagator.configure_mock(
**{"side_effect": test_propagators}
)
get_global_textmap()

# Apply fix and verify propagators is empty, with no exception raised
try:
from opentelemetry.propagate import get_global_textmap

mock_compositehttppropagator.assert_called_with(
[]
) # Validate empty list of propagators
except Exception as e:
self.fail(f"Test failed unexpectedly with an exception: {e}")

@patch.dict(environ, {OTEL_PROPAGATORS: "a, b, c "})
@patch("opentelemetry.propagators.composite.CompositePropagator")
Expand Down

0 comments on commit 5cbe62f

Please sign in to comment.