import type { NsidString } from '@atproto/lex-schema'; import type { NotificationsV2Algorithm } from '../config.js'; export type HydrationSource = 'known_likers' | 'known_followers' | 'activity_subscriptions'; /** XRPC method that owns a hydration; set on `HydrateCtx` from the method's `$lxm`. */ export type HydrationXrpcEndpoint = NsidString; /** Reported XRPC endpoint of an external hydration traversal. */ export type ExternalHydrationXrpcEndpoint = HydrationXrpcEndpoint | 'unknown'; /** Entry point that owns an external hydration traversal. */ export type ExternalHydrationRoot = 'uris' | 'refs' | 'dependencies'; /** * `partial` is a returned traversal that recovered from a best-effort * dependency failure; `capped` takes precedence over it. */ export type ExternalHydrationOutcome = 'completed' | 'capped' | 'partial' | 'failed'; /** Bounded metric attributes of an external hydration traversal. */ type ExternalHydrationAttributes = { xrpcEndpoint: ExternalHydrationXrpcEndpoint; root: ExternalHydrationRoot; outcome: ExternalHydrationOutcome; }; /** * Generic record lookup work of one external hydration traversal, across the * root and all nested dependency batches. Excludes profile/label hydration * and backlink sample/count RPCs. */ export type ExternalHydrationWork = { /** * Accepted latest/exact lookup identities scheduled for fetching, after * filtering duplicates and seen keys. Unavailable results and lookups in a * failed batch count; lookups skipped at the pass cap do not. */ recordLookups: number; /** Nonempty batches that scheduled generic fetches; not a raw RPC count. */ batches: number; /** Deepest fetched batch, where the root batch is pass 1; 0 if none. */ maxPass: number; /** * Refs inspected by the traversal's first dependency discovery. A traversal * whose root batch failed has none. */ roots: number; /** Roots available after takedown and owner moderation. */ rootsResolved: number; /** * Refs inspected by later dependency discoveries: records returned by * successful nested batches. Lookups lost to a failed batch or the pass cap * are excluded. */ dependencies: number; /** Dependencies available after takedown and owner moderation. */ dependenciesResolved: number; }; /** * Central hub for reporting AppView events. Each method reports a * single event to every relevant sink in one call: * * 1. a pino logger → stdout/stderr (docker logs) * 2. an OTEL counter → aggregated metric (low-cardinality dimensions only) * 3. the OTEL Logs SDK → structured, trace-correlated log record (full detail) * * This keeps the three concerns in sync: there is exactly one call site per * event, and the counter / log / attribute definitions live together here * rather than being duplicated and drifting across handlers. * * @note High-cardinality attributes (e.g. `did`, `uri`) belong in the pino and * OTEL log records but must stay OUT of the counters, whose attributes must * remain low-cardinality to avoid a metric-series explosion. * * @note The OTEL counters and log records are no-ops unless the corresponding * OTEL exporter is configured, so calling these methods is always safe and * essentially free when telemetry is disabled. */ declare class EventReporter { #private; hydrationFailed({ source, err }: { source: HydrationSource; err: unknown; }): void; /** * Reports the totals of one top-level external hydration traversal. Numeric * totals are observations and log fields, never metric attributes. * * @note this method should never throw */ externalHydrationTraversal({ xrpcEndpoint, root, outcome, durationMs, recordLookups, batches, maxPass, roots, rootsResolved, dependencies, dependenciesResolved, }: ExternalHydrationWork & ExternalHydrationAttributes & { durationMs: number; }): void; /** Reports compute time once per grouping invocation, excluding dataplane reads. */ notificationGrouping({ algorithm, durationMs, }: { algorithm: NotificationsV2Algorithm; durationMs: number; }): void; /** Reports dataplane fetches, raw-item counts, and hydration time once per completed page. */ groupedNotifications({ itemsFetched, itemsReturned, dataplaneFetches, hydrationDurationMs, }: { itemsFetched: number; itemsReturned: number; dataplaneFetches: number; hydrationDurationMs: number; }): void; } export declare const events: EventReporter; export {}; //# sourceMappingURL=events.d.ts.map