diff --git a/.changelog/5379.fixed b/.changelog/5379.fixed new file mode 100644 index 00000000000..21e0a6ddd3f --- /dev/null +++ b/.changelog/5379.fixed @@ -0,0 +1 @@ +`opentelemetry-exporter-otlp-proto-http`: fix `certificate_file=False` being ignored due to falsy check diff --git a/exporter/opentelemetry-exporter-otlp-proto-http/src/opentelemetry/exporter/otlp/proto/http/trace_exporter/__init__.py b/exporter/opentelemetry-exporter-otlp-proto-http/src/opentelemetry/exporter/otlp/proto/http/trace_exporter/__init__.py index 2be240103c0..974f34372ed 100644 --- a/exporter/opentelemetry-exporter-otlp-proto-http/src/opentelemetry/exporter/otlp/proto/http/trace_exporter/__init__.py +++ b/exporter/opentelemetry-exporter-otlp-proto-http/src/opentelemetry/exporter/otlp/proto/http/trace_exporter/__init__.py @@ -73,7 +73,7 @@ class OTLPSpanExporter(SpanExporter): def __init__( self, endpoint: str | None = None, - certificate_file: str | None = None, + certificate_file: str | bool | None = None, client_key_file: str | None = None, client_certificate_file: str | None = None, headers: dict[str, str] | None = None, @@ -90,9 +90,13 @@ def __init__( environ.get(OTEL_EXPORTER_OTLP_ENDPOINT, DEFAULT_ENDPOINT) ), ) - self._certificate_file = certificate_file or environ.get( - OTEL_EXPORTER_OTLP_TRACES_CERTIFICATE, - environ.get(OTEL_EXPORTER_OTLP_CERTIFICATE, True), + self._certificate_file = ( + certificate_file + if certificate_file is not None + else environ.get( + OTEL_EXPORTER_OTLP_TRACES_CERTIFICATE, + environ.get(OTEL_EXPORTER_OTLP_CERTIFICATE, True), + ) ) self._client_key_file = client_key_file or environ.get( OTEL_EXPORTER_OTLP_TRACES_CLIENT_KEY,