Skip to content
InfraChallenge Docs
Esc
↑↓navigate↵open⌘Jpreview
On this page

Overview

One telemetry path from the server to any back end, and the design targets it serves.

The server speaks one protocol, OTLP. An OpenTelemetry Collector decides where the data goes. Locally that is Prometheus, Jaeger and Grafana. In AWS it is CloudWatch (metrics through the Embedded Metric Format) and X-Ray, with the collector as a sidecar in the ECS task. Logs do not go through the collector: they are JSON lines on stdout, which the awslogs driver ships to CloudWatch Logs.

The telemetry path

Design targets

Design target Mechanism Where
Catch a failure before users report it One burn-rate alert on the failure ratio of AI suggestion requests. In AWS the same metric drives a CloudWatch alarm that also rolls back a release. observability/prometheus/rules.yml, infrastructure/modules/service/alarms.tf
See how the service performs and how it is used Request rate by outcome, p50 and p95 duration, requests in flight, open WebSocket connections, on one dashboard. These are counts and timings, not product analytics. server/app/telemetry.py, observability/grafana/dashboards/suggestions.json
Telemetry that is safe to keep Audit events for document reads and saves. Telemetry never carries document text, and a test enforces it. The collector’s AWS permissions only write telemetry. server/app/telemetry.py, server/tests/test_telemetry.py, infrastructure/modules/service/iam.tf
Find the cause of one failed request fast One trace per suggestion request, with the OpenAI call as a child span. Every log line carries the trace ID. server/app/telemetry.py
Response times for every route The duration histogram, plus HTTP server spans and metrics from the FastAPI instrumentation. server/app/telemetry.py
Silent failures become visible The WebSocket handler used to print the error and carry on: no 5xx, a passing health check, nothing to see. Every suggestion request now ends in exactly one outcome. server/app/__main__.py
A record of who read or saved a document audit.document.read and audit.document.saved. The AWS account trail (CloudTrail and the rest) is not built. See Logging and audit trail. server/app/telemetry.py
Logs and traces that join up Traces and logs joined by trace_id; failures carry the exception type. server/app/telemetry.py

Why OpenTelemetry

The same server image runs on a laptop, in AWS, and could run in a customer’s environment with a different back end. Only the collector config changes:

Config Back end Status
observability/collector/local.yaml Prometheus and Jaeger Run and proven locally
observability/collector/aws.yaml CloudWatch (EMF) and X-Ray The production default. Validated in CI, not run in AWS
observability/collector/datadog.yaml Datadog An option. Validated in CI, not deployed

Hands-on experience behind this design is with Prometheus, Grafana and the OpenTelemetry Collector. The CloudWatch and X-Ray side follows the AWS and exporter documentation and has not been run against an account.

Run it locally

The telemetry services are in observability/docker-compose.yml, which the root docker-compose.yml includes under the Compose profile observability. Two variables switch them on:

COMPOSE_PROFILES=observability \
OTEL_EXPORTER_OTLP_ENDPOINT=http://otel-collector:4318 \
docker compose up --build

Without them, docker compose up --build runs only the app, and the server exports nothing.

What URL
Grafana dashboard http://localhost:3001/d/patent-suggestions
Prometheus alerts http://localhost:9090/alerts
Jaeger http://localhost:16686
Collector (OTLP/HTTP) http://localhost:4318

Was this page helpful?