# Code Deb Observability

Project-scoped application request metrics. API keys with `telemetry:write` ingest bounded data; the Code Deb account workspace reads actual server-side observations. No fake traffic or performance score is created.

## Capture measurements

Record a real request duration after your application has produced a status code:

```bash
curl -X POST https://api.codedeb.com/api/developer/v1/telemetry \
 -H "Authorization: Bearer $CODEDEB_API_KEY" \
 -H "Content-Type: application/json" \
 -d '{"route":"/api/orders","statusCode":200,"durationMs":84,"traceId":"00000000000000000000000000000001"}'
```

Status codes must be 100–599, durations 0–120,000 ms, and optional trace IDs exactly 32 hexadecimal characters. URL query strings are discarded; numeric IDs and UUID-like path segments are normalized. **Do not attach request bodies, email addresses, tokens or raw URL queries to telemetry events.**

## 24-hour dashboard

The project dashboard reports:

- Number of API-key quota claims recorded in minute buckets.
- Number of received request samples.
- Count of samples with 5xx status codes.
- Latency p50/p95/p99 based on available sample durations, with unknown values displayed as unknown.
- A bounded list of recent sanitized routes, status codes and durations.

These are operational observations, not Google Core Web Vitals, synthetic Lighthouse scores or cumulative monthly billing records.

## Error tracking and trace correlation

HTTP 5xx observations count as server-error samples. A 32-hex trace ID may be attached for correlation, but **complete distributed tracing, stack-symbolication and alert routing are not provided** by this collector. Integrate W3C Trace Context/OpenTelemetry exporters separately before presenting linked multi-service spans.

## API latency and retention

Atomic API key rate limits protect ingestion. Samples are tenant-scoped and not available to unrelated project owners. The initial read window is 24 hours; backing storage and retention cleanup require production database jobs and data minimization review.

## Uptime and alerts

Code Deb Observability includes project-scoped **HTTPS uptime monitors**. An account owner may register a monitor by name and HTTPS URL, inspect its last real status, HTTP code and elapsed time, and disable it. The destination URL is AES-256-GCM sealed; its hostname is shown for identification. Probe history is stored separately with timestamp, HTTP status and duration.

Monitoring jobs are claimed transactionally every five minutes and executed with DNS-pinned HTTPS checks that refuse private and loopback addresses. On an actual status change, a `monitor.up` or `monitor.down` event is atomically queued for the project's matching webhook subscribers. The dedicated job endpoint `POST /api/developer/v1/jobs/uptime` requires the secret `CODEDEB_DEVELOPER_JOB_TOKEN`.

**A scheduler must actually call the internal uptime endpoint**; without one, monitors stay unknown and no live check or alert has occurred. Pager/Slack/email notification channels, retention cleanup, incident policy management and globally distributed synthetic probes remain separate integrations.

## Acceptance tests

Send real authorized telemetry and verify aggregation; check rejected invalid paths and oversized values; test no-token and wrong-scope requests; compare latency percentile calculations; validate tenant isolation and the absence of raw URL queries or user identifiers in stored samples.

[API Hub](/docs/platform/api-hub) · [Webhooks](/docs/platform/webhooks) · [Code Deb SDKs](/docs/sdk)

## Scheduler configuration

The shared Cloudflare Worker (`infra/cloudflare/developer-jobs/worker.mjs`) is designed to trigger delivery and uptime batches every five minutes, using a server-only secret binding. It is not active until its secret and Cron Trigger are configured. The worker exposes no HTTP diagnostics or public controls. Uptime remains `unknown` before the first real probe and state-change alerts depend on a registered webhook destination. Automatic monitoring should be considered active only when Cloudflare confirms the trigger and the API returns successful worker acknowledgements.
