/** * The one chokepoint every span passes through on its way out. * * The underlying SDK advertises an `onAttributesSerializing` hook for exactly * this purpose and then never calls it — its default exporter factory drops the * option on the floor. Injecting a span processor doesn't work either: the * provider is constructed with an explicit `spanProcessors` key that overrides * anything passed alongside it. So we replace the exporter factory, which is a * documented option, and patch the built exporter's `export` on the way past. * * Patching the instance rather than wrapping it in a new object is deliberate: * the batch processor holds onto this exporter and pokes at more of it than the * `SpanExporter` interface names, so it needs to stay the same object. */ import type { RumOtelWebExporterOptions } from "@hyperdx/otel-web"; import { OTLPTraceExporter } from "@opentelemetry/exporter-trace-otlp-http"; import type { RumTraceDestination } from "./options.js"; export type ScrubOptions = { scrubQueryStrings: boolean; onScrub?: (count: number) => void; additionalTraceDestinations?: RumTraceDestination[]; redactUrl?: (url: string) => string; /** * Hold the first export until this settles — the identity gate. * * Without it the head of every session is anonymous: the document-load spans * exist before any session request can have answered. The first caller to wire * identity found exactly that — "only the first ~2s of page-load spans stay * anonymous" — and a rule with a two-second hole in it is not a rule. * * See `identityGate` in ./index.ts for what bounds the wait. Whatever happens * there, this defers a batch; it never drops one. */ waitFor?: Promise; /** * Who to stamp on a held span, read at export rather than at span creation. * * Waiting is not enough on its own, which cost a staging verification to * learn: the underlying SDK copies global attributes onto a span in its * processor's `onStart`, so a span that had already STARTED when identity * arrived stays anonymous however long its batch is held. `documentLoad`, * `documentFetch`, `resourceFetch` and `webvitals` all start at init, which is * every span of the first page load. * * So the gate delays, and this fills in. Only keys the span is missing: a * span that started after a later `identifyUser` already carries that * person's attributes, and the older stamp must not overwrite them. */ identity?: () => Record | null; /** * Drop `resourceFetch` spans faster than this, in milliseconds. * * A page load emits one of these per stylesheet, font and chunk — seven per * load on our own app, the same seven every time, forever. The slow ones earn * their place: `documentLoad` tells you the page took 1.6s, and only the * asset spans tell you which font it was waiting on. The fast ones are the * same cache hit re-recorded on every visit by every visitor. * * A span whose status is not UNSET is always kept — a failed asset is the * whole reason to look, and Resource Timing gives no status code to filter on * afterwards. */ assetFloorMs?: number; }; /** * The SDK's `exporter` option carries a `factory` — it is read at runtime and * documented on the internal config type, but absent from the public `init` * signature. This function is the only place that gap is papered over. */ export declare function exporterOption(options: ScrubOptions): RumOtelWebExporterOptions; /** * The shape the SDK hands its exporter factory. Declared here rather than * imported because it belongs to the SDK's internal config type, which the * public `init` signature does not expose. */ export type ExporterFactoryConfig = { url: string; authHeader?: string; }; /** * Build the exporter the SDK will use, scrubbing query strings out of every * URL-shaped attribute unless the caller opted out. */ export declare function buildExporter(config: ExporterFactoryConfig, options: ScrubOptions): OTLPTraceExporter; /** * Patch one exporter's `export` so every span is scrubbed on its way out. * Separate from `buildExporter` so it can be tested without a live exporter. */ export declare function scrubOnExport(exporter: E, options: ScrubOptions): E; //# sourceMappingURL=exporter.d.ts.map