# OpenTelemetry, Prometheus & Tracing

OpenTelemetry, Prometheus remote-write, Jaeger trace queries, and RUM web-vitals ingest for BugWatch.

**Scope required for all write endpoints:** `ingest:write`

**Key facts:**
- OTLP/HTTP (`/v1/logs`, `/v1/traces`, `/v1/metrics`) accept **both** `application/json` and `application/x-protobuf`. The OpenTelemetry Collector sends protobuf by default; the requests in this folder use JSON for readability.
- An **OTLP/gRPC** receiver is also available on port `4317` (logs, traces and metrics services); pass the same credential as gRPC metadata (`x-api-key` or `authorization: Bearer ...`).
- The BugWatch JS and PHP SDKs export their own spans (`withSpan`/`startSpan`) to `POST /v1/traces` natively, so you do not need an OTel SDK or collector for BugWatch tracing.
- `POST /api/v1/prom/write` accepts **Snappy-compressed Prometheus protobuf**, which is always sent by the Prometheus remote-write adapter or the `bugwatch-otel-collector`. This folder documents the endpoint but does not include a fake binary body.
- Prometheus query endpoints (`/query`, `/query_range`, `/label/__name__/values`) are fully runnable; `/query` and `/query_range` also accept **POST** with form-encoded parameters, which is what Grafana's Prometheus data source sends by default.
- Jaeger GET endpoints (`/jaeger/api/services`, `/jaeger/api/traces`, `/jaeger/api/traces/{traceId}`) are fully runnable.
- RUM (`/api/v1/rum`) accepts `x-bugwatch-session` (browser) or `x-api-key` (server).

**Auth header:** `x-api-key: {{apiKey}}` or `Authorization: Bearer {{apiKey}}`

**POST /v1/logs**: OTLP/HTTP – ingest logs (JSON) (fetch id `endpoint:6ae152d083f212a997c813a3`)

**POST /v1/traces**: OTLP/HTTP – ingest traces (JSON) (fetch id `endpoint:6ae152d083f212a997c813a4`)

**POST /v1/metrics**: OTLP/HTTP – ingest metrics (JSON) (fetch id `endpoint:6ae152d083f212a997c813a5`)

**POST /api/v1/prom/write**: Prometheus remote-write (DOCUMENTATION ONLY) (fetch id `endpoint:6ae152d083f212a997c813a6`)

**GET /api/v1/prom/query**: Prometheus query (instant) (fetch id `endpoint:6ae152d083f212a997c813a7`)

**GET /api/v1/prom/query_range**: Prometheus query_range (over time) (fetch id `endpoint:6ae152d083f212a997c813a8`)

**GET /api/v1/prom/label/__name__/values**: Prometheus label __name__ values (list metric names) (fetch id `endpoint:6ae152d083f212a997c813a9`)

**GET /jaeger/api/services**: Jaeger – list service names (fetch id `endpoint:6ae152d083f212a997c813aa`)

**GET /jaeger/api/traces**: Jaeger – list traces (fetch id `endpoint:6ae152d083f212a997c813ab`)

**GET /jaeger/api/traces/{traceId}**: Jaeger – get one trace (fetch id `endpoint:6ae152d083f212a997c813ac`)

**POST /api/v1/rum**: RUM – ingest web-vitals (fetch id `endpoint:6ae152d083f212a997c813ad`)
