# OpenTelemetry and metrics

## OpenTelemetry traces

Every finished tool call becomes a span, and every MCP session is one trace.

**Cloud:** on **Settings → OpenTelemetry**, enter your collector's OTLP/HTTP endpoint and, if it needs one, an API key header (for example `x-honeycomb-team`, `DD-API-KEY` or `Authorization`). Spans are sent to `<endpoint>/v1/traces` as OTLP JSON every few seconds. **Send a test span** checks the setup.

**Self-hosted:** set the standard variables:

```bash
export OTEL_EXPORTER_OTLP_ENDPOINT=https://otlp.example.com
export OTEL_EXPORTER_OTLP_HEADERS="x-api-key=…"
export OTEL_SERVICE_NAME=godelgate
```

Span attributes:

| Attribute | Value |
| --- | --- |
| `gen_ai.tool.name`, `mcp.server.name`, `mcp.tool.name` | The tool |
| `mcp.session.id`, `enduser.id` | Session and person |
| `godelgate.decision`, `godelgate.status`, `godelgate.reason` | What Godelgate decided and why |
| `godelgate.labels`, `godelgate.approved_by`, `godelgate.duration_ms` | Labels, approver, upstream time |

Calls that were denied, rejected or failed have an error status.

## Prometheus

`GET /metrics` with the admin token (`Authorization: Bearer <token>`) returns:

- `godelgate_tool_calls_total{workspace,server,decision,status}`
- `godelgate_tool_call_duration_ms` (histogram)
- `godelgate_sessions_active`, `godelgate_approvals_pending`, `godelgate_tools`, `godelgate_tools_quarantined`, `godelgate_workspaces_loaded`
