Repository navigation
fix(zipkin): tolerate invalid OTEL_EXPORTER_ZIPKIN_TIMEOUT env var - #5704
RichardoMrMu wants to merge 3 commits into
Conversation
Pull request dashboard statusWaiting on maintainers · refreshed 2026-10-17 07:38 UTC Merge when ready. Status above doesn't look right?
|
There was a problem hiding this comment.
Copilot review overview
🟡 Changes recommended
Empty and whitespace-only values incorrectly emit warnings, and tests do not verify silent fallback.
Review effort: Balanced
Findings: 4
Open (4)
What changed in this PR
Adds resilient Zipkin timeout environment parsing to prevent malformed values from breaking SDK startup.
Changes:
- Falls back to the default timeout for invalid values.
- Adds warning and fallback tests.
- Adds a changelog entry.
| File | Description |
|---|---|
.changelog/5704.fixed |
Documents the fix. |
exporter/opentelemetry-exporter-zipkin-json/src/opentelemetry/exporter/zipkin/json/__init__.py |
Adds timeout fallback handling. |
exporter/opentelemetry-exporter-zipkin-json/tests/test_zipkin_exporter.py |
Tests invalid and empty values. |
exporter/opentelemetry-exporter-zipkin-proto-http/src/opentelemetry/exporter/zipkin/proto/http/__init__.py |
Adds timeout fallback handling. |
exporter/opentelemetry-exporter-zipkin-proto-http/tests/test_zipkin_exporter.py |
Tests invalid and empty values. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
035b627 to
d009679
Compare
|
Answering the inline question about the double The second read is still there because I could not remove it without breaking a check.
Behaviourally the second read is dead code rather than a second failure path: So the choice is: fold it into one line and accept the public-symbols failure plus the |
…ar (open-telemetry#5705) * fix(prometheus): tolerate invalid OTEL_EXPORTER_PROMETHEUS_PORT env var _AutoPrometheusMetricReader parsed OTEL_EXPORTER_PROMETHEUS_PORT with a bare int() in __init__, so a non-integer value (e.g. "9464abc") or an empty string raised ValueError while building the auto-configured reader and took opentelemetry-instrument/SDK startup down. This is the same class of startup crash already fixed for the OTLP exporters (HTTP _resolve_timeout in open-telemetry#5389, gRPC _timeout_from_env in open-telemetry#5448) and the Zipkin exporters (open-telemetry#5704). Add a private _port_from_env() that skips unset/empty values silently, logs a warning for non-integer values, and falls back to the 9464 default. Explicit configuration is unaffected (the reader's auto server only reads the env var). Assisted-by: Doubao * changelog: add fragment for PR open-telemetry#5705 * test(prometheus): ruff-format the new entrypoint timeout tests The `misc / precommit` job failed because the two added test signatures were split across lines while ruff (v0.16.0, line-length 120) keeps them on one line. Run `ruff format` so `pre-commit run ruff-format` is clean.
Please remove the double call and we can add a tag to skip the public API check. |
|
/dashboard route:reviewers @herin049 the double call is gone. Both exporters now read The only red on the current head ( The other 577 checks pass, so this is ready for the |
|
@RichardoMrMu, this pull request was routed to reviewers. The handoff remains active across pushes until newer actionable human feedback arrives. Top-level feedback through this request will not return; unresolved review threads remain open. |
Both Zipkin exporters parsed OTEL_EXPORTER_ZIPKIN_TIMEOUT with a bare int() in __init__, so an invalid value (e.g. "10s") raised ValueError during exporter construction and took SDK startup down, unlike the OTLP HTTP/gRPC exporters which warn and fall back to the default. Add _timeout_from_env() in each exporter that skips unset/empty values silently, logs a warning for non-integer values, and falls back to the 10 second default. Explicit timeout argument precedence is unchanged. Assisted-by: Doubao
407856f to
f7be704
Compare
| self.session.headers.update({"Content-Type": self.encoder.content_type()}) | ||
| self._closed = False | ||
| self.timeout = timeout or int(environ.get(OTEL_EXPORTER_ZIPKIN_TIMEOUT, 10)) | ||
| timeout = timeout or _timeout_from_env() |
There was a problem hiding this comment.
nit: can we move this to a single line.
There was a problem hiding this comment.
Done in 7a72e8a: simplified to a single line.
Collapse the two-line timeout resolution into a single assignment per review nit; no behavior change. Assisted-by: Doubao

Description
Both Zipkin span exporters construct their timeout with a bare
int(environ.get(OTEL_EXPORTER_ZIPKIN_TIMEOUT, 10))in__init__(opentelemetry-exporter-zipkin-jsonandopentelemetry-exporter-zipkin-proto-http). A malformed value such asOTEL_EXPORTER_ZIPKIN_TIMEOUT=10sraisesValueError: invalid literal for int()while the exporter is being built, which takes SDK/TracerProviderstartup down before any telemetry can flow.The OTLP exporters already tolerate this: the HTTP transport has
_resolve_timeout()(#5389) and the gRPC transport now has_timeout_from_env()(#5448), both of which log a warning and fall back to the default. The Zipkin exporters were the remaining outlier parsing this env var with an unguarded conversion.This change adds a private
_timeout_from_env()in each Zipkin exporter that:10seconds) silently when the variable is unset or empty/whitespace;Precedence of an explicit
timeout=constructor argument is unchanged (timeout or _timeout_from_env()).Type of change
How Has This Been Tested?
Pure-Python, no collector or network needed. Added two tests to each exporter's
test_zipkin_exporter.py:test_constructor_invalid_timeout_env_var_falls_back: setsOTEL_EXPORTER_ZIPKIN_TIMEOUT=10s, asserts the exporter builds withtimeout == 10and emits a WARNING.test_constructor_empty_timeout_env_var_falls_back: sets the variable to"", assertstimeout == 10.Red (before the fix), run per package:
Green (after the fix):
The pre-existing constructor/env/export tests in both files continue to pass, including
test_constructor_all_params_and_env_vars(explicittimeout=precedence) andtest_constructor_env_vars(valid numeric env value).Verification boundary: logic-level unit tests only (constructor configuration); no export round-trip against a live Zipkin instance was exercised, consistent with the existing tests in these modules which mock
requests.Session.post.