Skip to content

Commit 679ff95

Browse files
committed
cursor cleanup
1 parent 21b3dc2 commit 679ff95

File tree

3 files changed

+31
-84
lines changed

3 files changed

+31
-84
lines changed

PR_DESCRIPTION.md

Lines changed: 0 additions & 75 deletions
This file was deleted.

packages/node/src/integrations/tracing/express.ts

Lines changed: 27 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import type * as http from 'node:http';
22
import type { Span } from '@opentelemetry/api';
3-
import type { ExpressRequestInfo } from '@opentelemetry/instrumentation-express';
3+
import type { ExpressLayerType, ExpressRequestInfo } from '@opentelemetry/instrumentation-express';
44
import { ExpressInstrumentation } from '@opentelemetry/instrumentation-express';
55
import type { IntegrationFn } from '@sentry/core';
66
import {
@@ -26,11 +26,33 @@ type IgnoreMatcher = string | RegExp | ((path: string) => boolean);
2626

2727
interface ExpressOptions {
2828
/**
29-
* Ignore specific layers based on their path
29+
* Ignore specific layers based on their path.
30+
*
31+
* Accepts an array of matchers that can be:
32+
* - String: exact path match
33+
* - RegExp: pattern matching
34+
* - Function: custom logic that receives the path and returns boolean
3035
*/
3136
ignoreLayers?: IgnoreMatcher[];
3237
/**
33-
* Ignore specific layers based on their type
38+
* Ignore specific layers based on their type.
39+
*
40+
* Available layer types:
41+
* - 'router': Express router layers
42+
* - 'middleware': Express middleware layers
43+
* - 'request_handler': Express request handler layers
44+
*
45+
* @example
46+
* ```javascript
47+
* // Ignore only middleware layers
48+
* ignoreLayersType: ['middleware']
49+
*
50+
* // Ignore multiple layer types
51+
* ignoreLayersType: ['middleware', 'router']
52+
*
53+
* // Ignore all layer types (effectively disables tracing)
54+
* ignoreLayersType: ['middleware', 'router', 'request_handler']
55+
* ```
3456
*/
3557
ignoreLayersType?: ('router' | 'middleware' | 'request_handler')[];
3658
}
@@ -74,7 +96,7 @@ export const instrumentExpress = generateInstrumentOnce(
7496
requestHook: span => requestHook(span),
7597
spanNameHook: (info, defaultName) => spanNameHook(info, defaultName),
7698
ignoreLayers: options.ignoreLayers,
77-
ignoreLayersType: options.ignoreLayersType as any,
99+
ignoreLayersType: options.ignoreLayersType as ExpressLayerType[],
78100
}),
79101
);
80102

@@ -85,7 +107,7 @@ export const instrumentExpressV5 = generateInstrumentOnce(
85107
requestHook: span => requestHook(span),
86108
spanNameHook: (info, defaultName) => spanNameHook(info, defaultName),
87109
ignoreLayers: options.ignoreLayers,
88-
ignoreLayersType: options.ignoreLayersType as any,
110+
ignoreLayersType: options.ignoreLayersType as ExpressLayerType[],
89111
}),
90112
);
91113

packages/node/test/integrations/tracing/express.test.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ describe('Express', () => {
8686
it('passes both options to instrumentation', () => {
8787
instrumentExpress({
8888
ignoreLayers: ['/health'],
89-
ignoreLayersType: ['request_handler']
89+
ignoreLayersType: ['request_handler'],
9090
});
9191

9292
expect(ExpressInstrumentation).toHaveBeenCalledTimes(1);
@@ -115,7 +115,7 @@ describe('Express', () => {
115115
it('passes options to instrumentExpressV5', () => {
116116
instrumentExpressV5({
117117
ignoreLayers: [(path: string) => path.startsWith('/admin')],
118-
ignoreLayersType: ['middleware', 'router']
118+
ignoreLayersType: ['middleware', 'router'],
119119
});
120120

121121
expect(ExpressInstrumentationV5).toHaveBeenCalledTimes(1);
@@ -152,7 +152,7 @@ describe('Express', () => {
152152
it('passes options from expressIntegration to both instrumentations', () => {
153153
expressIntegration({
154154
ignoreLayers: [/^\/api\/v1/],
155-
ignoreLayersType: ['middleware']
155+
ignoreLayersType: ['middleware'],
156156
}).setupOnce!();
157157

158158
expect(ExpressInstrumentation).toHaveBeenCalledTimes(1);
@@ -174,7 +174,7 @@ describe('Express', () => {
174174

175175
it('passes all layer types from expressIntegration to instrumentation', () => {
176176
expressIntegration({
177-
ignoreLayersType: ['router', 'middleware', 'request_handler']
177+
ignoreLayersType: ['router', 'middleware', 'request_handler'],
178178
}).setupOnce!();
179179

180180
expect(ExpressInstrumentation).toHaveBeenCalledTimes(1);

0 commit comments

Comments
 (0)