On this page
Observability
For maintainers. Using Ozone? See docs/user.
Ozone has one server-side observability model:
- pretty logs go to stdout for humans
- completed spans go to a local NDJSON trace file
- traces, metrics, and logs can also be exported over OTLP to a real backend like Grafana LGTM
The local trace file is the persisted source of truth for normal local launches. Those launches do not
write a separate server log file, but SSH-managed launches also persist the remote process's
stdout/stderr at ~/.ozone/ssh-launch/<state>/server.log. Each managed launch starts that file
empty, so it holds only the latest launch's output.
Where To Find Things
Logs
Logs are human-facing:
- destination: stdout
- format:
Logger.consolePretty() - normal local persistence: none
- SSH-managed launch persistence:
~/.ozone/ssh-launch/<state>/server.log - remote export: OTLP only, when configured
If you want a log message to show up in the trace file, emit it inside an active span with Effect.log.... Logger.tracerLogger will attach it as a span event.
Configuring a logs endpoint takes over that job. The server then exports log records, which cover
every message instead of only the ones inside an active span and carry the trace and span ids so
they still line up with the trace. Logger.tracerLogger is dropped in that mode, so the same
message is not exported twice and the trace file stops carrying log messages. stdout output and
SSH-managed launch persistence stay unchanged either way.
Traces
Completed spans are written as NDJSON records to serverTracePath. The default depends on how the
server starts: production and explicitly configured homes use
<home>/userdata/logs/server.trace.ndjson (so ~/.ozone/userdata/... by default, or
/custom/path/userdata/... with --home-dir /custom/path), a linked worktree dev run uses
<worktree>/.t3/userdata/logs/server.trace.ndjson, and an implicit dev run outside a linked
worktree uses ~/.ozone/dev/logs/server.trace.ndjson.
Important fields common to both record types:
type:effect-spanorotlp-spanname: span nametraceId,spanId,parentSpanId: correlationdurationMs: elapsed timeattributes: structured contextevents: embedded logs and custom events
effect-span records also contain exit with Success, Failure, or Interrupted. otlp-span
records instead carry OTLP resource, scope, and optional status fields.
The TraceRecord, EffectTraceRecord, and OtlpTraceRecord schemas live in
packages/shared/src/observability.ts.
SQL statement spans (named sqlite) and sql.transaction spans carry db.connection and
db.lock_wait_ms. db.connection is writer for the read-write connection or reader for a
read-only one. For a database file both run in worker threads; an in-memory database has only a
writer, on the event loop. db.lock_wait_ms is the part of the
span spent waiting for that connection, behind other SQL. That wait does not block the event loop,
so subtract it before you blame a slow span on the query. Statements inside a transaction use its
connection and do not carry these attributes.
An MCP request over HTTP has a McpHttpServer.authenticateRequest span that covers only admitting
it: the credential check, the mode limit, and the Linked environments gate. The request runs after
it, under the McpServer.…/<method> span, and each tool call has its own mcp.tool.<name> span
that times it. That span's attributes name the tool, never its arguments.
DPoP proof failures include the safe environment.dpop.failure_code span
attribute. A time_window failure means that a signed proof was too old or too
far in the future for the environment server's allowed window. It can point to
a date or time problem on either device, but it can also result from a delayed
request.
Summarize the trace file
ozone trace summary reads the trace file and its rotated backups directly, so it works while the
server is stalled or stopped. It prints counts, rates, and latency percentiles per span name. Use
it to measure background work or to compare two builds.
Could not copy. Select the text instead.
ozone trace summary --since 30m --limit 40It reads OZONE_TRACE_FILE if set, else <home>/userdata/logs/server.trace.ndjson for
--base-dir or OZONE_HOME, plus the OZONE_TRACE_MAX_FILES rotated backups. For a dev run or
a copied file, set OZONE_TRACE_FILE. --since 30m keeps spans that ended in the last 30
minutes. The rate is per minute between the first and last span end.
Metrics
Metrics are not written to a local file.
- local persistence: none
- remote export: OTLP only, when configured
- current definitions:
apps/server/src/observability/Metrics.ts
If OTLP is not configured, metrics still exist in-process, but you will not have a local artifact to inspect.
Event Loop Stalls
apps/server/src/observability/EventLoopMonitor.ts samples the server's event loop every 30 s. When
the loop stalled for more than 2 s since the previous sample, it records a root
server.eventLoop.stall span with a warning. The span has trace level Warn, so it stays when
OZONE_TRACE_MIN_LEVEL is Warn. The warning shows in Settings > Diagnostics unless OTLP logs are
on. The span time is when the sample ran, not when the stall happened.
The trace file rotates in well under an hour on a busy server, so each stall is also appended as one
NDJSON line to event-loop-stalls.ndjson, next to the trace file. A line has time and the span
attributes. The file keeps the last 1000 or more stalls, with one rotated backup
(event-loop-stalls.ndjson.1). Use it to see how often a server stalls over days.
Some delay is not recorded:
delayMaxMsis the longest stall, and can undercount it by up to 1 s. The 2 s threshold applies to this value, so a stall over 3 s is normally recorded, and a shorter one can be missed. A stall that ends just as a sample runs can be missed too.- Time the computer spends asleep reads as delay on macOS and Windows. So a sample only counts when
the loop was busy, not waiting for events, for at least
delayMaxMs. Busy time covers the whole window, so a short sleep in an otherwise busy window can still record a false stall. The span then shows CPU time far belowdelayMaxMs. - The first sample after launch is skipped. Startup work such as migrations and projection bootstrap can block the loop for seconds on a large database.
CPU times and page faults cover the whole process over the whole window since the previous sample.
The window is nominally 30 s, but a long stall delays the sample and makes the window longer. Other
work in the window can hide a wait, so only CPU time far below delayMaxMs proves the thread was
waiting. Read CPU together with page faults:
- High
cpuSystemMswith many page faults means memory pressure. Major faults are reads from disk or swap. On macOS, reads from compressed memory are minor faults plus system CPU. - High
cpuUserMswith few page faults means JavaScript work or garbage collection. - Low CPU with few major page faults points at synchronous disk I/O, such as SQLite reads or trace file writes.
- Many
involuntaryContextSwitchesmean other processes were competing for the CPU.
Related Artifacts
Provider event NDJSON files still exist for provider runtime streams. Those are separate from the main server trace file.
Run The Server In Instrumented Mode
There are two useful modes:
- local-only: stdout + local
server.trace.ndjson - full local observability: stdout + local trace file + OTLP export to Grafana/Tempo/Prometheus
The local trace file is always on. OTLP export is opt-in.
Option 1: Local Traces Only
You do not need any extra env vars. Just run the app normally and inspect server.trace.ndjson.
Examples:
Could not copy. Select the text instead.
ozoneCould not copy. Select the text instead.
vp run devCould not copy. Select the text instead.
vp run dev:desktopOption 2: Run With A Local LGTM Stack
1. Start Grafana LGTM
Could not copy. Select the text instead.
docker run --name lgtm \
-p 3000:3000 \
-p 4317:4317 \
-p 4318:4318 \
--rm -ti \
grafana/otel-lgtmThen open http://localhost:3000.
Default Grafana login:
- username:
admin - password:
admin
2. Export OTLP env vars
For endpoint settings and startup precedence, see the
diagnostics export guide.
In a worktree, use vp run dev instead of ozone to keep state isolated.
Could not copy. Select the text instead.
export OZONE_OTLP_TRACES_URL=http://localhost:4318/v1/traces
export OZONE_OTLP_METRICS_URL=http://localhost:4318/v1/metrics
export OZONE_OTLP_LOGS_URL=http://localhost:4318/v1/logs
export OTEL_RESOURCE_ATTRIBUTES=deployment.environment.name=developmentOptional:
Could not copy. Select the text instead.
export OZONE_TRACE_MIN_LEVEL=Info
export OZONE_TRACE_TIMING_ENABLED=true3. Launch the app from that same shell
CLI:
Could not copy. Select the text instead.
ozoneMonorepo web/server dev:
Could not copy. Select the text instead.
vp run devMonorepo desktop dev:
Could not copy. Select the text instead.
vp run dev:desktopPackaged desktop app:
Launch the actual app executable from the same shell so the desktop app and embedded backend inherit OZONE_OTLP_*.
macOS app bundle example:
Could not copy. Select the text instead.
OZONE_OTLP_TRACES_URL=http://localhost:4318/v1/traces \
OZONE_OTLP_METRICS_URL=http://localhost:4318/v1/metrics \
OZONE_OTLP_LOGS_URL=http://localhost:4318/v1/logs \
"/Applications/Ozone.app/Contents/MacOS/Ozone"Direct binary example:
Could not copy. Select the text instead.
OZONE_OTLP_TRACES_URL=http://localhost:4318/v1/traces \
OZONE_OTLP_METRICS_URL=http://localhost:4318/v1/metrics \
OZONE_OTLP_LOGS_URL=http://localhost:4318/v1/logs \
./path/to/your/desktop-app-binaryDo not rely on launching from Finder, Spotlight, the dock, or the Start menu after setting shell env vars. Those launches usually will not pick them up.
4. Fully restart after changing env
The backend reads observability config at process start. If you change OTLP env vars, stop the app completely and start it again.
How To Use Traces And Metrics To Debug The Server
Start With The Local Trace File
The trace file is the fastest way to inspect raw span data.
Resolve the path for the launch mode once. Production and explicitly configured homes store runtime
state under the base directory's userdata folder:
Could not copy. Select the text instead.
TRACE_FILE="${OZONE_HOME:-$HOME/.ozone}/userdata/logs/server.trace.ndjson"A dev server started from a linked worktree defaults to that worktree's local home:
Could not copy. Select the text instead.
TRACE_FILE="$WORKTREE/.t3/userdata/logs/server.trace.ndjson"Only an implicit dev run outside a linked worktree uses the shared dev directory:
Could not copy. Select the text instead.
TRACE_FILE="$HOME/.ozone/dev/logs/server.trace.ndjson"Tail the selected file:
Could not copy. Select the text instead.
tail -f "$TRACE_FILE"Show failed spans:
Could not copy. Select the text instead.
jq -c 'select(.type == "effect-span" and .exit._tag != "Success") | {
name,
durationMs,
exit,
attributes
}' "$TRACE_FILE"Show slow spans:
Could not copy. Select the text instead.
jq -c 'select(.durationMs > 1000) | {
name,
durationMs,
traceId,
spanId
}' "$TRACE_FILE"Inspect embedded log events:
Could not copy. Select the text instead.
jq -c 'select(any(.events[]?; .attributes["effect.logLevel"] != null)) | {
name,
durationMs,
events: [
.events[]
| select(.attributes["effect.logLevel"] != null)
| {
message: .name,
level: .attributes["effect.logLevel"]
}
]
}' "$TRACE_FILE"Follow one trace:
Could not copy. Select the text instead.
jq -r 'select(.traceId == "TRACE_ID_HERE") | [
.name,
.spanId,
(.parentSpanId // "-"),
.durationMs
] | @tsv' "$TRACE_FILE"Filter orchestration commands:
Could not copy. Select the text instead.
jq -c 'select(.attributes["orchestration_v2.command_type"] != null) | {
name,
durationMs,
commandType: .attributes["orchestration_v2.command_type"],
threadId: .attributes["orchestration_v2.thread_id"]
}' "$TRACE_FILE"Filter git activity:
Could not copy. Select the text instead.
jq -c 'select(.attributes["git.operation"] != null) | {
name,
durationMs,
operation: .attributes["git.operation"],
cwd: .attributes["git.cwd"],
hookEvents: [
.events[]
| select(.name == "git.hook.started" or .name == "git.hook.finished")
]
}' "$TRACE_FILE"Use Tempo When You Need A Real Trace Viewer
Tempo is better than raw NDJSON when you want to:
- search across many traces
- inspect parent/child relationships visually
- compare many slow traces
- drill into one failing request without hand-joining by
traceId
Recommended flow in Grafana:
- Open
Explore. - Pick the
Tempodata source. - Set the time range to something recent like
Last 15 minutes. - Start broad. Do not begin with a very narrow query.
- Look for spans from the
t3code-serverort3code-desktopservice, then narrow by span name or attributes.
Good first searches:
- service name
t3code-serverort3code-desktop, plus a resource attribute such asdeployment.environment.name - span names like
sendTurnor a Git operation such asGitVcsDriver.statusDetails.status - Git spans whose
git.operationattribute identifies the operation - orchestration spans with attributes like
orchestration_v2.command_type
Once you know traces are arriving, narrower TraceQL queries for names such as sendTurn or Git
operation names become useful.
Use Metrics To See Systemic Problems
Traces are best for one request. Metrics are best for trends.
Good metric families to watch:
t3_rpc_request_durationt3_orchestration_command_durationt3_provider_turn_duration(how long the provider adapter takes to start a turn, not the turn's run time)t3_git_command_duration
Counters tell you volume and failure rate:
t3_rpc_requests_totalt3_orchestration_commands_totalt3_provider_turns_totalt3_git_commands_total
Webhooks have their own families:
-
t3_webhook_deliveries_totalbyoutcome. Beyond what the sender sees,queue_fullmeans a task already had its limit of deliveries waiting, andprompt_too_longmeans the filled-in prompt passed the provider limit. -
t3_webhook_runs_totalbyoutcome(started,skipped,failed) for the runs those deliveries start, which happen after the sender has its answer. -
t3_secret_requests_totalbystatus(saved,declined,cancelled,timed_out) for secrets agents asked users for, andt3_secret_refs_consumed_totalbyresult(used,rejected) for tools redeeming them. Neither ever carries a value.
ScheduledTaskService.triggerWebhook spans carry the same outcome per request, and each run
started from a delivery is its own ScheduledTaskService.runWebhookDelivery trace. A request
never joins its sender's trace.
Use metrics when the question is:
- "is this always slow?"
- "did this get worse after a change?"
- "which command type is failing most often?"
Use traces when the question is:
- "what happened in this specific request?"
- "which child span caused this one slow interaction?"
- "what logs were emitted inside the failing flow?"
Common Workflows
"Why did this request fail?"
- Start with the local NDJSON file.
- Find
effect-spanrecords whereexit._tag != "Success". - Group by
traceId. - Inspect sibling spans and span events.
- If needed, move to Tempo for the full trace tree.
"Why is the UI feeling slow?"
- Search for slow top-level spans in the trace file or Tempo.
- Check child spans for sqlite, git, provider, or terminal work.
- Look at the matching duration metrics to see whether the slowness is systemic.
"Are git hooks causing latency?"
- Filter
git.operationspans. - Inspect
git.hook.startedandgit.hook.finishedevents. - Compare hook timing to the enclosing git span duration.
"Why do I have spans locally but nothing in Grafana?"
Usually one of these is true:
OZONE_OTLP_TRACES_URLwas not set- the app was launched from a different environment than the one where you exported the vars
- the app was not fully restarted after changing env
- Grafana is looking at the wrong time range or service name
If the local NDJSON file is updating, local tracing is working. The problem is almost always OTLP export configuration or process startup.
How To Think About Adding Tracing To Future Code
Prefer Boundaries Over Tiny Helpers
Good span boundaries:
- RPC methods
- orchestration command handling
- provider adapter calls
- external process calls
- persistence writes
- queue handoffs
Avoid tracing every tiny helper. Most helpers should inherit the active span rather than create a new one.
Reuse Effect.fn(...) Where It Already Exists
The codebase already uses Effect.fn("name") heavily. That should usually be your first tracing boundary.
For ad hoc work:
Could not copy. Select the text instead.
import { Effect } from "effect";
const runThing = Effect.gen(function* () {
yield* Effect.annotateCurrentSpan({
"thing.id": "abc123",
"thing.kind": "example",
});
yield* Effect.logInfo("starting thing");
return yield* doWork();
}).pipe(Effect.withSpan("thing.run"));Put High-Cardinality Detail On Spans
Use span annotations for IDs, paths, and other detailed context:
Could not copy. Select the text instead.
yield *
Effect.annotateCurrentSpan({
"provider.thread_id": input.threadId,
"provider.request_id": input.requestId,
"git.cwd": input.cwd,
});Keep Metric Labels Low Cardinality
Good metric labels:
- operation kind
- method name
- provider kind
- aggregate kind
- outcome
Bad metric labels:
- raw thread IDs
- command IDs
- file paths
- cwd
- full prompts
- full model strings when a normalized family label would do
Detailed context belongs on spans, not metrics.
Use Logs As Span Events
Logs inside a span become part of the trace story:
Could not copy. Select the text instead.
yield * Effect.logInfo("starting provider turn");
yield * Effect.logDebug("waiting for approval response");Those messages show up as span events because Logger.tracerLogger is installed.
Use The Pipeable Metrics API
withMetrics(...) is the default way to attach a counter and timer to an effect:
Could not copy. Select the text instead.
import { someCounter, someDuration, withMetrics } from "../observability/Metrics.ts";
const program = doWork().pipe(
withMetrics({
counter: someCounter,
timer: someDuration,
attributes: {
operation: "work",
},
}),
);Detailed API Reference
Runtime Wiring
The server observability layer is assembled in apps/server/src/observability/Observability.ts.
It provides:
- pretty stdout logger
Logger.tracerLogger- local NDJSON tracer
- optional OTLP trace exporter
- optional OTLP metrics exporter
- optional OTLP log exporter
- Effect trace-level and timing refs
The desktop main process is a second producer, assembled in
apps/desktop/src/app/DesktopObservability.ts. It reads the same OZONE_OTLP_* names and the same
Settings entries as the backend it supervises, and covers work the backend cannot see: app startup,
window and menu handling, backend supervision, and updates. It reports as service
t3code-desktop, so a collector shows it alongside the backend rather than mixed into it. It
exports traces and logs only; the main process records no metrics, so the metrics endpoint applies
to the backend alone.
Env Vars
Local trace file:
OZONE_TRACE_FILE: override trace file pathOZONE_TRACE_MAX_BYTES: per-file rotation size, default10485760OZONE_TRACE_MAX_FILES: rotated file count, default10OZONE_TRACE_BATCH_WINDOW_MS: flush window, default1000OZONE_TRACE_MIN_LEVEL: minimum trace level, defaultInfoOZONE_TRACE_TIMING_ENABLED: enable timing metadata, defaulttrue
OTLP export:
OZONE_OTLP_TRACES_URL: OTLP trace endpointOZONE_OTLP_METRICS_URL: OTLP metric endpointOZONE_OTLP_LOGS_URL: OTLP log endpointOZONE_OTLP_EXPORT_INTERVAL_MS: export interval, default10000OZONE_OTLP_HEADERS: extra headers for all three exporters, same format asOTEL_EXPORTER_OTLP_HEADERS: comma-separatedkey=valuepairs with percent-encoded values.OZONE_OTLP_PROTOCOL:http/json(default) orhttp/protobuf
The server and the desktop app also read the standard
OTEL_EXPORTER_OTLP_{TRACES,METRICS,LOGS}_ENDPOINT and generic OTEL_EXPORTER_OTLP_ENDPOINT (with
/v1/traces, /v1/metrics, or /v1/logs appended), for a collector expecting those instead. A
non-blank OZONE_OTLP_*_URL wins over either, and a per-signal endpoint wins over the generic one
for its signal. A blank value counts as unset. A signal with an OTEL endpoint takes its headers from
OTEL_EXPORTER_OTLP_HEADERS and its protocol from OTEL_EXPORTER_OTLP_PROTOCOL (default
http/protobuf, read case-insensitively), and a per-signal
OTEL_EXPORTER_OTLP_{TRACES,METRICS,LOGS}_HEADERS or _PROTOCOL wins over the generic one for its
signal. OZONE_OTLP_HEADERS and OZONE_OTLP_PROTOCOL never apply to it. An endpoint that is not
an http or https URL, a protocol other than http/protobuf or http/json such as grpc, or
headers that are not key=value pairs with percent-encoded values turn that signal's export off
with a startup warning, rather than sending it to the Settings endpoint.
Service names are fixed: t3code-server for the backend and t3code-desktop for the desktop main
process, both in service.namespace t3code. OTEL_SERVICE_NAME and a service.name or
service.namespace in OTEL_RESOURCE_ATTRIBUTES are ignored. Tell installations apart with other
resource attributes, such as OTEL_RESOURCE_ATTRIBUTES=deployment.environment.name=staging.
Each process reports its own build, not the one it talks to: the server, the desktop main process
and the UI each carry t3code.release.channel and deployment.environment.name. The channel is
dev or stable. The desktop process and the UI report dev in a development build and stable
otherwise. The server's is set when it is built, by OZONE_TELEMETRY_CHANNEL: the release
workflow builds it as stable, and any other build reports dev. On the server and the
desktop main process either key in OTEL_RESOURCE_ATTRIBUTES wins. The UI never reads that
variable.
Attributes specific to Ozone use the t3code. prefix. The UI runs as t3code-web in both a
browser and the desktop window, since it is the same code, and t3code.client.surface is desktop
or web. The server's t3code.server.managed_by is desktop when the desktop app launched it and
standalone otherwise. The desktop main process reports t3code.desktop.mode as development or
packaged. Node processes
also report the semantic process.runtime.name, process.runtime.version, and
process.runtime.description, and UI traces report browser.language, user_agent.original, and,
in Chromium, browser.platform, browser.mobile, and browser.brands.
Every resource also carries a service.instance.id: random per process for the server and desktop,
and per page load for the UI. A service.instance.id in
OTEL_RESOURCE_ATTRIBUTES replaces the generated one on the server and desktop.
If the OTLP URLs are unset, local tracing still works, metrics stay in-process only, and logs stay on stdout only.
The Kill Switch
OZONE_OTEL_SDK_DISABLED and OTEL_SDK_DISABLED turn off every OTLP export in both the server and
the desktop main process, overriding any endpoint from the environment or Settings. Local trace
files and stdout logs are unaffected.
OZONE_OTEL_SDK_DISABLED wins when set, so OZONE_OTEL_SDK_DISABLED=false re-enables export on a
machine that sets OTEL_SDK_DISABLED for everything else. It accepts the usual boolean spellings
(true/false, yes/no, on/off, 1/0, y/n). OTEL_SDK_DISABLED follows the
OpenTelemetry specification and only true disables export, so OTEL_SDK_DISABLED=1 does not.
Values are case-insensitive and trimmed. An unrecognized value is ignored with a startup warning.
OTEL_TRACES_EXPORTER, OTEL_METRICS_EXPORTER, or OTEL_LOGS_EXPORTER set to none turns off
just that signal, overriding an OTEL endpoint and the Settings endpoint. A OZONE_OTLP_*_URL still
wins for its signal. otlp is the default, and any other exporter name, such as console or
prometheus, is ignored with a startup warning.
What Is Instrumented Today
Current high-value span and metric boundaries include:
- WebSocket RPC request spans (
ws.rpc.<method>) and metrics inapps/server/src/observability/RpcInstrumentation.ts - startup phases
- orchestration command processing
- provider session and turn operations
- git command execution and git hook events
- terminal session lifecycle
- sqlite query execution, except the statements inside
orchestrationV2.EventSink.write, which itssql.transactionspan times as one - event loop stalls (
server.eventLoop.stall)
Current Constraints
- logs outside spans are not persisted in the trace file; SSH-managed launch stdout/stderr is still captured in its launcher log
- metrics are not snapshotted locally
Heap Snapshots
To see what a long-running server holds in memory, send it SIGUSR2. The server writes a V8 heap
snapshot to its logs dir and logs the path. This works for desktop, ozone, and service installs
on macOS and Linux. Windows has no SIGUSR2.
Send the signal to the server pid in server-runtime.json, which sits in the server's state dir
next to the logs dir. For a dev server or a --home-dir launch, use that server's state dir from
Traces. Do not send it to the desktop app or the service launcher: a process without the
handler exits on SIGUSR2. After a crash the file can keep a stale pid that now belongs to a
different process, so check the pid first.
Could not copy. Select the text instead.
pid="$(jq .pid "${OZONE_HOME:-$HOME/.ozone}/userdata/server-runtime.json")"
ps -p "$pid" -o command=If ps shows the Ozone server, send the signal:
Could not copy. Select the text instead.
kill -USR2 "$pid"The file is <logsDir>/server-<pid>-<timestamp>.heapsnapshot, next to server.trace.ndjson. To
open it, use the Memory tab in Chrome DevTools and select Load.
Before you take one:
- The server stops while it writes the file. For a large heap this can take a minute or more. Connected clients can reconnect during the pause, and an event loop monitor, if the server has one, records the pause as a stall. Send the signal once. A second signal sent during a write takes another snapshot after the first one finishes.
- The write needs about as much free memory as the heap uses. On a machine that is already swapping, it can make the problem worse or crash the server.
- The file contains everything in server memory, including tokens, secrets, and thread content. Do not share it publicly. Delete it when you are done, because storage cleanup does not remove it.