headroom/docs/content/docs
Tejas Chopra 6b63b623e0
docs(metrics): document OTLP metric export and Dynatrace ingest (#2785)
## Description

The proxy can already push its counters to any OTLP/HTTP endpoint via
`HEADROOM_OTEL_METRICS_*`, but the docs site only surfaced this as a
single row in the proxy env table (`proxy.mdx:287`). The endpoint,
header, service-name, and resource-attribute variables were documented
only in `wiki/metrics.md` — so an operator reading the Vercel docs had
no way to wire Headroom into their existing observability stack.

This adds that section, plus a Dynatrace subsection, because Dynatrace
has a silent failure mode that costs an afternoon to diagnose.

Closes #

## Type of Change

- [ ] Bug fix (non-breaking change that fixes an issue)
- [ ] New feature (non-breaking change that adds functionality)
- [ ] Breaking change (fix or feature that would cause existing
functionality to change)
- [x] Documentation update
- [ ] Performance improvement
- [ ] Code refactoring (no functional changes)

## Changes Made

- `docs/content/docs/metrics.mdx` — new `### OpenTelemetry (OTLP)
Export` section after the Prometheus section: the
`headroom-ai[proxy,otel]` install, all seven `HEADROOM_OTEL_*` variables
in a table, the exported counter names (`headroom.proxy.tokens.saved` et
al.), the `curl /stats | jq .otel` verification, and the note that an
app-managed global meter provider is recorded into automatically.
- `docs/content/docs/metrics.mdx` — new `### Dynatrace` subsection:
copy-paste env block, `metrics.ingest` token scope, a `warn` Callout on
the delta-temporality requirement, the ActiveGate URL variant, the
Collector + `cumulativetodelta` alternative, and one paragraph
explaining that trace export needs `opentelemetry-instrument`
(Headroom's self-configured tracing targets Langfuse only).
- `docs/content/docs/proxy.mdx` — the `HEADROOM_OTEL_METRICS_ENABLED`
row now links to `/docs/metrics#opentelemetry-otlp-export`.

No code, config, or nav changes — the Observability nav slot already
points at `metrics.mdx`.

## Testing

- [ ] Unit tests pass (`pytest`)
- [ ] Linting passes (`ruff check .`)
- [ ] Type checking passes (`mypy headroom`)
- [ ] New tests added for new functionality
- [x] Manual testing performed

Docs-only change: no Python touched, so pytest/ruff/mypy have nothing to
cover here. `next build` was **not** run — `docs/node_modules` is absent
in this checkout, which would require a full `npm install`; Vercel's
preview build is the real gate. In its place I verified the MDX cannot
break the build by parsing for the two things that actually fail MDX v3
— unbalanced JSX and bare `<`/`{` in prose.

### Test Output

```text
$ python - <<'PY'   # strip fenced + inline code, then scan prose for MDX hazards
...
PY
hazards: [(80, '<Tabs groupId="lang" items={[\'TypeScript\', \'Python\']}>'),
          (125, '<Tabs groupId="lang" items={[\'Python\', \'Proxy\']}>')]
Callout balance: 1 open / 1 close
```

Both flagged lines are pre-existing `<Tabs>` JSX expressions, untouched
by this PR. The added prose introduces no bare `<` or `{` (every
`<env-id>` / `<activegate>` placeholder sits inside a code fence or
inline backticks). `type="warn"` is already used on three other pages,
and the anchor `#opentelemetry-otlp-export` matches the GitHub-slugger
form of the new heading.

## Real Behavior Proof

- **Environment:** macOS (darwin 25.4.0), repo `.venv`,
`opentelemetry-sdk` 1.44.0, `opentelemetry-exporter-otlp-proto-http`,
headroom @ 6422a80a.
- **Exact command / steps:** verified the central claim of the new
Callout — that the OTLP HTTP exporter defaults to cumulative (which
Dynatrace rejects) and that the standard env var flips it to delta with
no Headroom code change:

```text
$ python -c '...'
DELTA= 1 CUMULATIVE= 2
default counter: 2

$ OTEL_EXPORTER_OTLP_METRICS_TEMPORALITY_PREFERENCE=DELTA python -c '...'
counter temporality with env=DELTA: 1
```

- **Observed result:**
`OTLPMetricExporter._preferred_temporality[Counter]` is `CUMULATIVE` (2)
by default and `DELTA` (1) with the env var set. Since every Headroom
OTEL instrument is a `Counter`
(`headroom/observability/metrics.py:136-189`), without the env var
Dynatrace drops all of them — matching its documented
`UNSUPPORTED_METRIC_TYPE_MONOTONIC_CUMULATIVE_SUM` rejection. Also
confirmed against the code that `HEADROOM_OTEL_METRICS_ENDPOINT` is
passed verbatim to the exporter (`metrics.py:539-543`), hence the doc's
warning that `/v1/metrics` must be included by hand, and that
`HEADROOM_OTEL_METRICS_HEADERS` splits on the first `=` so
`Authorization=Api-Token dt0c01...` parses correctly.
- **Not tested:** no live export against a real Dynatrace tenant — the
URL shapes and token scopes come from Dynatrace's docs, not from an
observed 200. The `opentelemetry-instrument` trace path is described
from the code's global-provider fallback (`tracing.py:95-99`), not run
end-to-end. `next build` not run (see Testing).

## Review Readiness

- [x] I have performed a self-review
- [x] This PR is ready for human review

## Checklist

- [x] My code follows the project's style guidelines
- [x] I have performed a self-review of my code
- [x] I have commented my code, particularly in hard-to-understand areas
- [x] I have made corresponding changes to the documentation
- [x] My changes generate no new warnings
- [ ] I have added tests that prove my fix is effective or that my
feature works
- [ ] New and existing unit tests pass locally with my changes
- [x] I did **not** edit `CHANGELOG.md` — it is generated by
release-please from my Conventional Commit PR title (a CI guard enforces
this)

## Additional Notes

- N/A on the pytest / ruff / mypy / new-tests items: this PR changes two
`.mdx` files and no Python.
- Follow-up worth considering: `wiki/metrics.md:244` carries the same
OTEL variable table and still lacks the Dynatrace guidance — happy to
mirror it there, kept out of this PR to hold the diff to the Vercel docs
as asked.
- Second follow-up: the delta-temporality fix currently depends on an
upstream OTEL SDK env var that Headroom neither sets nor documents in
code. A `HEADROOM_OTEL_METRICS_TEMPORALITY=delta` passthrough would make
the Dynatrace case self-contained instead of relying on a variable one
layer down.
2026-08-04 18:46:39 -07:00
..
agent-orchestration.mdx docs(orchestration): guide repeated agent wakes with CCR (#1871) 2026-07-08 08:37:24 -05:00
agno.mdx new docs UI + ts doc coverage 2026-04-12 13:15:58 +06:00
anthropic-sdk.mdx fix(compress): resolve the /v1/compress tokenizer per model, and document the real contract (#2743) 2026-08-03 12:20:33 -07:00
api-reference.mdx docs: sync README + benchmarks with code (drop retired IntelligentContext/RollingWindow) (#1545) 2026-06-28 22:36:41 -07:00
architecture.mdx docs: sync Vercel docs with current code and add in-depth proxy config (#2475) 2026-07-21 16:26:56 -07:00
autogen.mdx feat: add CrewAI and AutoGen tool compression integrations (#1384) 2026-07-15 19:58:54 +00:00
benchmarks.mdx docs: sync Vercel docs with current code and add in-depth proxy config (#2475) 2026-07-21 16:26:56 -07:00
cache-optimization.mdx docs(configuration): document cold-prefix hook flags + bound the TTL observation log (#2557) 2026-07-25 11:07:57 -07:00
ccr.mdx docs: qualify CCR auto-resolution support for Gemini (#2044) 2026-07-14 11:59:08 -04:00
ci-cd-flows.mdx docs(ci): add CI/CD flow diagrams (#1062) 2026-06-16 23:05:15 -07:00
claude-code-azure-foundry.mdx fix(cli): harden all CLI surfaces + fix docs accuracy (#1491) 2026-06-27 14:48:43 -07:00
claude-code-vertex.mdx docs: use headroom-ai package name in install commands (#1014) (#1257) 2026-06-22 19:25:00 -05:00
code-compression.mdx feat(code): add PHP support to CodeAwareCompressor (#2423) 2026-07-31 15:54:13 -07:00
codex-recovery.mdx fix(codex): preserve wrapped sessions and recover state (#2160) 2026-07-15 19:58:21 +00:00
configuration.mdx chore(docs): one documentation site, not two (#2784) 2026-08-04 16:42:49 -07:00
context-management.mdx docs: sync README + benchmarks with code (drop retired IntelligentContext/RollingWindow) (#1545) 2026-06-28 22:36:41 -07:00
crewai.mdx feat: add CrewAI and AutoGen tool compression integrations (#1384) 2026-07-15 19:58:54 +00:00
docker-install.mdx fix: remove rtk and lean-ctx CLI context tools (#2677) 2026-07-30 22:59:41 -07:00
errors.mdx new docs UI + ts doc coverage 2026-04-12 13:15:58 +06:00
failure-learning.mdx feat: add first-class OpenCode support (wrap, learn, mcp install) (#559) 2026-06-25 13:38:58 -05:00
filesystem-contract.mdx fix: remove rtk and lean-ctx CLI context tools (#2677) 2026-07-30 22:59:41 -07:00
grok-build.mdx fix: remove rtk and lean-ctx CLI context tools (#2677) 2026-07-30 22:59:41 -07:00
how-compression-works.mdx docs: sync Vercel docs with current code and add in-depth proxy config (#2475) 2026-07-21 16:26:56 -07:00
image-compression.mdx fix: align docs and prune dead compatibility surfaces 2026-05-09 14:07:59 -07:00
index.mdx fix(compress): resolve the /v1/compress tokenizer per model, and document the real contract (#2743) 2026-08-03 12:20:33 -07:00
installation.mdx docs: sync Vercel docs with current code and add in-depth proxy config (#2475) 2026-07-21 16:26:56 -07:00
langchain.mdx new docs UI + ts doc coverage 2026-04-12 13:15:58 +06:00
limitations.mdx docs: sync README + benchmarks with code (drop retired IntelligentContext/RollingWindow) (#1545) 2026-06-28 22:36:41 -07:00
litellm.mdx fix(compress): resolve the /v1/compress tokenizer per model, and document the real contract (#2743) 2026-08-03 12:20:33 -07:00
local-llm-prefill.mdx [codex] Document local LLM prefill benchmarking (#1396) 2026-07-09 21:47:59 -05:00
mcp.mdx feat(mcp): add streamable HTTP MCP transport (#1773) 2026-07-14 13:25:45 -04:00
memory.mdx docs: sync Vercel docs with current code and add in-depth proxy config (#2475) 2026-07-21 16:26:56 -07:00
meta.json feat(claude): support Claude Code in VS Code (#2752) 2026-08-03 20:14:13 -07:00
metrics.mdx docs(metrics): document OTLP metric export and Dynatrace ingest (#2785) 2026-08-04 18:46:39 -07:00
openai-sdk.mdx fix(compress): resolve the /v1/compress tokenizer per model, and document the real contract (#2743) 2026-08-03 12:20:33 -07:00
opencode.mdx fix: remove rtk and lean-ctx CLI context tools (#2677) 2026-07-30 22:59:41 -07:00
persistent-installs.mdx feat(deploy): Add turnkey deploy command (#1404) 2026-07-15 18:37:20 +00:00
pipeline-extensions.mdx docs: add pipeline-extension recipe and x-headroom-base-url routing docs (#1712) 2026-07-07 12:45:16 -05:00
proxy.mdx docs(metrics): document OTLP metric export and Dynatrace ingest (#2785) 2026-08-04 18:46:39 -07:00
quickstart.mdx feat(claude): support Claude Code in VS Code (#2752) 2026-08-03 20:14:13 -07:00
releases.mdx docs(ci): add CI/CD flow diagrams (#1062) 2026-06-16 23:05:15 -07:00
savings.mdx feat(savings): durable savings ledger + headroom savings command (#1127) 2026-06-22 18:47:57 -05:00
shared-context.mdx fix(cli): harden all CLI surfaces + fix docs accuracy (#1491) 2026-06-27 14:48:43 -07:00
simulation.mdx fix(cli): harden all CLI surfaces + fix docs accuracy (#1491) 2026-06-27 14:48:43 -07:00
smart-crusher.mdx docs: fix stale API references, retired class imports, and incorrect examples 2026-06-02 19:19:19 -04:00
strands.mdx docs: sync README + benchmarks with code (drop retired IntelligentContext/RollingWindow) (#1545) 2026-06-28 22:36:41 -07:00
text-and-logs.mdx docs: sync Vercel docs with current code and add in-depth proxy config (#2475) 2026-07-21 16:26:56 -07:00
troubleshooting.mdx docs: add troubleshooting entry for uv build cache errors (#2490) 2026-07-22 06:06:51 -07:00
vercel-ai-sdk.mdx new docs UI + ts doc coverage 2026-04-12 13:15:58 +06:00
vscode-claude-code.mdx feat(claude): support Claude Code in VS Code (#2752) 2026-08-03 20:14:13 -07:00
vscode-copilot.mdx feat(copilot): proxy VS Code models transparently (#2687) 2026-08-03 04:42:48 -07:00