Skip to content

Make OpenTelemetry export honor the protocol, correlate logs and traces, and tag chain spans. - #229

Merged
howethomas merged 6 commits into
mainfrom
o6-otel-fixes
Nov 23, 2026
Merged

howethomas merged 6 commits into
mainfrom
o6-otel-fixes

Conversation

@howethomas

Copy link
Copy Markdown
Contributor

Makes turning on OTEL_EXPORTER_OTLP_ENDPOINT safe and useful. Nothing changes while the endpoint is empty.

  • Metrics honor OTEL_EXPORTER_OTLP_PROTOCOL (grpc or http/protobuf, per-signal overrides too). Unset stays gRPC. Per-process service.instance.id, the own-provider meter binding, the atexit flush and the per-vCon key filter are kept.
  • The worker's own spans (vcon_processing.*, link.*, storage.*) export through a tracer provider built once per pid, like the meter provider, so forked workers get their own.
  • Dockerfile, Dockerfile.api and Dockerfile.conserver no longer run opentelemetry-bootstrap ... || true. Redis, httpx, requests, logging and FastAPI instrumentations are pinned in pyproject.toml (uv.lock updated), so a missing one fails the build.
  • The API honors an incoming traceparent through the FastAPI instrumentation. A test covers it.
  • JSON logs gain trace_id and span_id inside a span, through the OpenTelemetry logging instrumentation. Existing fields are unchanged.
  • The chain span gets tenant.id (from the tenant attachment) and call.session_id (from the telnyx_call_session_id tag) as span attributes only. A test checks they are absent from metrics.
  • LLM content capture stays off: if the optional openinference package is installed, inputs, outputs, messages and embeddings are hidden. No vCon body, dialog, transcript or prompt is added to spans or logs.
  • docs/operations/monitoring.md, logging.md, .env.example and the generated environment reference are updated.

Tests: new tests for metrics over http/protobuf (a real local OTLP/HTTP endpoint), protocol selection, per-pid tracer provider, traceparent, trace ids in a JSON record, and the span attributes. With Redis running, 740 passed, 17 skipped, 2 failed and 4 collection errors. The failures and errors are environmental on this host (audioop missing on Python 3.13, milvus and openai_transcribe dependencies not installed) and do not touch this change. Docker images were not built here.

🤖 Generated with Claude Code

howethomas and others added 3 commits November 22, 2026 16:59
Metrics now honor OTEL_EXPORTER_OTLP_PROTOCOL (grpc or http/protobuf), and
the worker's own spans export through a tracer provider built per process.
The images install the Redis, httpx, requests, logging and FastAPI
instrumentations as pinned dependencies instead of a bootstrap step that
could fail silently. JSON logs gain trace_id and span_id inside a span. The
chain span gains tenant.id and call.session_id as span attributes only.
OpenAI LLM instrumentation, when installed, hides prompt and reply content.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Chain span attributes now come from the vCon the link step already loads,
only when an export endpoint is set, so there is no extra Redis or storage
read. A worker flushes its tracer and meter providers when it returns,
including after an error, since a forked worker never runs atexit. The
tracer pid marker is set after the build under a lock, log trace ids appear
only with an endpoint set, and the multi-worker parent no longer builds a
provider its children would carry idle.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…he generated environment page.

Forking the pytest process after other tests load gRPC crashed the child
with SIGSEGV on macOS. The driver now forks from a clean process.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
howethomas and others added 3 commits November 22, 2026 17:54
With the collector down, the SDK defaults held a worker's exit for up to a
minute. Exporters get a 2 s timeout, and the tracer and meter shutdowns
each run on a daemon thread with a 3 s and 2 s budget. The tracer provider
no longer uses the SDK's own atexit hook, which could block for 30 s.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@howethomas
howethomas merged commit d60f0ab into main Nov 23, 2026
3 checks passed
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