Workers 追踪按 span 计费:先量每条 trace 的 span 数,再定采样率
Omid Saffari 说明一次跨 RPC 调用的追踪请求可能产生多个计费 span,建议先在一条路径上量出 span 密度,再设定生产采样率。
- 适用产品
- WorkersDurable ObjectsWorkers Logs
- 来源
- 作者经验𝕏
- 作者
- Omid Saffari(@omidsaffari)
要点
- 作者写道:10 月 1 日起,根 span、RPC 会话、方法调用、被调方调用和嵌套绑定 span 都共享 Workers Logs 额度;默认 head_sampling_rate 为 1,即追踪 100% 请求。
- 他的方法:先以 100% 采样复现一条客户路径并数出 span,再按“采样请求数 × 每条 trace 平均 span 数 + 现有日志事件”估算;0.05 之类的采样率能降量,但可能漏掉少见的慢请求。
- 现行文档(2026-10-14 复核):2026 年 12 月 1 日起日志与追踪改按 GB 计的 Observability 定价;此前 Workers Logs 为 Free 每天 20 万条、Paid 每月 2000 万条,超出每百万 0.60 美元。
原始来源
发布
原帖
到 𝕏 阅读Omid Saffari 说明一次跨 RPC 调用的追踪请求可能产生多个计费 span,建议先在一条路径上量出 span 密度,再设定生产采样率。
Omid Saffari
@omidsaffari · 𝕏 原帖
From October 1, one traced customer request can count as several observability events. @Cloudflare bills Workers tracing by span, and the default setting samples 100% of incoming requests. That matters because the new trace is much more useful than the old one. A JavaScript RPC call is one Worker calling a public method on another Worker or Durable Object. Until this release, the trace could stop at that boundary. You saw the caller make the request, then had to match logs or add custom spans to reconstruct what happened downstream. Now the same timeline can contain the caller-side RPC session, each method call, the callee invocation and nested calls or callbacks. For a checkout path, that means you can follow the first Worker into inventory.reserve(), then into order.commit() on a Durable Object. If the inventory invocation holds most of the wall time, start with its storage or upstream dependency. If the Durable Object call is wide, start with that handler. If the caller is slow before either RPC starts, stop blaming the downstream services. The trace finds the owner of the wait. It does not diagnose the slow method for you. These platform spans appear automatically after tracing is enabled, without adding an observability SDK or changing application code. But automatic tracing stops when the request leaves the platform, and some non-I/O work can show 0 ms because runtime time updates at an I/O event. The cost needs the same care as the diagnosis. Tracing is free during the initial beta. After October 1, every root, RPC session, method-call, callee and nested binding span shares the Workers Logs quota. Free includes 200,000 observability events per day and keeps them for 3 days. Paid includes 20 million per month, keeps them for 7 days and charges $0.60 per additional million. A sampling rate of 0.05 traces 5 of every 100 incoming requests. That cuts volume, but the decision happens before the request runs, so the rare slow one may never be selected. Start with one repeatable customer path at 100%. Count the spans it creates, then estimate sampled requests multiplied by average spans per trace and add the log events already using the quota. Set production sampling from measured spans per trace, not from request count. https://t.co/kS52KWk85N
作者博客版本逐步说明如何开启追踪、阅读 RPC span,并在上线前估算每月追踪事件量。
打开原始来源阅读全文归档于
此译文尚未完整。
Cloudflare 能看出是哪个 Worker 拖慢了客户请求
你可以看出哪个服务和方法拖慢了请求
其他推荐阅读
风易:上游响应不要次次现调,用 Cache API 做边缘缓存
2026-11-18,X 用户 @Michael_liyang(风易)写道:上游响应别次次现调,用 Cache API 做边缘缓存。做法是:请求先查 Cache API,命中直接返回;未命中再调上游,成功响应写缓存并带 TTL;写操作不进缓存,命中率记进 D1 日报。链路是请求→查缓存→命中返→未命中调上游→回写→返回。作者判断:缓存的是上游结果,不是你的业务状态。
itsabhisheksood:Cloudflare 的 3D Secure 提示要求确认一笔 $275.68 的月度付款。
X 用户 @itsabhisheksood(Abhishek Sood)发布了一张 Cloudflare 3D Secure 提示的截图,要求确认一笔 $275.68 的付款,配文为“A vibe coding mishap or something big in the making?”。该提示描述的是月度付款。X 用户 @thisnaeem 回复称这是一笔 $275.68 的 Cloudflare 月度账单,并询问是智能体开通了什么还是用量累积。产品和原因未说明。公开结果未知。
Cloudflare Containers 定价:vCPU、内存、磁盘与出站流量
官方 Containers 定价(dateModified 2026-11-13):主动运行期间每 10ms 计费。内存与磁盘按预配的实例大小、在实例处于 up 状态的时间计费;CPU 仅按活跃使用计费。Workers Paid 每月包含 25 GiB-hours 内存、375 vCPU-minutes 和 200 GB-hours 磁盘,其后为按秒超额费率。费用在请求被发送到容器或容器被启动时开始,在实例进入休眠后停止。快照在公开 beta 期间免费;GA 定价尚未公布。该官方页面此前尚未进入目录;它在 2026-11-22 至 2026-11-25 窗口内没有变化。