Skip to content

Runtime model

Layeron treats an observability stream as part of the app model.

Terminal window
observability(...)
-> app.use(...)
-> AppSpec
-> RuntimeTopology
-> Worker observability settings
-> runtime sink

The declaration starts in application code. Layeron records it in the app spec and includes it in the compiled runtime plan.

Layeron attaches the stream before route handlers run.

After attachment, route code can call methods such as increment(...), timing(...), event(...), and capture(...).

A route that calls the stream before runtime attachment receives an observability runtime is not attached error.

span(...) emits a span record after the callback finishes.

Nested spans receive a parentSpanId. Failed spans use outcome error and also capture the thrown error.

The current Cloudflare target uses Cloudflare Workers Logs as the sink.

Layeron enables Worker observability settings during compile and deploy when an app or product declares observability.

Tests can provide an observabilitySink and inspect emitted records directly.

Use this for unit tests that need to verify counters, events, signals, timings, or captured errors.