Tracing is optional. Connect an instance to the OpenTelemetry (OTLP/HTTP) traces endpoint of the backend you already use, and the release Worker exports the spans of every request and Run to it. A Run's owner continues the trace of the request that started it, so one Run is one trace, and the Run's result record names it. An instance without a traces endpoint exports nothing and needs none of the variables below.
Connecting your provider
Set these optional Stack variables and apply the instance Stack:
| Variable | Meaning |
|---|---|
SCWRAP_INSTANCE_TRACES_URL | The provider's HTTPS OTLP/HTTP traces endpoint, including its path, usually ending in /v1/traces. Unset turns tracing off, along with every other variable here. |
SCWRAP_INSTANCE_TRACES_HEADERS | A JSON object of headers sent with every export: the provider's credential, in whatever header it wants, and settings such as a dataset name. Stored as a Secrets Store secret, so it may hold keys and an authorization header. |
SCWRAP_INSTANCE_TRACES_TOKEN | A shortcut for providers that take a bearer token: sent as authorization: Bearer <token>, stored as its own Secrets Store secret. Leave it unset when SCWRAP_INSTANCE_TRACES_HEADERS holds authorization; setting both is refused. |
SCWRAP_INSTANCE_TRACES_PROTOCOL | http/json (the default) or http/protobuf. Every OTLP/HTTP endpoint accepts protobuf; some also take JSON. |
SCWRAP_INSTANCE_TRACES_LINK | An HTTPS URL template containing {traceId}, which gives every result record a traceUrl (Linking a record to its trace). |
Planning the Stack checks them: an HTTPS URL, a JSON object of valid header names to strings, a known protocol, a link with {traceId}. Give the instance an ingest-only credential, never one that can read or manage the backend.
Axiom
Create a dataset of kind otel:traces:v1, such as scwrap-traces-<stage>, and an API token that can only ingest into it. Use the endpoint of the dataset's edge deployment:
SCWRAP_INSTANCE_TRACES_URL=https://us-east-1.aws.edge.axiom.co/v1/traces
SCWRAP_INSTANCE_TRACES_HEADERS={"x-axiom-dataset":"scwrap-traces-<stage>"}
SCWRAP_INSTANCE_TRACES_TOKEN=<ingest-only API token>
SCWRAP_INSTANCE_TRACES_LINK=https://app.axiom.co/<org-id>/trace?traceDataset=scwrap-traces-<stage>&traceId={traceId}Axiom Runs dashboard adds a dashboard over that dataset.
Honeycomb
An ingest key goes in x-honeycomb-team; the service name scwrap-instance becomes the dataset:
SCWRAP_INSTANCE_TRACES_URL=https://api.honeycomb.io/v1/traces
SCWRAP_INSTANCE_TRACES_HEADERS={"x-honeycomb-team":"<ingest key>"}
SCWRAP_INSTANCE_TRACES_PROTOCOL=http/protobufUse https://api.eu1.honeycomb.io/v1/traces for an EU team.
Grafana Cloud
The stack's OTLP endpoint takes basic auth: the base64 of <instance id>:<token>, with a Cloud Access Policy token that has the traces:write scope. The stack's OpenTelemetry page shows the endpoint and instance ID:
SCWRAP_INSTANCE_TRACES_URL=https://otlp-gateway-<zone>.grafana.net/otlp/v1/traces
SCWRAP_INSTANCE_TRACES_HEADERS={"authorization":"Basic <base64 of instance id:token>"}
SCWRAP_INSTANCE_TRACES_PROTOCOL=http/protobufAny other backend or a collector
Any endpoint that speaks OTLP/HTTP works the same way: its URL, its credential header in SCWRAP_INSTANCE_TRACES_HEADERS, and http/protobuf unless it documents JSON. The exporter speaks OTLP over HTTP only, so backends that take only gRPC need an OpenTelemetry Collector in front of them, reachable over HTTPS.
Where production's spans go
Production uses Axiom:
| Production | |
|---|---|
| Endpoint | https://us-east-1.aws.edge.axiom.co/v1/traces, OTLP JSON |
| Headers | {"x-axiom-dataset":"scwrap-traces-production"} |
| Dataset | scwrap-traces-production (kind otel:traces:v1, 30-day retention) |
| Token | An ingest-only Axiom token for that dataset alone |
| Link | https://app.axiom.co/jakob-kruse-yy9n/trace?traceDataset=scwrap-traces-production&traceId={traceId} |
| Dashboard | Scwrap Runs (production), from the Axiom Runs dashboard Stack |
The values live in the instance's OpenBao document.
What a trace holds
| Span | Service | What it is |
|---|---|---|
Runtime.fetch | scwrap-instance | The Worker's handling of one request. Carries scwrap.token.name, the run token that authenticated it (Named tokens); MCP's Instance.mcp span does too. |
Runtime.release | scwrap-instance | Asking a Release for its input check or its schemas, a child of Runtime.fetch or Instance.mcp, with scwrap.scraper, scwrap.release.revision and scwrap.release.digest. When the Release is unavailable, the span fails and carries scwrap.release.unavailable, the reason, such as Release sandbox failed: Missing artifact sdk/<digest>.mjs, Artifact digest mismatch: <key> or Artifact read failed: <key>: <R2 error>; the same reason is logged as a warning, which the Worker's logs show and the span holds as an event. The caller's 503 release_unavailable body carries only its code, such as artifact_missing (Errors, Finding why a Release was unavailable). |
Runtime.trigger | scwrap-instance | Starting a Run: checking the input and handing the Run to its owner. |
Runtime.start | scwrap-instance | The root of the Run's own trace: handing the Run to its owner, with scwrap.result.id and scwrap.scraper. It links the Runtime.trigger span that started it, in the request's trace, instead of being its child (Each Run has its own trace). |
Runtime.run | scwrap-instance | One Run, executed by its owner after the trigger has answered, a child of Runtime.start. Carries scwrap.result.id, scwrap.scraper, scwrap.release.revision, scwrap.release.digest and scwrap.token.name, and when the Run ends scwrap.run.status (completed or failed), scwrap.run.items, the items stored, and for a failed Run scwrap.run.error_tag, the tag of its error, such as RunTimeout, SchemaDrift or the Scraper's own. |
Runtime.storeItems | scwrap-instance | Storing a Run's items, from the first item to the end of the stream, a child of Runtime.run. Carries scwrap.store.items, scwrap.store.chunks, and scwrap.store.item_write_ms and scwrap.store.metadata_write_ms, the totals over every chunk. |
Runtime.writeChunk, Runtime.writeMetadata | scwrap-instance | The two R2 writes of one chunk of up to 100 items, children of Runtime.storeItems with scwrap.chunk.index. The last chunk has no Runtime.writeMetadata: Runtime.storeResult records it. Only the first 10 chunks get them; the totals cover the rest. |
Runtime.storeResult | scwrap-instance | The final write of the result record. |
Sandbox.run | scwrap-instance | A Release in its own sandbox running one Run, a child of Runtime.run, with scwrap.result.id (Spans from a Release's sandbox). |
Scraper.run and below | scwrap-instance | The Release's own spans below Sandbox.run: every Effect.fn step, Download.*, Browser, proxy and captcha spans, with their annotations. |
Every span comes from scwrap-instance.
The trace ID does not leave the instance. Requests a Scraper sends to the sites it scrapes carry no traceparent or b3 header.
Each Run has its own trace
An MCP request's tool call, and with it Runtime.trigger, joins the trace of the caller's traceparent header when it sends one; an HTTP request's Runtime.fetch starts a trace of its own. The Run itself starts a new trace at Runtime.start, which carries a span link to Runtime.trigger. So Runs started in parallel by one client program, under one caller trace, each get their own traceId and traceUrl, and the backend still leads from a Run's trace to the request that started it.
Spans from a Release's sandbox
A Release in its own sandbox holds no traces credential. While the instance exports traces, its env gets TRACES, a stub of the release Worker's Traces entrypoint, and TRACES_PROTOCOL. The sandbox's own OtlpTracer sends its spans to that stub, and the entrypoint posts them to SCWRAP_INSTANCE_TRACES_URL with the instance's headers and token, whatever address and headers the sandbox used. The Run owner hands the sandbox its Runtime.run span as a traceparent, so the sandbox's Sandbox.run span and the Scraper's steps below it belong to the Run's trace.
The sandbox exports every 5 seconds and once more when its Run ends. An instance without a traces endpoint gives the sandbox no TRACES, and the sandbox exports nothing (Known gaps).
Linking a record to its trace
While an instance exports traces, every result record carries traceId, the Run's 32-hex OTLP trace ID, set when the Run starts and kept in every later write of the record. With SCWRAP_INSTANCE_TRACES_LINK set, it also carries traceUrl, the template with {traceId} replaced. Production's traceUrl opens the Run's trace in Axiom's trace view.
An instance that exports no traces writes neither field, so a record never names a trace that went nowhere. Records written before the fields existed have neither.
Finding a Run's trace
Open the record's traceUrl, or search the backend for its traceId. Without a traceId, find the trace by its resultId, the scwrap.result.id attribute. In Axiom, query the dataset:
['scwrap-traces-production']
| where ['attributes.custom']['scwrap.result.id'] == "<resultId>"
| project trace_idOpen the trace ID in Axiom's trace view to see the whole Run, or list its spans:
['scwrap-traces-production']
| where trace_id == "<trace_id>"
| project _time, ['service.name'], name, span_id, parent_span_id, durationThe record's startedAt and endedAt bound the time range to search. A Run's trace reads Runtime.start → Runtime.run, with the Run's storage spans and, for a Release in its own sandbox, Sandbox.run with the Scraper's steps below Runtime.run.
Finding why a Release was unavailable
A 503 release_unavailable answers a Run before it has a record. Its reason code, such as artifact_read_failed, names the kind of failure; for the full message, search for the failing Runtime.release spans in the time range of the 503s. In Axiom:
['scwrap-traces-production']
| where name == "Runtime.release" and isnotempty(['attributes.custom']['scwrap.release.unavailable'])
| project _time, trace_id, ['attributes.custom']['scwrap.scraper'], ['attributes.custom']['scwrap.release.unavailable']Axiom Runs dashboard
For an instance that exports to Axiom, a separate, optional Alchemy Stack, ScwrapTracesDashboard in apps/infra/alchemy.traces-dashboard.ts, keeps a dashboard named Scwrap Runs (<stage>) as code. Instances without Axiom never run it, and the instance Stack does not depend on it. Over the last 7 days by default, it shows:
- the number of Runs, failed Runs and unavailable Release answers;
- Runs over time by
scwrap.run.status, and the p50 and p95 Run duration; - each Scraper's Runs, failures, items stored, duration and last Run;
- failures by Scraper and
scwrap.run.error_tag; - unavailable Releases by Scraper, revision and reason, from the
Runtime.releasespans.
It reads the dataset scwrap-traces-<stage>, or SCWRAP_TRACES_AXIOM_DATASET when that is set. Its Alchemy state sits next to the instance's, so it runs with the instance's Cloudflare credentials, plus AXIOM_TOKEN, an Axiom API token that can create, read, update and delete dashboards (not the instance's ingest token):
AXIOM_TOKEN=<dashboard token> pnpm infra:traces-dashboard:plan --stage <stage>
AXIOM_TOKEN=<dashboard token> pnpm infra:traces-dashboard:deploy --stage <stage>Applying it again updates the dashboard in place; destroying the Stack deletes it. Edit the charts in apps/infra/src/traces-dashboard.ts; each is an APL query, so a chart you prototype in Axiom's query editor copies over as is. Production's CI deploy does not apply this Stack.
How it is wired
- The Worker builds an
OtlpTracerfromeffect/observabilityfor each request, with the JSON or protobuf serializer, and flushes it withwaitUntilafter the response, so export never delays a caller. - The Stack turns the URL, protocol and link into the Worker's
TRACES_URL,TRACES_PROTOCOL(only forhttp/protobuf) andTRACES_LINKplain-text bindings. WithoutSCWRAP_INSTANCE_TRACES_URLit adds no tracing binding at all. TRACES_HEADERSandTRACES_TOKENare Secrets Store secrets,scwrap-instance-<stage>-traces-headersandscwrap-instance-<stage>-traces-token, which the Stack writes from their variables. Applying the Stack with a new value updates them in place. When a binding exists but its secret cannot be read, the Worker exports nothing for that request rather than sending spans without credentials.
Keeping secrets out
Spans are exported as recorded. Never put a credential in a span name, a span attribute or an error message, and hold credentials as Redacted. HTTP client spans record no headers unless a Scraper opts in, and Effect redacts authorization and similar headers when it does.
The backend's access controls decide who can read the traces; a traceUrl is only a link.
Source
- tracing.ts: the OTLP exporter, the sandbox's exporter and the front desk's forwarding
- release-sandbox.ts: the sandbox's
Sandbox.runspan - runtime-entry.ts: the Worker's per-request tracer, the Run owner's tracer and the
Tracesentrypoint - instance-traces.ts: the checks on the tracing variables
- instance-secret.ts: the headers' and token's Secrets Store secrets
- alchemy.traces-dashboard.ts and traces-dashboard.ts: the Axiom Runs dashboard