| 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 write telemetry to the fleet bucket. |
| 6 | Set `CELLD_OTEL=http://collector:4318` to send telemetry to an OTLP collector. |
| 7 | |
| 8 | The default sink is the fleet bucket. celld writes Parquet files under |
| 9 | the `telemetry/` prefix, so a fleet with a bucket has observability |
| 10 | with no other service. DuckDB can query these files directly. An |
| 11 | alternative sink sends the same data to an OpenTelemetry collector. |
| 12 | |
| 13 | The schema is version `v0-unstable`. The column names can change |
| 14 | before a stable release, and each file carries the schema version in |
| 15 | its object metadata under the name `celld-schema`. Azure Blob Storage |
| 16 | does not accept a hyphen in a metadata name, so on an `az://` bucket |
| 17 | the name is `celld_schema`. |
| 18 | |
| 19 | ## Configuration |
| 20 | |
| 21 | | variable | default | effect | |
| 22 | | --- | --- | --- | |
| 23 | | `CELLD_OTEL` | `0` | `0` disables telemetry. `1` writes Parquet to the fleet bucket. An HTTP(S) collector base URL selects OTLP/HTTP protobuf. | |
| 24 | | `CELLD_OTEL_BUCKET` | the fleet bucket | A different bucket for the Parquet files, on the same endpoint and credentials. | |
| 25 | | `CELLD_OTEL_RETENTION` | `30d` | celld deletes telemetry files older than this. `none` disables the deletion, so your own lifecycle rules can control the data. | |
| 26 | | `CELLD_OTEL_FLUSH_MS` | `300000` | celld writes a Parquet file after this many milliseconds of buffered events. | |
| 27 | | `CELLD_OTEL_FLUSH_BYTES` | `5242880` | The estimated buffered bytes that trigger a flush before the interval ends. | |
| 28 | | `OTEL_TRACES_SAMPLER` | `parentbased_always_on` | A standard sampler name. `traceidratio` with `OTEL_TRACES_SAMPLER_ARG` records a fraction of the traces. | |
| 29 | | `OTEL_EXPORTER_OTLP_HEADERS` | unset | A comma-separated list of `name=value` headers for the collector. | |
| 30 | | `OTEL_EXPORTER_OTLP_TIMEOUT` | `10000` | The collector request timeout in milliseconds. | |
| 31 | | `OTEL_SERVICE_NAME` | `celld` | The service name in the exported resource. | |
| 32 | |
| 33 | The `bucket` sink requires the node to have a fleet bucket |
| 34 | (`CELLD_BUCKET`). The `otlp` sink works on a node without one. |
| 35 | |
| 36 | Use a full HTTP(S) collector base URL without a query or a fragment. |
| 37 | celld adds `/v1/traces` and `/v1/logs` to its path for the two signals. |
| 38 | `CELLD_OTEL` supplies the collector address, so celld does not read |
| 39 | `OTEL_EXPORTER_OTLP_ENDPOINT`. |
| 40 | |
| 41 | `CELLD_OTEL_SINK` is removed. Remove this setting before starting the node. |
| 42 | For a collector, copy its full base URL into `CELLD_OTEL`. For the fleet bucket, keep `CELLD_OTEL=1`. |
| 43 | |
| 44 | |
| 45 | ## What celld records |
| 46 | |
| 47 | celld records a span for each request a stateless Worker serves, for |
| 48 | each event a cell serves (a fetch, an alarm, an RPC, a WebSocket |
| 49 | message), for each outbound `fetch()`, and for each cell start. A |
| 50 | span carries the request id, the cell, the isolate, the |
| 51 | queue wait, the outbound URL and status, and the durability facts the |
| 52 | runtime already knows. |
| 53 | |
| 54 | celld also records each `console.log` line as a log record. The log |
| 55 | record carries the trace id and the span id of the handler that wrote |
| 56 | it, so a query can join the logs to the traces. The correlation |
| 57 | survives `await`. |
| 58 | |
| 59 | The log record also carries the OpenTelemetry severity of the console |
| 60 | method: |
| 61 | |
| 62 | | method | severity number | severity text | |
| 63 | | --- | --- | --- | |
| 64 | | `console.debug` | `5` | `DEBUG` | |
| 65 | | `console.log`, `console.info` | `9` | `INFO` | |
| 66 | | `console.warn` | `13` | `WARN` | |
| 67 | | `console.error` | `17` | `ERROR` | |
| 68 | |
| 69 | The OTLP export sets these values in the `severity_number` and |
| 70 | `severity_text` fields. The Parquet export writes them to columns with |
| 71 | the same names. The body contains only the message, so a query must use |
| 72 | the severity to find the level. |
| 73 | |
| 74 | A log file from an earlier celld version has no severity columns. A |
| 75 | DuckDB query over files from both versions must therefore read them |
| 76 | with `union_by_name = true`. |
| 77 | |
| 78 | celld reads the W3C `traceparent` header on incoming requests, so its |
| 79 | spans join the trace of the system in front of it. celld sends a |
| 80 | `traceparent` header on outbound `fetch()`, so downstream systems can |
| 81 | join too. celld ignores a malformed header and starts a new trace. A |
| 82 | Worker call to a Durable Object stays in one trace. |
| 83 | |
| 84 | The sampler decides at the start of a request. An unsampled request |
| 85 | records nothing and costs almost nothing. Under load, telemetry sheds |
| 86 | before requests do, and celld counts what it sheds. |
| 87 | |
| 88 | A sampling ratio of `0` records no traces, and a ratio of `1` records |
| 89 | every trace. An intermediate ratio makes the same trace-id decision on |
| 90 | each node. |
| 91 | |
| 92 | celld keeps a valid incoming context when the sampler rejects it. An |
| 93 | outbound `fetch()` or Durable Object call keeps the trace id, uses a new |
| 94 | span id, and keeps the sampled flag clear. |
| 95 | |
| 96 | celld records no metrics yet. The spans carry the durations and the |
| 97 | queue waits, so many questions a metric answers have an answer in the |
| 98 | traces, and a metrics signal can come later without a change to the |
| 99 | trace schema. |
| 100 | |
| 101 | ## Query the bucket with DuckDB |
| 102 | |
| 103 | ```sql |
| 104 | INSTALL httpfs; LOAD httpfs; |
| 105 | CREATE SECRET celld_telemetry ( |
| 106 | TYPE s3, KEY_ID '...', SECRET '...', |
| 107 | ENDPOINT 's3.example.com', URL_STYLE 'path' |
| 108 | ); |
| 109 | CREATE VIEW traces AS SELECT * FROM |
| 110 | read_parquet('s3://YOUR-BUCKET/telemetry/traces/*/*/*/*/*/*.parquet'); |
| 111 | CREATE VIEW logs AS SELECT * FROM |
| 112 | read_parquet('s3://YOUR-BUCKET/telemetry/logs/*/*/*/*/*/*.parquet'); |
| 113 | |
| 114 | -- The slowest requests. |
| 115 | SELECT name, duration_us, trace_id FROM traces |
| 116 | ORDER BY duration_us DESC LIMIT 20; |
| 117 | |
| 118 | -- The error lines. |
| 119 | SELECT time_unix_us, body FROM logs WHERE severity_number >= 17; |
| 120 | |
| 121 | -- Every log line, inside the span that wrote it. |
| 122 | SELECT l.body, t.name, t.duration_us FROM logs l |
| 123 | JOIN traces t ON l.trace_id = t.trace_id AND l.span_id = t.span_id; |
| 124 | ``` |
| 125 | |
| 126 | An S3-compatible endpoint such as minio needs `URL_STYLE 'path'` in |
| 127 | the secret, and a plain-HTTP endpoint also needs `USE_SSL false`. AWS |
| 128 | itself does not need either. |
| 129 | |
| 130 | The files are partitioned by node and by hour: |
| 131 | `telemetry/traces/<node>/<yyyy>/<mm>/<dd>/<hh>/<id>.parquet`. A query |
| 132 | that reads one day therefore touches only that day's files. |
| 133 | |
| 134 | ## File size and compaction |
| 135 | |
| 136 | celld writes one Parquet file for each flush, on a time limit or a |
| 137 | size target, whichever it reaches first. The default interval is 5 minutes |
| 138 | (`CELLD_OTEL_FLUSH_MS=300000`). The default size target is 5 MiB of estimated |
| 139 | buffered events (`CELLD_OTEL_FLUSH_BYTES=5242880`). The event that reaches |
| 140 | the target can take the batch past it. |
| 141 | |
| 142 | Keep the defaults if you run no compaction job. They make files large |
| 143 | enough for a fast query with no other moving part. The default batching |
| 144 | delay can reach 5 minutes, so the default suits an investigation after the fact. |
| 145 | |
| 146 | Set `CELLD_OTEL_FLUSH_MS=5000` for a five-second batching interval. |
| 147 | An upload, a retry, or collector processing can add a delivery delay. |
| 148 | A short flush makes many small files, and DuckDB |
| 149 | opens every file a query reads, so you must also run the compaction |
| 150 | job below. Turn on the compaction job first, then shorten the flush, |
| 151 | or queries grow slow within hours. |
| 152 | |
| 153 | The `otlp` sink is the other route to a near-live view. It sends each |
| 154 | batch to a collector, so set the same short `CELLD_OTEL_FLUSH_MS`. |
| 155 | |
| 156 | The `otlp` sink makes no more than five attempts for a batch when a |
| 157 | transient failure occurs. It uses exponential backoff with jitter, and it |
| 158 | uses an applicable `Retry-After` value from the collector. The exporter caps |
| 159 | each delay at 30 seconds, so a collector cannot suspend a batch indefinitely. |
| 160 | HTTP 408, 429, 502, 503, and 504 responses are transient failures. A |
| 161 | permanent refusal drops the batch immediately. |
| 162 | |
| 163 | The exporter owns one retrying batch, and the input channel holds 8192 |
| 164 | new events. An outage cannot make either bound grow. celld drops and counts |
| 165 | new telemetry when the channel is full, so request handling continues. |
| 166 | |
| 167 | The retention sweep runs at startup and six hours after each completed sweep. It deletes expired |
| 168 | objects and preserves objects within the configured retention window. |
| 169 | |
| 170 | ## Compaction |
| 171 | |
| 172 | Run a compaction job on a maintenance node, not on a celld node. celld |
| 173 | does not compact its own files, because the serving path must not do |
| 174 | storage maintenance and each node writes only the files it produced. |
| 175 | |
| 176 | The job rewrites one past hour of small files into one large file. |
| 177 | DuckDB does the work: |
| 178 | |
| 179 | ```sql |
| 180 | COPY ( |
| 181 | SELECT * FROM |
| 182 | read_parquet('s3://YOUR-BUCKET/telemetry/traces/<node>/2026/08/09/22/*.parquet') |
| 183 | ORDER BY start_unix_us |
| 184 | ) TO 's3://YOUR-BUCKET/telemetry/traces/<node>/2026/08/09/22/compacted.parquet' |
| 185 | (FORMAT parquet, COMPRESSION zstd); |
| 186 | ``` |
| 187 | |
| 188 | Run the job once an hour, for the hour that just ended. Do not compact |
| 189 | the current hour, because a node still writes to it. Delete the source |
| 190 | files after DuckDB writes the compacted file. The compacted file is |
| 191 | also smaller, because zstd compresses one sorted batch better than |
| 192 | many separate files. |