Skip to content
This repository was archived by the owner on Oct 31, 2024. It is now read-only.

Commit 2ae18cb

Browse files
author
Amir Blum
authored
fix(instrumentation-express): explicitly depend on used express util packages (#141)
1 parent e6eb2ac commit 2ae18cb

File tree

3 files changed

+5
-4
lines changed

3 files changed

+5
-4
lines changed

packages/instrumentation-express/package.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,9 @@
3636
"dependencies": {
3737
"@opentelemetry/core": "^0.21.0",
3838
"@opentelemetry/instrumentation": "^0.21.0",
39-
"@opentelemetry/semantic-conventions": "^0.21.0"
39+
"@opentelemetry/semantic-conventions": "^0.21.0",
40+
"parseurl": "~1.3.3",
41+
"path-to-regexp": "0.1.7"
4042
},
4143
"devDependencies": {
4244
"@opentelemetry/api": "^0.21.0",

packages/instrumentation-express/src/utils/layer-path.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { LayerPath, LayerPathAlternative } from '../types';
2+
import pathRegexp from 'path-to-regexp';
23
import type express from 'express';
34

45
const pathStringToDisplayValue = (pathInput: string, options: express.RouterOptions): string => {
@@ -14,8 +15,6 @@ const getLayerPathAlternativeFromFirstArg = (
1415
pathInput: any,
1516
options
1617
): LayerPathAlternative | LayerPathAlternative[] => {
17-
const pathRegexp = require('path-to-regexp');
18-
1918
if (typeof pathInput === 'string') {
2019
return {
2120
userSuppliedValue: pathInput,

packages/instrumentation-express/src/utils/route-context.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { ExpressConsumedRouteState, LayerPath } from '../types';
2+
import parseurl from 'parseurl';
23
import type express from 'express';
34

45
export const getUsedPathFromLayerPath = (
@@ -65,7 +66,6 @@ export const createInitialRouteState = (req: express.Request): ExpressConsumedRo
6566
// at this point, we have the raw http req object, and not the express req.
6667
// thus, we cannot call req.path
6768
// we use parseurl(req).pathname which is exactly what express is doing
68-
const parseurl = require('parseurl');
6969
const path = parseurl(req).pathname;
7070
return { resolvedRoute: '', remainingRoute: path, configuredRoute: '', params: {} };
7171
};

0 commit comments

Comments
 (0)