| 1 | # Telemetry |
| 2 | |
| 3 | celld can record traces and logs for the requests it serves. Telemetry is off |
| 4 | by default and costs nothing when off. `CELLD_OTEL=1` writes Parquet files |
| 5 | under the `telemetry/` prefix of the fleet bucket, which DuckDB can query |
| 6 | directly. `CELLD_OTEL=http://collector:4318` sends the same data to an |
| 7 | OpenTelemetry collector. |
| 8 | |
| 9 | The schema is version `v0-unstable`, so column names can change before a |
| 10 | stable release. Each file carries the version in the object metadata name |
| 11 | `celld-schema`, or `celld_schema` on an `az://` bucket. |
| 12 | |
| 13 | ## Configuration |
| 14 | |
| 15 | | variable | default | effect | |
| 16 | | --- | --- | --- | |
| 17 | | `CELLD_OTEL` | `0` | `0` disables telemetry. `1` writes Parquet to the fleet bucket. An HTTP(S) collector base URL selects OTLP/HTTP protobuf. | |
| 18 | | `CELLD_OTEL_BUCKET` | the fleet bucket | A different bucket for the Parquet files, on the same endpoint and credentials. | |
| 19 | | `CELLD_OTEL_RETENTION` | `30d` | celld deletes telemetry files older than this. `none` disables the deletion, so your own lifecycle rules can control the data. In the fleet bucket, such a rule must select only the `telemetry/` prefix, after the key prefix if the bucket value has one. [Guarantees](guarantees.md) lists the reserved prefixes that a rule must not select. | |
| 20 | | `CELLD_OTEL_FLUSH_MS` | `300000` | celld writes a Parquet file after this many milliseconds of buffered events. | |
| 21 | | `CELLD_OTEL_FLUSH_BYTES` | `5242880` | The estimated buffered bytes that trigger a flush before the interval ends. | |
| 22 | | `OTEL_TRACES_SAMPLER` | `parentbased_always_on` | A standard sampler name. `traceidratio` with `OTEL_TRACES_SAMPLER_ARG` records a fraction of the traces. | |
| 23 | | `OTEL_EXPORTER_OTLP_HEADERS` | unset | A comma-separated list of `name=value` headers for the collector. | |
| 24 | | `OTEL_EXPORTER_OTLP_TIMEOUT` | `10000` | The collector request timeout in milliseconds. | |
| 25 | | `OTEL_SERVICE_NAME` | `celld` | The service name in the exported resource. | |
| 26 | |
| 27 | The bucket sink requires `CELLD_BUCKET`. The OTLP sink does not. |
| 28 | |
| 29 | A collector URL must have no query or fragment. celld appends `/v1/traces` and |
| 30 | `/v1/logs` to its path and ignores `OTEL_EXPORTER_OTLP_ENDPOINT`. |
| 31 | |
| 32 | `CELLD_OTEL_SINK` is removed, and a node with it set does not start. Put the |
| 33 | collector base URL in `CELLD_OTEL`, or keep `CELLD_OTEL=1` for the bucket. |
| 34 | |
| 35 | ## What celld records |
| 36 | |
| 37 | celld records a span for each stateless Worker request, each cell event (a |
| 38 | fetch, an alarm, an RPC, a WebSocket message), each outbound `fetch()`, and |
| 39 | each cell start. A span carries the request id, the cell, the isolate, the |
| 40 | queue wait, the outbound URL and status, and the known durability facts. |
| 41 | |
| 42 | Each `console.log` line becomes a log record with the trace id and span id of |
| 43 | its handler, across `await`. The record carries the console method's severity |
| 44 | in `severity_number` and `severity_text` (OTLP fields and Parquet columns). The |
| 45 | body holds only the message. |
| 46 | |
| 47 | | method | severity number | severity text | |
| 48 | | --- | --- | --- | |
| 49 | | `console.debug` | `5` | `DEBUG` | |
| 50 | | `console.log`, `console.info` | `9` | `INFO` | |
| 51 | | `console.warn` | `13` | `WARN` | |
| 52 | | `console.error` | `17` | `ERROR` | |
| 53 | |
| 54 | Log files from earlier celld versions have no severity columns. Read a mix of |
| 55 | versions with `union_by_name = true`. |
| 56 | |
| 57 | celld reads the W3C `traceparent` header on incoming requests and sends it on |
| 58 | outbound `fetch()`. A malformed header starts a new trace. A Worker call to a |
| 59 | Durable Object stays in one trace. |
| 60 | |
| 61 | The sampler decides at the start of a request, and an unsampled request |
| 62 | records nothing. A ratio of `0` records no traces and `1` records all. An |
| 63 | intermediate ratio makes the same trace-id decision on each node. celld keeps |
| 64 | a valid incoming context that the sampler rejects: an outbound `fetch()` or |
| 65 | Durable Object call keeps the trace id, uses a new span id, and keeps the |
| 66 | sampled flag clear. |
| 67 | |
| 68 | Under load, telemetry sheds before requests do, and celld counts what it |
| 69 | sheds. celld records no metrics yet. |
| 70 | |
| 71 | ## Query the bucket with DuckDB |
| 72 | |
| 73 | ```sql |
| 74 | INSTALL httpfs; LOAD httpfs; |
| 75 | CREATE SECRET celld_telemetry ( |
| 76 | TYPE s3, KEY_ID '...', SECRET '...', |
| 77 | ENDPOINT 's3.example.com', URL_STYLE 'path' |
| 78 | ); |
| 79 | CREATE VIEW traces AS SELECT * FROM |
| 80 | read_parquet('s3://YOUR-BUCKET/telemetry/traces/*/*/*/*/*/*.parquet'); |
| 81 | CREATE VIEW logs AS SELECT * FROM |
| 82 | read_parquet('s3://YOUR-BUCKET/telemetry/logs/*/*/*/*/*/*.parquet'); |
| 83 | |
| 84 | -- The slowest requests. |
| 85 | SELECT name, duration_us, trace_id FROM traces |
| 86 | ORDER BY duration_us DESC LIMIT 20; |
| 87 | |
| 88 | -- The error lines. |
| 89 | SELECT time_unix_us, body FROM logs WHERE severity_number >= 17; |
| 90 | |
| 91 | -- Every log line, inside the span that wrote it. |
| 92 | SELECT l.body, t.name, t.duration_us FROM logs l |
| 93 | JOIN traces t ON l.trace_id = t.trace_id AND l.span_id = t.span_id; |
| 94 | ``` |
| 95 | |
| 96 | A non-AWS S3-compatible endpoint needs `URL_STYLE 'path'`. A plain-HTTP |
| 97 | endpoint also needs `USE_SSL false`. |
| 98 | |
| 99 | Files are partitioned by node and hour: |
| 100 | `telemetry/traces/<node>/<yyyy>/<mm>/<dd>/<hh>/<id>.parquet`. |
| 101 | |
| 102 | ## Flushing and delivery |
| 103 | |
| 104 | celld writes one Parquet file per flush, at 5 minutes |
| 105 | (`CELLD_OTEL_FLUSH_MS=300000`) or 5 MiB of estimated buffered events |
| 106 | (`CELLD_OTEL_FLUSH_BYTES=5242880`), whichever comes first. The event that |
| 107 | reaches the target can take the batch past it. |
| 108 | |
| 109 | Keep the defaults if you run no compaction job. They produce large files, but |
| 110 | data can arrive up to 5 minutes late. `CELLD_OTEL_FLUSH_MS=5000` gives a |
| 111 | five-second interval, plus upload or collector delay. A short interval makes |
| 112 | many small files and slows queries within hours, so start the compaction job |
| 113 | first. For a near-live view, use the OTLP sink with the same short interval. |
| 114 | |
| 115 | The OTLP sink makes at most five attempts per batch on a transient failure |
| 116 | (HTTP 408, 429, 502, 503, or 504). It uses exponential backoff with jitter and |
| 117 | honors `Retry-After`, with each delay capped at 30 seconds. A permanent |
| 118 | refusal drops the batch. |
| 119 | |
| 120 | The exporter holds one retrying batch, and the input channel holds 8192 new |
| 121 | events. When the channel is full, celld drops and counts new telemetry, so |
| 122 | request handling continues. |
| 123 | |
| 124 | The retention sweep runs at startup and six hours after each completed sweep. |
| 125 | |
| 126 | ## Compaction |
| 127 | |
| 128 | celld does not compact its own files. Run a compaction job on a maintenance |
| 129 | node once an hour, for the hour that just ended. Do not compact the current |
| 130 | hour, because a node still writes to it. |
| 131 | |
| 132 | ```sql |
| 133 | COPY ( |
| 134 | SELECT * FROM |
| 135 | read_parquet('s3://YOUR-BUCKET/telemetry/traces/<node>/2026/08/09/22/*.parquet') |
| 136 | ORDER BY start_unix_us |
| 137 | ) TO 's3://YOUR-BUCKET/telemetry/traces/<node>/2026/08/09/22/compacted.parquet' |
| 138 | (FORMAT parquet, COMPRESSION zstd); |
| 139 | ``` |
| 140 | |
| 141 | Delete the source files after DuckDB writes the compacted file. |