Skip to content
Français

ObservationHub

import type { ObservationHub } from "@elie-laloum/outpost/observation";
  • redactingRequired
    boolean
    True when this scope has any redaction rules, including inherited ones. Conversation capture uses it to refuse unsupported binary filtering only when enabled.
  • scopeRequired
    ObservationScope
    Immutable correlation fields inherited by emissions from this hub.
  • errorsRequired
    readonly unknown[]
    Shared bounded collection of sink, serialization, overflow and timeout errors; retains the first 100 failures independently of execution.
  • droppedRequired
    number
    Shared count of delivery losses across sinks, including overflow and disabled receivers.
  • verboseRequired
    boolean
    Whether producers may emit full model request and response payloads; journal retention is configured separately.
  • redactRequired
    <T>(value: T) => T
    Copy a structured value and apply this scope’s masking rules without mutating the original. Used by transcript storage before serializing records.
  • emitRequired
    (source: ObservationSource, event: ObservationEvent) => void
    Stamps an event with seq, timestamp, source and this hub’s scope, then delivers a copy to inherited and local sinks. Does nothing after close(); sink failures go to errors, never thrown.
  • childRequired
    (scope: ObservationScope, sinks?: readonly ObservationSink[], redact?: readonly RegExp[]) => ObservationHub
    Create a child scope inheriting sinks and redaction rules; optional additional sinks and regular expressions apply before all inherited and local receivers. Closing the child flushes its deliveries without closing the parent.
  • flushRequired
    () => Promise<void>
    Drain the current delivery snapshot and flush registered sinks with bounded waits; later emissions belong to a later snapshot.
  • closeRequired
    () => Promise<void>
    Stop emissions from this child and its descendants, drain its delivery snapshot and detach its own sinks without closing caller-owned parent sinks.
export interface ObservationHub {
  readonly redacting: boolean;
  readonly scope: ObservationScope;
  readonly errors: readonly unknown[];
  readonly dropped: number;
  readonly verbose: boolean;
  redact<T>(value: T): T;
  emit(source: ObservationSource, event: ObservationEvent): void;
  child(
    scope: ObservationScope,
    sinks?: readonly ObservationSink[],
    redact?: readonly RegExp[],
  ): ObservationHub;
  flush(): Promise<void>;
  close(): Promise<void>;
}