Skip to content

Commit 4f35f83

Browse files
Enforce HYPERDX_OTLP_ENDPOINT path at runtime
The documented requirement (env var MUST include ``/v1/traces``) was only enforced through docs, not the test itself. Because the OTel SDK swallows exporter-side errors and ``force_flush`` returns True regardless of the HTTP response, a host-only URL would POST to ``/``, HyperDX would 404, and the test would still report green. This is the silent-failure mode the test's docstring already warned about and the one we hit on this PR's manual validation. Assert the endpoint ends with ``/v1/traces`` before constructing the exporter; the assert raises with a pointer to the expected shape if the env var is misconfigured.
1 parent d4e3113 commit 4f35f83

1 file changed

Lines changed: 13 additions & 1 deletion

File tree

tests/integration/test_otel_hyperdx_export.py

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,12 +60,24 @@ async def test_otel_observer_pipeline_drains_with_hyperdx_exporter() -> None:
6060
from openarmature.graph import END, GraphBuilder, State
6161
from openarmature.observability.otel import OTelObserver
6262

63+
# Enforce the documented endpoint shape at runtime. The
64+
# ``OTLPSpanExporter`` uses the URL verbatim and does not append
65+
# ``/v1/traces`` itself, so a host-only URL POSTs to ``/`` and
66+
# HyperDX 404s; the SDK swallows that response and ``force_flush``
67+
# still returns True, which would mask a misconfigured env var
68+
# behind a passing test.
69+
endpoint = os.environ["HYPERDX_OTLP_ENDPOINT"]
70+
assert endpoint.endswith("/v1/traces"), (
71+
f"HYPERDX_OTLP_ENDPOINT must end with /v1/traces (got {endpoint!r}); "
72+
"OTLPSpanExporter uses the URL verbatim and does not append paths."
73+
)
74+
6375
# HyperDX accepts the API key as a bare ``authorization`` header
6476
# value (no ``Bearer`` prefix). Other OTLP collectors that expect
6577
# ``Bearer <token>`` will need the caller to format the header
6678
# themselves; this is the documented HyperDX shape.
6779
exporter = OTLPSpanExporter(
68-
endpoint=os.environ["HYPERDX_OTLP_ENDPOINT"],
80+
endpoint=endpoint,
6981
headers={"authorization": os.environ["HYPERDX_API_KEY"]},
7082
)
7183

0 commit comments

Comments
 (0)