Skip to main content
Ask your AI

Observe

Observe is the collector's reporter. Give it an endpoint and a token, or run it under a paired runner that signs the reports, and a running flow sends what it did: counters and issues of the whole runtime, and optionally one row for every event and every destination outcome. It adds no step to the flow and never holds an event back.

"collector": {
  "observe": {
    "usage": {
      "url": "https://ingest.example.com/usage",
      "token": "$secret.USAGE_TOKEN"
    }
  }
}

You can verify a flow at three levels, each one step closer to production:

  1. Simulate: run an event through the built flow offline, with destinations mocked, see bundled mode.
  2. Run locally: run the flow where your app runs and watch each event in your console, see integrated mode.
  3. Observe: let a running flow report to an endpoint, so you see what it delivered, what failed and why.

This page covers the third rung.

Options​

collector.observe in a flow file, or observe in startFlow, takes two parts. Both are optional, and each posts to its own endpoint.

PartWhat it sendsOptions
usageCounters, gauges and issues of this runtime, every intervalurl, token, interval
previewOne row per event and one per destination outcome, as they happenurl, token
  • url is an absolute http or https URL, or a $env. or $var. reference to one. In a server bundle, $env.NAME becomes a read of process.env.NAME (with its :default, if any) when the bundle loads, and $secret.NAME a read of the secret's environment variable at the same point. The CLI's preview build needs the literal URL.
  • token is sent as Authorization: Bearer <token>. In a server flow, back it with a managed secret ($secret.NAME) instead of writing it into the file. The usage part may leave it out when a paired runner signs its reports (see Signed by a paired runner); the preview part always needs it.
  • interval is a whole number of seconds from 10 to 300, default 60.

Every other key fails walkeros validate at its path. Without options, nothing runs: no timer, no buffer, no observer, no request.

At runtime a part that fails its check logs one ERROR line naming the key path and the value as written (never the token), does no work, and the flow runs on:

Invalid observe option at observe.usage.interval: 5 is not a whole number of seconds from 10 to 300; usage not started

In startFlow the same options read:

import { startFlow } from '@walkeros/collector';

const { elb } = await startFlow({
  observe: {
    usage: {
      url: 'https://ingest.example.com/usage',
      token: process.env.USAGE_TOKEN,
      interval: 30,
    },
  },
  // ...your sources and destinations
});

Outside the CLI, no build flag is defined, so the reporter runs wherever observe is passed.

What a report holds​

Each report is a set of rows, posted as NDJSON (Content-Type: application/x-ndjson), one JSON object per line. A body holds at most 60,000 bytes, and a larger report goes out in several requests. Requests carry no cookies and no referrer, and wait at most 10 seconds for an answer.

Usage rows​

