Skip to content

Commit fcadee2

Browse files
committed
Add test
1 parent 66fb14d commit fcadee2

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

opentelemetry-sdk/tests/test_configurator.py

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -484,6 +484,30 @@ def f():
484484
assert exporter.credentials is credential_for_traces_only
485485
assert exporter.credentials is not credential_for_all_signals
486486

487+
@patch.dict(
488+
environ,
489+
{
490+
OTEL_PYTHON_EXPORTER_OTLP_TRACES_CREDENTIAL_PROVIDER: "custom_credential"
491+
},
492+
)
493+
@patch("opentelemetry.sdk._configuration.entry_points")
494+
def test_that_invalid_credential_type_raises_exception(
495+
self, mock_entry_points
496+
):
497+
def f():
498+
# Entry point must return a grpc.ChannelCredential or requests.Session.
499+
return 32
500+
501+
mock_entry_points.configure_mock(
502+
return_value=[IterEntryPoint("custom_credential", f)]
503+
)
504+
with raises(RuntimeError):
505+
_init_exporter(
506+
"traces",
507+
{},
508+
OTLPSpanExporter,
509+
)
510+
487511
@patch.dict(
488512
"os.environ", {OTEL_TRACES_SAMPLER: "non_existent_entry_point"}
489513
)

0 commit comments

Comments
 (0)