feat: enable Cloudflare Workers observability (logs + traces)

Add observability config to wrangler.jsonc with logs and traces enabled,
100% sampling, and persistence. Free tier feature — no code changes needed.
This commit is contained in:
2026-04-09 10:06:41 +07:00
parent 4ce97e5bf0
commit bb8f4dcde8
3 changed files with 24 additions and 1 deletions

View File

@@ -97,6 +97,15 @@ Binding: `claude-status` queue
- **403/400 handling**: subscriber removed from KV, message acknowledged - **403/400 handling**: subscriber removed from KV, message acknowledged
- **Network errors**: `msg.retry()` for transient failures - **Network errors**: `msg.retry()` for transient failures
## Observability
Enabled via `wrangler.jsonc` `observability` config. Automatic — no code changes required.
- **Logs**: All `console.log`/`console.error` calls, request metadata, exceptions. Persisted with invocation logs enabled. Free tier: 200k logs/day, 3-day retention.
- **Traces**: Automatic instrumentation of fetch calls, KV reads, queue operations. Persisted.
- **Sampling**: 100% (`head_sampling_rate: 1`) for both logs and traces — reduce for high-volume scenarios
- **Dashboard**: Cloudflare Dashboard → Workers → Observability
## Security ## Security
- **Statuspage webhook auth**: URL path secret validated with timing-safe SHA-256 comparison - **Statuspage webhook auth**: URL path secret validated with timing-safe SHA-256 comparison

View File

@@ -10,7 +10,6 @@ import {
humanizeStatus, humanizeStatus,
STATUS_URL, STATUS_URL,
} from "./status-fetcher.js"; } from "./status-fetcher.js";
/** /**
* Register info commands: /help, /status, /history, /uptime * Register info commands: /help, /status, /history, /uptime
*/ */

View File

@@ -23,6 +23,21 @@
"max_retries": 3 "max_retries": 3
} }
] ]
},
"observability": {
"enabled": false,
"head_sampling_rate": 1,
"logs": {
"enabled": true,
"head_sampling_rate": 1,
"persist": true,
"invocation_logs": true
},
"traces": {
"enabled": true,
"persist": true,
"head_sampling_rate": 1
}
} }
// Secrets (set via `wrangler secret put`): // Secrets (set via `wrangler secret put`):
// BOT_TOKEN - Telegram bot token // BOT_TOKEN - Telegram bot token