Skip to content

test(harness): shared OTLP harness for TH-8103 contract tests - #203

Open
nik13 wants to merge 3 commits into
devfrom
feat/th-8103-harness
Open

nik13 wants to merge 3 commits into
devfrom
feat/th-8103-harness

Conversation

@nik13

@nik13 nik13 commented Oct 4, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • Adds python/tests/harness/, providing the four functions the TH-8103 architecture requires:
    • a loopback OTLP/HTTP receiver
    • a one-command runner
    • a fixture poster
    • a golden-file compare
  • The harness holds no secrets, calls no vendor and does not start fi-collector. It owns none of the children's assertions. TH-8339 and the other families use it.
  • Branched from dev (fabaf0a8). dev is behind main (54421a67). That rebase is a separate PR and is not part of this one.

Spec: https://github.com/future-agi/company-brain/pull/62 (commit b2463134).

Update at 3eaadc8: chunked bodies and request metadata

  • Defect: the Node OTLP exporter (@opentelemetry/otlp-exporter-base) sends Transfer-Encoding: chunked with no Content-Length. The receiver read zero bytes and returned 400, so TypeScript children exported nothing to the harness. _read_body now decodes both chunked and Content-Length bodies.
  • New: each export records its request path, lower-cased headers and flattened resource attributes, available through Receiver.requests(). clear() resets both stores. Children assert the collector contract against this record: /tracer/v1/traces, X-Api-Key / X-Secret-Key, project_name / project_type=observe. Per-package relays are no longer needed.
  • Tests first: test_receiver_accepts_the_collector_path and test_receiver_decodes_a_chunked_body both failed before the fix.
  • Real-exporter check: the real Node exporter delivered 4 chunked exports straight to the receiver, with no relay. All 4 had the collector path, both auth headers and both resource attributes.

Used by #209 (Claude Agent SDK TS), #210 (AG2), #211 (AG2 Classic) and #212 (TanStack AI).

Tests

cd python && PYTHONPATH=. uv run --no-project --python 3.11 --with pytest --with protobuf --with opentelemetry-proto pytest tests/harness/test_harness.py -q -p no:cacheprovider --noconftest -o addopts=''
6 passed in 2.36s

That run was against head 3eaadc8 on 2026-10-04. --noconftest is required because python/tests/conftest.py auto-imports fi_instrumentation, and the harness does not use that fixture.

Video demo

Not applicable. This PR adds a test utility with no user-visible behavior. The narrated demo belongs to the integration PRs that use the harness (#209–#212).

nik13 added 2 commits October 3, 2026 23:21
The Node OTLP exporter streams with Transfer-Encoding: chunked and sends
no Content-Length. The Receiver read Content-Length only, so every Node
export came back 400 with zero spans; two TH-8103 children had to put a
de-chunking relay in front of it. Receiver now accepts both framings.

It also records one entry per accepted export (path, lower-cased
headers, flattened resource attributes) via requests(), so a contract
test can assert X-Api-Key/X-Secret-Key and project_name through the
shared harness instead of a private recorder.

Verified: 6 harness tests pass, and the TanStack example's real Node
exporter delivered 4 chunked exports (4 spans, collector path, both
auth headers, project_name/project_type) with no relay.

Refs: TH-8339, TH-8103
This was referenced Oct 4, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant