//#region src/http/body/types.d.ts /** * Matches request or response content types that should be captured. */ type HttpBodyContentTypeMatcher = string | RegExp; /** * HTTP message kind being captured. */ type HttpBodyKind = 'request' | 'response'; /** * Snapshot of the HTTP message exposed to ignore and body-transform hooks. */ interface HttpBodyInfo { /** * Direction of the captured HTTP message. */ direction: 'incoming' | 'outgoing'; /** * Whether the captured message is a request or a response. */ kind: HttpBodyKind; /** * HTTP method when available. */ method?: string; /** * Absolute URL when it can be reconstructed, otherwise the raw path. */ url?: string; /** * Normalized headers as a flat string map. */ headers: Record; /** * Remote IP address when known. */ ip?: string; /** * HTTP status code when known. */ statusCode?: number; /** * Normalized `content-type` header value. */ contentType?: string; /** * Parsed body value after content-type aware decoding. */ body?: unknown; } /** * Mutable record passed through the body capture pipeline. */ interface HttpBodyRecord { http: HttpBodyInfo; } /** * User-provided transform that can mutate the record or return a replacement. */ type HttpBodyRedactor = (record: HttpBodyRecord) => void | HttpBodyRecord; /** * Declarative redaction rules applied before custom transforms. */ interface HttpBodyRedactionConfig { /** * Body keys to redact recursively, case-insensitively. */ bodyKeys?: string[]; /** * Replacement value written for redacted fields. * @default '***' */ censor?: string; /** * Header names to redact, case-insensitively. */ headers?: string[]; /** * Query parameter names to redact, case-insensitively. */ queryParams?: string[]; } /** * Controls body capture for one HTTP message shape. */ interface HttpBodyCaptureSideConfig { /** * Enables body capture for this HTTP message shape. * This can opt in even when the top-level namespace is omitted. * @default false */ enabled?: boolean; /** * Content types eligible for capture. * @default ['application/json', 'application/x-www-form-urlencoded'] */ contentTypes?: HttpBodyContentTypeMatcher[]; /** * Skips capture for matching HTTP messages. */ ignore?: (http: HttpBodyInfo) => boolean; /** * Maximum number of body bytes stored on the span. * Total body size is still reported separately. * @default 10000 */ maxBodySize?: number; } type HttpBodyTrafficCaptureConfig = { /** * Capture settings for request bodies. * Set to `false` to disable request capture explicitly. */ request?: false | HttpBodyCaptureSideConfig; /** * Capture settings for response bodies. * Set to `false` to disable response capture explicitly. */ response?: false | HttpBodyCaptureSideConfig; }; /** * Shared HTTP body capture configuration used by Node agents. */ interface HttpBodyCaptureConfig { /** * Enables the HTTP body capture namespace. * @default false */ enabled?: boolean; /** * Capture settings for incoming HTTP traffic. * Set to `false` to disable incoming capture explicitly. */ incoming?: false | HttpBodyTrafficCaptureConfig; /** * Capture settings for outgoing traffic produced by `@opentelemetry/instrumentation-http`. * This covers `node:http` and `node:https`, not `fetch` / `undici`. * Set to `false` to disable outgoing capture explicitly. */ outgoing?: false | HttpBodyTrafficCaptureConfig; /** * Declarative redaction rules for headers, query params, and body keys. */ redact?: HttpBodyRedactionConfig; /** * One or more custom transforms applied after declarative redaction. */ transform?: HttpBodyRedactor | HttpBodyRedactor[]; } //#endregion export { HttpBodyCaptureConfig, HttpBodyCaptureSideConfig, HttpBodyContentTypeMatcher, HttpBodyInfo, HttpBodyKind, HttpBodyRecord, HttpBodyRedactionConfig, HttpBodyRedactor };