This plugin automatically instruments the http module.

By default any option set at the root will apply to both clients and servers. To configure only one or the other, use the client and server options.

interface http {
    allowlist?: string | RegExp | ((urlOrPath) => boolean) | (string | RegExp | ((urlOrPath) => boolean))[];
    blocklist?: string | RegExp | ((urlOrPath) => boolean) | (string | RegExp | ((urlOrPath) => boolean))[];
    client?: boolean | HttpClient;
    enabled?: boolean;
    headers?: string[];
    hooks?: {
        request?: ((span?, req?, res?) => any);
    };
    measured?: boolean | {
        [key: string]: boolean;
    };
    middleware?: boolean;
    propagationBlocklist?: string | RegExp | ((url) => boolean) | (string | RegExp | ((url) => boolean))[];
    server?: boolean | HttpServer;
    service?: any;
    splitByDomain?: boolean;
    validateStatus?: ((code) => boolean);
}

Hierarchy

  • HttpClient
  • HttpServer
    • http

Properties

allowlist?: string | RegExp | ((urlOrPath) => boolean) | (string | RegExp | ((urlOrPath) => boolean))[]

List of URLs/paths that should be instrumented.

Note that when used for an http client the entry represents a full outbound URL (https://example.org/api/foo) but when used as a server the entry represents an inbound path (/api/foo).

Type declaration

    • (urlOrPath): boolean
    • Parameters

      • urlOrPath: string

      Returns boolean

Default

/^.*$/
blocklist?: string | RegExp | ((urlOrPath) => boolean) | (string | RegExp | ((urlOrPath) => boolean))[]

List of URLs/paths that should not be instrumented. Takes precedence over allowlist if a URL matches an entry in both.

Note that when used for an http client the entry represents a full outbound URL (https://example.org/api/foo) but when used as a server the entry represents an inbound path (/api/foo).

Type declaration

    • (urlOrPath): boolean
    • Parameters

      • urlOrPath: string

      Returns boolean

Default

[]
client?: boolean | HttpClient

Configuration for HTTP clients.

enabled?: boolean

Whether to enable the plugin.

Default

true
headers?: string[]

An array of headers to include in the span metadata.

Default

[]
hooks?: {
    request?: ((span?, req?, res?) => any);
}

Hooks to run before spans are finished.

Type declaration

  • Optional request?: ((span?, req?, res?) => any)

    Hook to execute just before the request span finishes.

      • (span?, req?, res?): any
      • Hook to execute just before the request span finishes.

        Parameters

        • Optional span: export=.Span
        • Optional req: IncomingMessage | ClientRequest
        • Optional res: IncomingMessage | ServerResponse<IncomingMessage>

        Returns any

measured?: boolean | {
    [key: string]: boolean;
}

Whether to measure the span. Can also be set to a key-value pair with span names as keys and booleans as values for more granular control.

Type declaration

  • [key: string]: boolean
middleware?: boolean

Whether to enable instrumentation of .middleware spans

Default

true
propagationBlocklist?: string | RegExp | ((url) => boolean) | (string | RegExp | ((url) => boolean))[]

List of urls to which propagation headers should not be injected

Type declaration

    • (url): boolean
    • Parameters

      • url: string

      Returns boolean

server?: boolean | HttpServer

Configuration for HTTP servers.

service?: any

The service name to be used for this plugin.

splitByDomain?: boolean

Use the remote endpoint host as the service name instead of the default.

Default

false
validateStatus?: ((code) => boolean)

Callback function to determine if there was an error. It should take a status code as its only parameter and return true for success or false for errors.

Type declaration

    • (code): boolean
    • Callback function to determine if there was an error. It should take a status code as its only parameter and return true for success or false for errors.

      Parameters

      • code: number

      Returns boolean

      Default

      code => code < 400 || code >= 500
      

Default

code => code < 400 || code >= 500

Generated using TypeDoc