From 6a23c40dbc3d16d41dd88aacdd31e84a4fe1b9ae Mon Sep 17 00:00:00 2001 From: emdneto <9735060+emdneto@users.noreply.github.com> Date: Thu, 17 Jul 2025 23:27:10 -0300 Subject: [PATCH 1/2] default timeout_sec Signed-off-by: emdneto <9735060+emdneto@users.noreply.github.com> --- CHANGELOG.md | 4 +++- .../exporter/otlp/proto/http/_log_exporter/__init__.py | 7 ++++++- .../exporter/otlp/proto/http/metric_exporter/__init__.py | 7 ++++++- .../exporter/otlp/proto/http/trace_exporter/__init__.py | 7 ++++++- 4 files changed, 21 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 81e52e6d409..08dc5e6a1ed 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Overwrite logging.config.fileConfig and logging.config.dictConfig to ensure the OTLP `LogHandler` remains attached to the root logger. Fix a bug that can cause a deadlock to occur over `logging._lock` in some cases ([#4636](https://github.com/open-telemetry/opentelemetry-python/pull/4636)). +- otlp-http-exporter: set default value for param `timeout_sec` in `_export` method + ([#4690](https://github.com/open-telemetry/opentelemetry-python/pull/4690)) ## Version 1.35.0/0.56b0 (2025-07-11) @@ -31,7 +33,7 @@ can cause a deadlock to occur over `logging._lock` in some cases ([#4636](https: - Update logger level to NOTSET in logs example ([#4637](https://github.com/open-telemetry/opentelemetry-python/pull/4637)) - Logging API accepts optional `context`; deprecates `trace_id`, `span_id`, `trace_flags`. - ([#4597](https://github.com/open-telemetry/opentelemetry-python/pull/4597)) and + ([#4597](https://github.com/open-telemetry/opentelemetry-python/pull/4597)) and ([#4668](https://github.com/open-telemetry/opentelemetry-python/pull/4668)) - sdk: use context instead of trace_id,span_id for initializing LogRecord ([#4653](https://github.com/open-telemetry/opentelemetry-python/pull/4653)) diff --git a/exporter/opentelemetry-exporter-otlp-proto-http/src/opentelemetry/exporter/otlp/proto/http/_log_exporter/__init__.py b/exporter/opentelemetry-exporter-otlp-proto-http/src/opentelemetry/exporter/otlp/proto/http/_log_exporter/__init__.py index c64f269b9ed..2f3f5b5275d 100644 --- a/exporter/opentelemetry-exporter-otlp-proto-http/src/opentelemetry/exporter/otlp/proto/http/_log_exporter/__init__.py +++ b/exporter/opentelemetry-exporter-otlp-proto-http/src/opentelemetry/exporter/otlp/proto/http/_log_exporter/__init__.py @@ -124,7 +124,9 @@ def __init__( ) self._shutdown = False - def _export(self, serialized_data: bytes, timeout_sec: float): + def _export( + self, serialized_data: bytes, timeout_sec: Optional[float] = None + ): data = serialized_data if self._compression == Compression.Gzip: gzip_data = BytesIO() @@ -134,6 +136,9 @@ def _export(self, serialized_data: bytes, timeout_sec: float): elif self._compression == Compression.Deflate: data = zlib.compress(serialized_data) + if timeout_sec is None: + timeout_sec = self._timeout + # By default, keep-alive is enabled in Session's request # headers. Backends may choose to close the connection # while a post happens which causes an unhandled diff --git a/exporter/opentelemetry-exporter-otlp-proto-http/src/opentelemetry/exporter/otlp/proto/http/metric_exporter/__init__.py b/exporter/opentelemetry-exporter-otlp-proto-http/src/opentelemetry/exporter/otlp/proto/http/metric_exporter/__init__.py index 7ee0aa79132..a9d259e32a9 100644 --- a/exporter/opentelemetry-exporter-otlp-proto-http/src/opentelemetry/exporter/otlp/proto/http/metric_exporter/__init__.py +++ b/exporter/opentelemetry-exporter-otlp-proto-http/src/opentelemetry/exporter/otlp/proto/http/metric_exporter/__init__.py @@ -170,7 +170,9 @@ def __init__( ) self._shutdown = False - def _export(self, serialized_data: bytes, timeout_sec: float): + def _export( + self, serialized_data: bytes, timeout_sec: Optional[float] = None + ): data = serialized_data if self._compression == Compression.Gzip: gzip_data = BytesIO() @@ -180,6 +182,9 @@ def _export(self, serialized_data: bytes, timeout_sec: float): elif self._compression == Compression.Deflate: data = zlib.compress(serialized_data) + if timeout_sec is None: + timeout_sec = self._timeout + # By default, keep-alive is enabled in Session's request # headers. Backends may choose to close the connection # while a post happens which causes an unhandled 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 9f9baf31150..4d360be3de4 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 @@ -122,7 +122,9 @@ def __init__( ) self._shutdown = False - def _export(self, serialized_data: bytes, timeout_sec: float): + def _export( + self, serialized_data: bytes, timeout_sec: Optional[float] = None + ): data = serialized_data if self._compression == Compression.Gzip: gzip_data = BytesIO() @@ -132,6 +134,9 @@ def _export(self, serialized_data: bytes, timeout_sec: float): elif self._compression == Compression.Deflate: data = zlib.compress(serialized_data) + if timeout_sec is None: + timeout_sec = self._timeout + # By default, keep-alive is enabled in Session's request # headers. Backends may choose to close the connection # while a post happens which causes an unhandled From 5b7690ba0b887bdc88ca73979f84783cb01dbc43 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Em=C3=ADdio=20Neto?= <9735060+emdneto@users.noreply.github.com> Date: Mon, 28 Jul 2025 12:25:15 -0300 Subject: [PATCH 2/2] Update CHANGELOG.md Co-authored-by: Riccardo Magliocchetti --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 08dc5e6a1ed..f8e003cd354 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,7 +11,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 the OTLP `LogHandler` remains attached to the root logger. Fix a bug that can cause a deadlock to occur over `logging._lock` in some cases ([#4636](https://github.com/open-telemetry/opentelemetry-python/pull/4636)). - otlp-http-exporter: set default value for param `timeout_sec` in `_export` method - ([#4690](https://github.com/open-telemetry/opentelemetry-python/pull/4690)) + ([#4691](https://github.com/open-telemetry/opentelemetry-python/pull/4691)) ## Version 1.35.0/0.56b0 (2025-07-11)