Commit d504350
authored
Add HyperDX OTel integration test path (#110)
* Add HyperDX OTel integration test path
Wire an opt-in integration test against a live HyperDX endpoint via
the OTLP-HTTP exporter, plus a "Production swap" section in example
03's docstring showing the same setup.
The integration test (``tests/integration/test_otel_hyperdx_export.py``)
is env-gated on ``HYPERDX_API_KEY`` + ``HYPERDX_OTLP_ENDPOINT`` and
``@pytest.mark.integration``; skipped by default. Verifies that the
``BatchSpanProcessor`` + ``OTLPSpanExporter`` pipeline drains cleanly
within a 15s deadline. HyperDX-side acceptance is verified by the
UI, not the test, because the OTel SDK swallows exporter errors
silently.
``opentelemetry-exporter-otlp-proto-http`` lands in the dev dependency
group only, capped ``<3`` for parity with the ``[otel]`` extras' SDK
pins. Not promoted to a public extras group yet; revisit when more
than one downstream user wants OTLP-HTTP export packaged.
* Document HYPERDX_OTLP_ENDPOINT path requirement
The OTLPSpanExporter uses the ``endpoint`` kwarg verbatim and does
not append ``/v1/traces`` itself (that auto-append is only for the
host-only ``OTEL_EXPORTER_OTLP_ENDPOINT`` env-var convention this
test doesn't use). A host-only URL POSTs to ``/`` and HyperDX 404s,
which the OTel SDK swallows silently while ``force_flush`` still
returns True — the failure mode this test calls out.
Note the path-suffix requirement explicitly in the module docstring
and the pytestmark skip reason so future readers don't lose half an
hour to a silent failure that wasn't surfaced.
* Drain observer queue before flush; fix sync force_flush docs
Two CoPilot findings on PR #110:
1. Integration test missed ``await graph.drain()`` between
``invoke()`` and ``observer.force_flush()``. ``invoke()`` returns
when the graph reaches END, but observer events sit on a per-
invocation queue until the background worker delivers them, so a
span that hasn't seen its ``completed`` event yet is still open
when ``force_flush`` runs. The live HyperDX run worked only
because the queue drained inside the 15s flush window; under load
the test could ship only ``started`` halves.
2. Example docstring suggested ``await otel_observer.force_flush()``.
``force_flush`` is synchronous (returns bool, wraps
``TracerProvider.force_flush``); the await would raise
``TypeError`` at runtime. Replaced with the canonical
short-lived-process pattern: ``await graph.drain()`` then
``otel_observer.force_flush()`` (sync).
* 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 0661af0 commit d504350
5 files changed
Lines changed: 176 additions & 0 deletions
File tree
- examples/03-observer-hooks
- tests/integration
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
6 | 6 | | |
7 | 7 | | |
8 | 8 | | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
9 | 13 | | |
10 | 14 | | |
11 | 15 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
35 | 35 | | |
36 | 36 | | |
37 | 37 | | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
38 | 78 | | |
39 | 79 | | |
40 | 80 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
75 | 75 | | |
76 | 76 | | |
77 | 77 | | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
78 | 83 | | |
79 | 84 | | |
80 | 85 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
0 commit comments