Skip to content

feat(analytics): wide events: the accumulator, the stdout and PostHog sinks, the request event on runtime routes #388

Closed

Description

@allisonmahmood

Part of #384. Implements the observability half of spec §14; decision limits §3.

What to build

  • Wide events in packages/analytics: one structured record per hop of work, built on an Effect-scoped accumulator that the work enriches as it goes and emitted once in a finalizer. Delivery is best effort: logging never delays or fails the work, and a lost process can lose its last events.
  • Sinks: one JSON line on stdout (CloudWatch in production) and PostHog, sharing the existing client. Nothing is sampled. Each event records the probability it was kept with (1 today), so sampling can come later without a schema change.
  • Common fields: event id, trace and parent ids, host replica, deployment revision, and, where attributable, company, patch, version, viewer, handler name, kind, tier, task and process generation. Absent fields are omitted, never borrowed from an arbitrary invocation.
  • The five emitters' schemas: request (host), re-run (host), stream (host), process (supervisor) and binding (controller). This ticket emits the request event on the existing runtime routes (/api/runtime/call and the bytes routes) with the operation names, outcome, refusal code and limit id, and duration. The runtime tickets enrich it; the stream, supervisor and controller tickets emit their own.
  • Retire "readers stay unwatched" from the analytics package's doc comments and glossary. It was a PatchPage promise from the codebase Patchy grew out of; Patchy bills for usage, views included.
  • Dev: the dev runtime prints the same event compactly as its log line, with the full record behind --json (the dev ticket wires it to dev.log).

Admitted at merge

Request events for tier 1 runtime calls in stdout and PostHog.

Done when

A tier 1 runtime call emits exactly one request event with the fields above, a refusal emits one carrying its code, a failing PostHog sink changes nothing for the caller, and the event is emitted even when the work fails.

Surfaces

The Analytics glossary (Wide event, beside the analytics event), packages/analytics/CONTEXT.md, docs/DEVELOPMENT.md if a PostHog key is needed locally.

Metadata

Metadata

Assignees

No one assigned

    Labels

    area:serverready-for-agent

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions