From 72c420abce01130ab0836a69116d2a1cf94674b8 Mon Sep 17 00:00:00 2001 From: tiennm99 Date: Sat, 9 May 2026 12:03:47 +0700 Subject: [PATCH] feat(observability): enable full Workers Logs traces (100% sampling) --- CHANGELOG.md | 3 +++ README.md | 2 +- wrangler.toml | 10 +++++++++- 3 files changed, 13 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 27d193b..da88ed6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +### Changed +- Enable Workers Logs with `head_sampling_rate = 1` and `invocation_logs = true` — every cron tick produces a full trace, browsable in the CF dashboard for 3 days. + ## [0.1.0] - 2026-05-09 ### Added diff --git a/README.md b/README.md index 11c582f..a9bbdd7 100644 --- a/README.md +++ b/README.md @@ -135,7 +135,7 @@ The request pins `anthropic-beta: experimental-cc-routine-2026-04-01` (constant - **Time accuracy**: cron precision on CF Workers is within ~15 seconds — adequate for routine triggering. - **No retry**: each `/fire` POST creates a new Claude Code session — retrying multiplies sessions and burns quota. The worker logs failures and moves on. -- **Logs**: `wrangler tail` streams live; CF dashboard's "Logs" tab persists them per the observability tier. +- **Logs / traces**: `[observability]` is enabled in `wrangler.toml` with `head_sampling_rate = 1` and `invocation_logs = true` — every invocation produces a structured log + trace, retained per the [Workers Logs retention policy](https://developers.cloudflare.com/workers/observability/logs/workers-logs/) (3 days on the free plan). View live with `npx wrangler tail`, or browse history in the CF dashboard under **Workers & Pages → your worker → Logs**. - **Cost**: scheduled handlers count against the Workers Free plan's 100k requests/day budget. 5 daily fires × 30 days = 150 requests/month — negligible. ## Security diff --git a/wrangler.toml b/wrangler.toml index 96325e5..e74a9ef 100644 --- a/wrangler.toml +++ b/wrangler.toml @@ -19,6 +19,14 @@ crons = [ "0 0-17,22-23 * * *", # UTC+7: 00:00 + 05:00..23:00 hourly ] -# Built-in observability (free tier supports basic logs). +# Workers Logs / traces. `head_sampling_rate = 1` keeps 100% of invocations +# (low volume here — ~20/day — so full retention is free). Drop to e.g. 0.1 +# if traffic ever grows enough to matter. [observability] enabled = true +head_sampling_rate = 1 + +[observability.logs] +enabled = true +head_sampling_rate = 1 +invocation_logs = true