import { kLayerPatched } from './' ; import { Request } from 'express' ; import { SpanAttributes } from '@opentelemetry/api' ; import { InstrumentationConfig } from '@opentelemetry/instrumentation' ; import { ExpressLayerType } from './enums/ExpressLayerType' ; /**
 * This const define where on the `request` object the Instrumentation will mount the
 * current stack of express layer.
 *
 * It is necessary because express doesnt store the different layers
 * (ie: middleware, router etc) that it called to get to the current layer.
 * Given that, the only way to know the route of a given layer is to
 * store the path of where each previous layer has been mounted.
 *
 * ex: bodyParser > auth middleware > /users router > get /:id
 *  in this case the stack would be: ["/users", "/:id"]
 *
 * ex2: bodyParser > /api router > /v1 router > /users router > get /:id
 *  stack: ["/api", "/v1", "/users", ":id"]
 *
 */ export const _LAYERS_STORE_PROPERTY = '__ot_middlewares' ; export type PatchedRequest = { [ _LAYERS_STORE_PROPERTY ] ? : string [ ] ; } & Request ; export type PathParams = string | RegExp | Array < string | RegExp > ; export type ExpressRouter = { params : { [ key ] : string ; } ; _params : string [ ] ; caseSensitive : boolean ; mergeParams : boolean ; strict : boolean ; stack : ExpressLayer [ ] ; } ; export type ExpressLayer = { handle : Function ; [ kLayerPatched ] ? : boolean ; name : string ; params : { [ key ] : string ; } ; path : string ; regexp : RegExp ; } ; export type LayerMetadata = { attributes : SpanAttributes ; name : string ; } ; export type IgnoreMatcher = string | RegExp | ( ( name : string ) => boolean ) ; /**
 * Options available for the Express Instrumentation (see [documentation](https://github.com/open-telemetry/opentelemetry-js/tree/main/packages/opentelemetry-Instrumentation-express#express-Instrumentation-options))
 */ export interface ExpressInstrumentationConfig extends InstrumentationConfig { /** Ignore specific based on their name */ ignoreLayers ? : IgnoreMatcher [ ] ; /** Ignore specific layers based on their type */ ignoreLayersType ? : ExpressLayerType [ ] ; }