A usage report goes out when the collector starts, then every interval, soon after a new kind of issue first appears, and once more when the collector shuts down. Every row carries instance (16 hex characters naming this process), seq (1 for the first report of the instance, one more for each report), final (1 on the report at shutdown), interval_s, release, part (the collector's name, else default) and reported_at.

Counters are cumulative since the collector started (the runtime counters since their host started), so a lost or repeated report changes nothing about the totals. A counter at 0 is left out, except collector.in, which every report carries. Gauges go in every report, zero included.

stepmetric
collectorin, out, failed
a drop positiondropped_consent, dropped_ignored, dropped_stopped, dropped_queue, dropped_dlq
source.<id>count, rejected
destination.<id>delivered, failed, skipped_consent, skipped_ignored, duration_ms, latency_ms_le_<bound>
destination.<id>gauges: queue, dlq, in_flight
a step with a breakergauge: breaker_open (1 or 0)
a stepconnection_errors
runtimecpu_ms, loop_delay_ms, loop_samples
runtimegauges: memory_bytes, memory_limit_bytes
the step that failedissue, with code, status, retryable, a masked message and the count in value

latency_ms_le_<bound> is one count per delivery or batch flush that took at most <bound> milliseconds, for the bounds 5, 10, 25, 50, 100, 250, 500, 1000, 2500, 5000 and 10000, plus latency_ms_le_inf above the last. @walkeros/core exports them as LATENCY_BOUNDS_MS.

The runtime rows describe the process that runs the collector, and only a host fills them: runneros measures its process every 10 seconds (resident memory against the memory it may use, CPU time, and event loop delay with its sample count). A web page, and a collector started without such a host, send none.

Every issue the collector holds goes in every report, one row per step, code and status. Each is a line the logger writes at most once a minute, so a failing destination is one row, not one per event.

Preview rows​

A preview row says what happened to one event. Every row carries instance, seq, release, part and reported_at. The seq counts rows from 1, so a gap is a lost row: the buffer holds 500 rows, and a full buffer drops the oldest.

An event row (kind: "event") comes from the collector's own record of the push: event_id, trace_id, name, source, timestamp, the event as payload, an outcome and the list of outcomes.

outcomeMeaning
doneEvery destination delivered the event
queuedThe event waits: for consent, for a batch, or for run or a page leave
failedA destination or the collector failed it
skippedA consent skip, a rule ignore or a drop; never a delivery or a failure

Each element of outcomes holds destination, phase, outcome, code, status, message (masked), mapping_key and ms. An element with destination: "" is the collector's own: a drop, a failed push, or why an event waits (run, page-leave).

An outcome row (kind: "outcome") follows each destination's own result, flush, error or skip, with the same event_id and one element in outcomes. It carries no payload. An error row carries no name, since only the first record of an event holds the event.

Rows go out in batches of up to 100, or after 2 seconds, whichever comes first.

What stays out of a row​

Every message the reporter sends passes one mask, in this order:

  1. the secret values the host knows (a server flow's $secret values),
  2. patterns for credentials in text: keys, tokens, short Bearer and Basic credentials and private keys,
  3. every token that starts with wos_,
  4. a cut at 256 characters.

The masking applies to issue messages and to every outcomes[].message. The event payload is the event itself: what a flow redacts before its destinations is redacted there too, so mask personal data in the flow, not in the reporter. Tokens never reach collector.config or a log line.

A host that builds its own logger passes a mask for this. Logger.Config.mask is optional, and the logger's mask(text) is what the reporter calls. The CLI's logger masks the secret values it knows.

Delivery never waits for a report​

The reporter is never awaited on the event path and never throws. A report that fails, whether the endpoint refuses it (401, 403, 413, 429), errs (500, 502) or hangs, costs delivery nothing. One ERROR line a minute carries the message Observe usage report failed (or Observe preview report failed) and a context of step (observe.usage or observe.preview), code (report-failed), status when the endpoint answered one, and error: the reason, the ClickHouse code when the answer has one, and last success with the time of the last good report or never. A 403 reads the data server refused the usage report: 403, plus clock offset <n> s when the answer's Date is more than 5 seconds off this clock, since a signed report from a clock that is off is refused. Repeats within the minute are counted in suppressed on the next line. How the context prints depends on the logger's format.

A screen that reads the reports shows a missing report as "no report since 10:42", never as 0.

On shutdown the final usage report goes out after the destinations' flush and waits at most 3 seconds. A report already in flight at that moment keeps its request up to its own 10-second timeout, so a Node host without process.exit stays alive that long.

Web flows​

A web flow reports from the visitor's browser, so a token in the page is public. That shapes what a build carries.

  • A production web bundle carries no reporter. A collector.observe block in a web flow file ships in the bundle's bytes with its token, and is not used: the page logs observe: not in this build, config ignored. Do not put a token in a web flow file. A self-hosted bundle logs the line, and a deploy of such a part to the walkerOS app is refused.
  • A preview build carries the preview part only. The CLI's browser wrap takes observe: { preview: { url, token } }, which replaces the flow file's own block and turns the reporter on in that build alone. Any other key, usage included, is refused, and so is observe on a node wrap or beside preview activation.
  • walkeros push and every simulate report nothing. They drop the flow's collector.observe before the flow starts, for a flow config and a prebuilt bundle alike.

On a page with a Content Security Policy, add the origin of the preview url to connect-src, for example https://ingest.example.com. Without it the browser blocks the rows and the console shows an error.

When the page is left​

The browser source sends a flush command when the page is hidden, and the preview part answers with one keepalive request:

  • It sends at most 16 KiB, the newest rows first. Older rows are dropped, and the seq gap shows them.
  • An event that has not settled yet arrives as queued with the element page-leave. If the page lives on, the settled row replaces it.
  • A row sent while leaving carries no payload, so a redaction in the flow is never skipped. The settled row brings the processed event.

This is proven in Chromium 148 and Firefox 150 with a destination still sending as the page left: the clicked event arrived as queued. Other browsers are not tested.

The 16 KiB cap leaves the rest of the page's 64 KiB keepalive budget to your destinations. A destination's own page-leave batch of 48 to 64 KiB can still be refused beside the reporter's body, in a preview build only. The destination then reports a transport failure.

A preview build is larger than a production one. For the minimal flow it adds 16,064 bytes raw and 6,308 gzipped.

Server flows​

A server flow reads collector.observe from its own config, with the token from a secret:

"collector": {
  "observe": {
    "usage": {
      "url": "$env.OBSERVE_URL",
      "token": "$secret.USAGE_TOKEN",
      "interval": 60
    }
  }
}

$env.OBSERVE_URL is read from process.env when the bundle loads, so the URL can differ per environment without a rebuild, and $var. references are resolved when the CLI bundles. Built with walkeros bundle and run with runneros, it starts with the flow.

Signed by a paired runner​

A runner paired with the walkerOS app holds a credential for its deployment. Started with it, runneros signs each usage report with the credential's key when the usage part names no token, so walkerOS hosted ingest needs no token in the flow:

"collector": {
  "observe": {
    "usage": { "url": "https://ingest.walkeros.io/usage" }
  }
}

Each report carries a fresh signature over its exact bytes. A token, when the part names one, wins. Without a token and without a runner that signs, the part logs one ERROR line naming observe.usage.token and does not start. When the data server answers 503 with Retry-After (a key it does not know yet), the next report goes out after that delay, once, then the interval holds again; a report is cumulative, so nothing is lost meanwhile. The signer is a runtime option of the host, never written in a flow file: startFlow takes it as observe.usage.authorize.

Self-hosting an endpoint​

Any HTTP endpoint that accepts a POST of NDJSON rows with a Bearer token can take the reports. The reporter's bodies are at most 60,000 bytes, and 16 KiB at a page leave. The endpoint should answer 2xx once the rows are stored, and, when a preview build posts from a page, allow a cross-origin POST with the Authorization and Content-Type headers.

The rows are the columns named above, and an endpoint may drop a column it does not store. The ClickHouse destination can write to such an endpoint when it needs a token: see Credentials. Run by a paired runner against walkerOS hosted ingest, it signs instead: see Signed inserts.

Observers​

Observe reports what a flow did. To handle every record of a flow yourself, use the collector's observers.

Next steps​

  • Collector: counters on collector.status, observers and trace correlation
  • Logger: failure lines, codes and masking
  • Runtime: run a built server flow
  • Deploy: from config to a running flow
💡 Need implementation support?
elbwalker offers hands-on support: setup review, measurement planning, destination mapping, and live troubleshooting. Book a 2-hour session (€399)