Skip to content

Commit

Permalink
Apply suggestions from code review
Browse files Browse the repository at this point in the history
Co-authored-by: Abhijeet Prasad <[email protected]>
  • Loading branch information
onurtemizkan and AbhiPrasad authored Jul 25, 2024
1 parent a591c05 commit a42a65f
Showing 1 changed file with 7 additions and 12 deletions.
19 changes: 7 additions & 12 deletions plugins/node/opentelemetry-instrumentation-express/src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,11 @@ export const getRouterPath = (path: string, layer: ExpressLayer): string => {
const stackLayer = layer.handle?.stack[0];

if (stackLayer.route?.path) {
path += stackLayer.route.path;
} else if (stackLayer.handle?.stack) {
path = getRouterPath(path, stackLayer);
return `${path}${stackLayer.route.path}`;
}

if (stackLayer.handle?.stack) {
return getRouterPath(path, stackLayer);
}

return path;
Expand All @@ -77,15 +79,8 @@ export const getLayerMetadata = (
name: string;
} => {
if (layer.name === 'router') {
let extractedRouterPath = '';

if (layer.handle?.stack) {
extractedRouterPath = getRouterPath(extractedRouterPath, layer);
}

if (!extractedRouterPath) {
extractedRouterPath = layerPath || route || '/';
}
const maybeRouterPath = getRouterPath('', layer);
const extractedRouterPath = maybeRouterPath ? maybeRouterPath : layerPath || route || '/';

return {
attributes: {
Expand Down

0 comments on commit a42a65f

Please sign in to comment.