UNPKG

3.39 kBTypeScriptView Raw
1/// <reference types="node" />
2import type { ClientRequest, IncomingMessage, RequestOptions, ServerResponse } from 'node:http';
3import type { Span } from '@opentelemetry/api';
4import { HttpInstrumentation } from '@opentelemetry/instrumentation-http';
5import type { HTTPModuleRequestIncomingMessage } from '../transports/http-module';
6interface HttpOptions {
7 /**
8 * Whether breadcrumbs should be recorded for requests.
9 * Defaults to true
10 */
11 breadcrumbs?: boolean;
12 /**
13 * Do not capture spans or breadcrumbs for outgoing HTTP requests to URLs where the given callback returns `true`.
14 * This controls both span & breadcrumb creation - spans will be non recording if tracing is disabled.
15 *
16 * The `url` param contains the entire URL, including query string (if any), protocol, host, etc. of the outgoing request.
17 * For example: `'https://someService.com/users/details?id=123'`
18 *
19 * The `request` param contains the original {@type RequestOptions} object used to make the outgoing request.
20 * You can use it to filter on additional properties like method, headers, etc.
21 */
22 ignoreOutgoingRequests?: (url: string, request: RequestOptions) => boolean;
23 /**
24 * Do not capture spans or breadcrumbs for incoming HTTP requests to URLs where the given callback returns `true`.
25 * This controls both span & breadcrumb creation - spans will be non recording if tracing is disabled.
26 *
27 * The `urlPath` param consists of the URL path and query string (if any) of the incoming request.
28 * For example: `'/users/details?id=123'`
29 *
30 * The `request` param contains the original {@type IncomingMessage} object of the incoming request.
31 * You can use it to filter on additional properties like method, headers, etc.
32 */
33 ignoreIncomingRequests?: (urlPath: string, request: IncomingMessage) => boolean;
34 /**
35 * Additional instrumentation options that are passed to the underlying HttpInstrumentation.
36 */
37 instrumentation?: {
38 requestHook?: (span: Span, req: ClientRequest | HTTPModuleRequestIncomingMessage) => void;
39 responseHook?: (span: Span, response: HTTPModuleRequestIncomingMessage | ServerResponse) => void;
40 applyCustomAttributesOnSpan?: (span: Span, request: ClientRequest | HTTPModuleRequestIncomingMessage, response: HTTPModuleRequestIncomingMessage | ServerResponse) => void;
41 /**
42 * You can pass any configuration through to the underlying instrumention.
43 * Note that there are no semver guarantees for this!
44 */
45 _experimentalConfig?: ConstructorParameters<typeof HttpInstrumentation>[0];
46 };
47 /** Allows to pass a custom version of HttpInstrumentation. We use this for Next.js. */
48 _instrumentation?: typeof HttpInstrumentation;
49}
50/**
51 * Instrument the HTTP module.
52 * This can only be instrumented once! If this called again later, we just update the options.
53 */
54export declare const instrumentHttp: (() => void) & {
55 id: string;
56};
57/**
58 * The http integration instruments Node's internal http and https modules.
59 * It creates breadcrumbs and spans for outgoing HTTP requests which will be attached to the currently active span.
60 */
61export declare const httpIntegration: (options?: HttpOptions | undefined) => import("@sentry/types").Integration;
62export {};
63//# sourceMappingURL=http.d.ts.map
\No newline at end of file