Skip to content

Commit a762b60

Browse files
committed
fixup! feat(core, node): portable Express integration
1 parent fd4fefe commit a762b60

2 files changed

Lines changed: 8 additions & 2 deletions

File tree

‎packages/core/src/integrations/express/patch-layer.ts‎

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,13 @@ export function patchLayer(options: ExpressPatchLayerOptions, layer?: ExpressLay
7979

8080
// verify against the config if the layer should be ignored
8181
if (isLayerIgnored(metadata.name, type, options)) {
82-
if (type === ExpressLayerType_MIDDLEWARE) {
82+
// XXX: the isLayerPathStored guard here is *not* present in the
83+
// original @opentelemetry/instrumentation-express impl, but was
84+
// suggested by the Sentry code review bot. It appears to correctly
85+
// prevent improper layer calculation in the case where there's a
86+
// middleware without a layerPath argument. It's unclear whether
87+
// that's possible, or if any existing code depends on that "bug".
88+
if (isLayerPathStored && type === ExpressLayerType_MIDDLEWARE) {
8389
storedLayers.pop();
8490
}
8591
return originalHandle.apply(this, [req, res, ...otherArgs]);

‎packages/core/test/lib/integrations/express/patch-layer.test.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@ describe('patchLayer', () => {
185185
data: {
186186
'express.name': 'mw',
187187
'express.type': 'middleware',
188-
'http.route': '/a/:boo',
188+
'http.route': '/a/:boo/:car',
189189
'sentry.op': 'middleware.express',
190190
'sentry.origin': 'auto.http.express',
191191
},

0 commit comments

Comments
 (0)