Files
buzz/test/otel-e2e/compose.otel-e2e.yml
npub1mn7jgtj4w2pd0g0zeuhxsa6jy6p0rewxz4kujt98my82ahfmp72sxjexk7 fd59e6660f test(otel): add E2E harness for relay OTEL export surfaces
Adds a one-command local E2E that proves both observability export
surfaces introduced in PR #1398:

  (a) Prometheus /metrics: buzz_ws_connections_total,
      buzz_events_received_total, buzz_auth_attempts_total present with
      non-zero values; target_info absent (suppressed via PR #1398).

  (b) OTLP traces: ws.auth and ws.event spans arrive at the collector
      carrying conn_id attribute and service.name=buzz-relay resource.

  (c) OTLP metrics: collector receives data tagged service.name=buzz-relay.

  (d) OTLP-disabled control: with OTEL_EXPORTER_OTLP_ENDPOINT unset
      /metrics still serves correctly; collector receives nothing.

Architecture: relay runs on the host (matching the existing
host.docker.internal Prometheus pattern); an otel-collector container
added via compose overlay receives OTLP on :4317. The collector image is
distroless so the output dir is bind-mounted to the host rather than read
via docker exec. The Rust assertions in buzz-test-client read the host
path directly.

New files:
- test/otel-e2e/run.sh — main driver script
- test/otel-e2e/compose.otel-e2e.yml — compose overlay
- test/otel-e2e/otelcol-config.yml — collector config
- test/otel-e2e/README.md — prerequisites and usage
- crates/buzz-test-client/tests/e2e_otel.rs — Rust assertions (all #[ignore])
- Justfile: just otel-e2e target

No changes to crates/buzz-relay/src/**.

Co-authored-by: Will Pfleger <pfleger.will@gmail.com>
Signed-off-by: Will Pfleger <pfleger.will@gmail.com>
2026-06-30 14:03:45 -04:00

52 lines
1.8 KiB
YAML

# Compose overlay — OTEL E2E harness.
#
# Adds an otel-collector to the existing dev stack (docker-compose.yml). The
# relay itself runs on the HOST (matching the existing host.docker.internal
# Prometheus pattern), so only the collector and its shared output volume are
# declared here. This keeps the relay build/start cycle fast and avoids a
# slow full-image rebuild for each test run.
#
# Usage (via `just otel-e2e` which calls run.sh, or manually):
#
# docker compose -f docker-compose.yml -f test/otel-e2e/compose.otel-e2e.yml up -d
#
# Teardown:
#
# docker compose -f docker-compose.yml -f test/otel-e2e/compose.otel-e2e.yml down -v
#
# The relay is pointed at the collector via:
# OTEL_EXPORTER_OTLP_ENDPOINT=http://localhost:4317
# (the collector's gRPC port is published to the host).
name: buzz
services:
otel-collector:
image: otel/opentelemetry-collector-contrib:0.115.1
container_name: buzz-otel-collector
command: ["--config=/etc/otelcol-config.yml"]
volumes:
- ./test/otel-e2e/otelcol-config.yml:/etc/otelcol-config.yml:ro
# Bind-mount to the host so assertions can read the file directly —
# the collector image is distroless (no shell/cat available via docker exec).
- /tmp/buzz-otel-e2e-output:/tmp/otelcol-output
ports:
# OTLP gRPC — relay (on host) dials this
- "4317:4317"
networks:
- buzz-net
healthcheck:
# Use the collector's own /metrics health endpoint (otelcol exposes it on :8888)
test: ["CMD", "/otelcol-contrib", "--version"]
interval: 5s
timeout: 3s
retries: 10
start_period: 10s
deploy:
resources:
limits:
memory: 128m
labels:
com.buzz.service: "otel-collector"
com.buzz.env: "e2e"
restart: unless-stopped