Skip to content

Commit eb1a4c5

Browse files
emdnetoxrmx
andauthored
otlp-http-exporter: set default value for param timeout_sec in _export method (#4691)
* default timeout_sec Signed-off-by: emdneto <[email protected]> * Update CHANGELOG.md Co-authored-by: Riccardo Magliocchetti <[email protected]> --------- Signed-off-by: emdneto <[email protected]> Co-authored-by: Riccardo Magliocchetti <[email protected]>
1 parent 23aad5e commit eb1a4c5

File tree

4 files changed

+21
-4
lines changed

4 files changed

+21
-4
lines changed

CHANGELOG.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1212
- Overwrite logging.config.fileConfig and logging.config.dictConfig to ensure
1313
the OTLP `LogHandler` remains attached to the root logger. Fix a bug that
1414
can cause a deadlock to occur over `logging._lock` in some cases ([#4636](https://github.com/open-telemetry/opentelemetry-python/pull/4636)).
15+
- otlp-http-exporter: set default value for param `timeout_sec` in `_export` method
16+
([#4691](https://github.com/open-telemetry/opentelemetry-python/pull/4691))
1517

1618
- Update OTLP gRPC/HTTP exporters: calling shutdown will now interrupt exporters that are sleeping
1719
before a retry attempt, and cause them to return failure immediately.
@@ -39,7 +41,7 @@ can cause a deadlock to occur over `logging._lock` in some cases ([#4636](https:
3941
- Update logger level to NOTSET in logs example
4042
([#4637](https://github.com/open-telemetry/opentelemetry-python/pull/4637))
4143
- Logging API accepts optional `context`; deprecates `trace_id`, `span_id`, `trace_flags`.
42-
([#4597](https://github.com/open-telemetry/opentelemetry-python/pull/4597)) and
44+
([#4597](https://github.com/open-telemetry/opentelemetry-python/pull/4597)) and
4345
([#4668](https://github.com/open-telemetry/opentelemetry-python/pull/4668))
4446
- sdk: use context instead of trace_id,span_id for initializing LogRecord
4547
([#4653](https://github.com/open-telemetry/opentelemetry-python/pull/4653))

exporter/opentelemetry-exporter-otlp-proto-http/src/opentelemetry/exporter/otlp/proto/http/_log_exporter/__init__.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,9 @@ def __init__(
126126
)
127127
self._shutdown = False
128128

129-
def _export(self, serialized_data: bytes, timeout_sec: float):
129+
def _export(
130+
self, serialized_data: bytes, timeout_sec: Optional[float] = None
131+
):
130132
data = serialized_data
131133
if self._compression == Compression.Gzip:
132134
gzip_data = BytesIO()
@@ -136,6 +138,9 @@ def _export(self, serialized_data: bytes, timeout_sec: float):
136138
elif self._compression == Compression.Deflate:
137139
data = zlib.compress(serialized_data)
138140

141+
if timeout_sec is None:
142+
timeout_sec = self._timeout
143+
139144
# By default, keep-alive is enabled in Session's request
140145
# headers. Backends may choose to close the connection
141146
# while a post happens which causes an unhandled

exporter/opentelemetry-exporter-otlp-proto-http/src/opentelemetry/exporter/otlp/proto/http/metric_exporter/__init__.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,9 @@ def __init__(
172172
)
173173
self._shutdown = False
174174

175-
def _export(self, serialized_data: bytes, timeout_sec: float):
175+
def _export(
176+
self, serialized_data: bytes, timeout_sec: Optional[float] = None
177+
):
176178
data = serialized_data
177179
if self._compression == Compression.Gzip:
178180
gzip_data = BytesIO()
@@ -182,6 +184,9 @@ def _export(self, serialized_data: bytes, timeout_sec: float):
182184
elif self._compression == Compression.Deflate:
183185
data = zlib.compress(serialized_data)
184186

187+
if timeout_sec is None:
188+
timeout_sec = self._timeout
189+
185190
# By default, keep-alive is enabled in Session's request
186191
# headers. Backends may choose to close the connection
187192
# while a post happens which causes an unhandled

exporter/opentelemetry-exporter-otlp-proto-http/src/opentelemetry/exporter/otlp/proto/http/trace_exporter/__init__.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,9 @@ def __init__(
124124
)
125125
self._shutdown = False
126126

127-
def _export(self, serialized_data: bytes, timeout_sec: float):
127+
def _export(
128+
self, serialized_data: bytes, timeout_sec: Optional[float] = None
129+
):
128130
data = serialized_data
129131
if self._compression == Compression.Gzip:
130132
gzip_data = BytesIO()
@@ -134,6 +136,9 @@ def _export(self, serialized_data: bytes, timeout_sec: float):
134136
elif self._compression == Compression.Deflate:
135137
data = zlib.compress(serialized_data)
136138

139+
if timeout_sec is None:
140+
timeout_sec = self._timeout
141+
137142
# By default, keep-alive is enabled in Session's request
138143
# headers. Backends may choose to close the connection
139144
# while a post happens which causes an unhandled

0 commit comments

Comments
 (0)