Skip to content

Core concepts

Observability has four concepts: stream identity, records, context, and attributes.

Every stream uses Layeron’s platform namespace/name identity:

Terminal window
const runtime = observability({
namespace: "api",
name: "runtime",
})

The example identity is api/runtime. See Namespaces for platform namespace defaults and naming rules.

Examples:

NamespaceNameGood For
apiruntimeRoute counts, latency, and errors.
apidatabaseQuery latency and database events.
webhooksstripeDelivery attempts, retries, and replay events.
jobsemailQueue depth, job duration, and failures.

A record is one emitted observability fact.

Examples:

  • A counter named posts.list.requests.
  • A timing named posts.list.duration_ms.
  • An event named posts.created.
  • An error captured from a failed handler.

Layeron adds context when it is available:

  • projectId
  • environmentId
  • deploymentId
  • requestId
  • traceId
  • moduleId
  • routeId
  • resourceLogicalId

Context helps connect a record to the request, route, module, environment, or deployment that produced it.

Attributes are extra fields that you pass with a record:

Terminal window
runtime.increment("webhooks.stripe.deliveries", 1, {
provider: "stripe",
route: "/webhooks/stripe",
})

Use attributes for values that make filtering useful, such as route, provider, tenant, status, shard, or queue name.

The current sink is worker_logs.

It emits structured records through Cloudflare Workers Logs.