| 1 | # Telemetry |
| 2 | |
| 3 | celld can record traces and logs for the requests it serves. The |
| 4 | feature is off by default, and the off state costs nothing. Set |
| 5 | `CELLD_OTEL=1` to turn it on. |
| 6 | |
| 7 | The default sink is the fleet bucket. celld writes Parquet files under |
| 8 | the `telemetry/` prefix, so a fleet with a bucket has observability |
| 9 | with no other service. DuckDB can query these files directly. An |
| 10 | alternative sink sends the same data to an OpenTelemetry collector. |
| 11 | |
| 12 | The schema is version `v0-unstable`. The column names can change |
| 13 | before a stable release, and each file carries the schema version in |
| 14 | its object metadata. |
| 15 | |
| 16 | ## Configuration |
| 17 | |
| 18 | | variable | default | effect | |
| 19 | | --- | --- | --- | |
| 20 | | `CELLD_OTEL` | `0` | Set this value to `1` to enable telemetry. | |
| 21 | | `CELLD_OTEL_SINK` | `bucket` | `bucket` writes Parquet to the fleet bucket. `otlp` sends OTLP/HTTP protobuf to a collector instead. | |
| 22 | | `CELLD_OTEL_BUCKET` | the fleet bucket | A different bucket for the Parquet files, on the same endpoint and credentials. | |
| 23 | | `CELLD_OTEL_RETENTION` | `30d` | celld deletes telemetry files older than this. `none` disables the deletion, so your own lifecycle rules can control the data. | |
| 24 | | `CELLD_OTEL_FLUSH_MS` | `300000` | celld writes a Parquet file after this many milliseconds of buffered events. | |
| 25 | | `CELLD_OTEL_FLUSH_BYTES` | `5242880` | celld writes a Parquet file after the buffered events reach this many bytes. celld uses the limit it reaches first. | |
| 26 | | `OTEL_TRACES_SAMPLER` | `parentbased_always_on` | A standard sampler name. `traceidratio` with `OTEL_TRACES_SAMPLER_ARG` records a fraction of the traces. | |
| 27 | | `OTEL_EXPORTER_OTLP_ENDPOINT` | `http://localhost:4318` | The collector base URL, for the `otlp` sink. `OTEL_EXPORTER_OTLP_HEADERS` and `OTEL_EXPORTER_OTLP_TIMEOUT` also apply. | |
| 28 | | `OTEL_SERVICE_NAME` | `celld` | The service name in the exported resource. | |
| 29 | |
| 30 | The `bucket` sink requires the node to have a fleet bucket |
| 31 | (`CELLD_BUCKET`). The `otlp` sink works on a node without one. |
| 32 | |
| 33 | ## What celld records |
| 34 | |
| 35 | celld records a span for each request a stateless Worker serves, for |
| 36 | each event a cell serves (a fetch, an alarm, an RPC, a WebSocket |
| 37 | message), for each outbound `fetch()`, and for each cell start. A |
| 38 | span carries the request id, the cell, the isolate, the |
| 39 | queue wait, the outbound URL and status, and the durability facts the |
| 40 | runtime already knows. |
| 41 | |
| 42 | celld also records each `console.log` line as a log record. The log |
| 43 | record carries the trace id and the span id of the handler that wrote |
| 44 | it, so a query can join the logs to the traces. The correlation |
| 45 | survives `await`. |
| 46 | |
| 47 | celld reads the W3C `traceparent` header on incoming requests, so its |
| 48 | spans join the trace of the system in front of it. celld sends a |
| 49 | `traceparent` header on outbound `fetch()`, so downstream systems can |
| 50 | join too. A Worker call to a Durable Object stays in one trace. |
| 51 | |
| 52 | The sampler decides at the start of a request. An unsampled request |
| 53 | records nothing and costs almost nothing. Under load, telemetry sheds |
| 54 | before requests do, and celld counts what it sheds. |
| 55 | |
| 56 | celld records no metrics yet. This is a known gap, not a silent one: |
| 57 | the spans carry the durations and the queue waits, so many questions |
| 58 | a metric answers have an answer in the traces, and a metrics signal |
| 59 | can come later without a change to the trace schema. |
| 60 | |
| 61 | ## Query the bucket with DuckDB |
| 62 | |
| 63 | ```sql |
| 64 | INSTALL httpfs; LOAD httpfs; |
| 65 | CREATE SECRET celld_telemetry ( |
| 66 | TYPE s3, KEY_ID '...', SECRET '...', |
| 67 | ENDPOINT 's3.example.com', URL_STYLE 'path' |
| 68 | ); |
| 69 | CREATE VIEW traces AS SELECT * FROM |
| 70 | read_parquet('s3://YOUR-BUCKET/telemetry/traces/*/*/*/*/*/*.parquet'); |
| 71 | CREATE VIEW logs AS SELECT * FROM |
| 72 | read_parquet('s3://YOUR-BUCKET/telemetry/logs/*/*/*/*/*/*.parquet'); |
| 73 | |
| 74 | -- The slowest requests. |
| 75 | SELECT name, duration_us, trace_id FROM traces |
| 76 | ORDER BY duration_us DESC LIMIT 20; |
| 77 | |
| 78 | -- Every log line, inside the span that wrote it. |
| 79 | SELECT l.body, t.name, t.duration_us FROM logs l |
| 80 | JOIN traces t ON l.trace_id = t.trace_id AND l.span_id = t.span_id; |
| 81 | ``` |
| 82 | |
| 83 | An S3-compatible endpoint such as minio needs `URL_STYLE 'path'` in |
| 84 | the secret, and a plain-HTTP endpoint also needs `USE_SSL false`. AWS |
| 85 | itself does not need either. |
| 86 | |
| 87 | The files are partitioned by node and by hour: |
| 88 | `telemetry/traces/<node>/<yyyy>/<mm>/<dd>/<hh>/<id>.parquet`. A query |
| 89 | that reads one day therefore touches only that day's files. |
| 90 | |
| 91 | ## File size and compaction |
| 92 | |
| 93 | celld writes one Parquet file for each flush, on a time limit or a |
| 94 | size limit, whichever it reaches first. The defaults are 5 minutes |
| 95 | (`CELLD_OTEL_FLUSH_MS=300000`) and 5 MB (`CELLD_OTEL_FLUSH_BYTES=5242880`). |
| 96 | |
| 97 | Keep the defaults if you run no compaction job. They make files large |
| 98 | enough for a fast query with no other moving part. A query sees an |
| 99 | event up to 5 minutes after the request, so the default suits an |
| 100 | investigation after the fact. |
| 101 | |
| 102 | Set `CELLD_OTEL_FLUSH_MS=10000` for a near-live view, such as a |
| 103 | dashboard or an active debug session: a query then sees an event |
| 104 | within 10 seconds. A short flush makes many small files, and DuckDB |
| 105 | opens every file a query reads, so you must also run the compaction |
| 106 | job below. Turn on the compaction job first, then shorten the flush, |
| 107 | or queries grow slow within hours. |
| 108 | |
| 109 | The `otlp` sink is the other route to a near-live view. It sends each |
| 110 | batch to a collector, so set the same short `CELLD_OTEL_FLUSH_MS`. |
| 111 | |
| 112 | ## Compaction |
| 113 | |
| 114 | Run a compaction job on a maintenance node, not on a celld node. celld |
| 115 | does not compact its own files, because the serving path must not do |
| 116 | storage maintenance and each node writes only the files it produced. |
| 117 | |
| 118 | The job rewrites one past hour of small files into one large file. |
| 119 | DuckDB does the work: |
| 120 | |
| 121 | ```sql |
| 122 | COPY ( |
| 123 | SELECT * FROM |
| 124 | read_parquet('s3://YOUR-BUCKET/telemetry/traces/<node>/2026/08/09/22/*.parquet') |
| 125 | ORDER BY start_unix_us |
| 126 | ) TO 's3://YOUR-BUCKET/telemetry/traces/<node>/2026/08/09/22/compacted.parquet' |
| 127 | (FORMAT parquet, COMPRESSION zstd); |
| 128 | ``` |
| 129 | |
| 130 | Run the job once an hour, for the hour that just ended. Do not compact |
| 131 | the current hour, because a node still writes to it. Delete the source |
| 132 | files after DuckDB writes the compacted file. The compacted file is |
| 133 | also smaller, because zstd compresses one sorted batch better than |
| 134 | many separate files. |