提供案例
billflare.

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 美元。

原始来源

  1. 发布

    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
  2. 作者博客版本逐步说明如何开启追踪、阅读 RPC span,并在上线前估算每月追踪事件量。

    打开原始来源
作者经验Durable Objects +3

在 Durable Objects 上设计扑克游戏,让空闲时间不花钱

Philip Atkinson 介绍他在 Cloudflare 开发者平台上的多人扑克游戏架构,以及他遵循的成本原则:结束的对局移出 Durable Object 存储、WebSocket 休眠、用 alarm 唤醒、把日志当作成本决策。

其他产品

sylwair:项目失误,不到两天爆了近 900 刀。

@sylwair 称最近因项目失误爆了账单,不到两天爆了近 900 刀。他称在 Cloudflare【可计费使用量】中发现后停掉了异常服务;在回复中补充,由于每日账单延时展示,停服后看到金额没有明显下降。

官方说明账号级用量计费产品

预算预警

Cloudflare 官方说明账号级费用预警及其通知边界。