Skip to content

Commit cf559f9

Browse files
nicohrubecclaude
andauthored
ref(server-utils): Collapse express route/use into one orchestrion channel (#22331)
Merges the express `route`/`use` registration channels into a single per-module `register` channel to reduce the number of tracing channels — the subscriber treats both identically, so there's no behavior change. --------- Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
1 parent 8fb6d5c commit cf559f9

2 files changed

Lines changed: 10 additions & 14 deletions

File tree

packages/server-utils/src/integrations/tracing-channel/express/instrumentation.ts

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -60,12 +60,7 @@ export function instrumentExpress(
6060
// matched route can be reconstructed with its parameters intact at request
6161
// time. Only the `end` event matters (the layer is on the router's stack by
6262
// then); the others are required by the subscriber type, so no-op them.
63-
for (const channelName of [
64-
CHANNELS.EXPRESS_ROUTE,
65-
CHANNELS.EXPRESS_USE,
66-
CHANNELS.ROUTER_ROUTE,
67-
CHANNELS.ROUTER_USE,
68-
]) {
63+
for (const channelName of [CHANNELS.EXPRESS_REGISTER, CHANNELS.ROUTER_REGISTER]) {
6964
tracingChannel<RegistrationChannelContext>(channelName).subscribe({
7065
start: NOOP,
7166
asyncStart: NOOP,

packages/server-utils/src/orchestrion/config/express.ts

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -32,25 +32,28 @@ export const expressConfig = [
3232
// handler, `use`'s trailing function argument is a registration payload, not a
3333
// callback — so `Callback` would misclassify it and never fire `end`.
3434
//
35+
// `route` and `use` share one `register` channel because the subscriber handles
36+
// them identically, saving a channel per module.
37+
//
3538
// Express v4 ships its own router in `express/lib/router/index.js`.
3639
{
37-
channelName: 'route',
40+
channelName: 'register',
3841
module: { name: 'express', versionRange: '>=4.0.0 <5', filePath: 'lib/router/index.js' },
3942
functionQuery: { expressionName: 'route', kind: 'Sync' },
4043
},
4144
{
42-
channelName: 'use',
45+
channelName: 'register',
4346
module: { name: 'express', versionRange: '>=4.0.0 <5', filePath: 'lib/router/index.js' },
4447
functionQuery: { expressionName: 'use', kind: 'Sync' },
4548
},
4649
// Express v5 delegates routing to the standalone `router` package.
4750
{
48-
channelName: 'route',
51+
channelName: 'register',
4952
module: { name: 'router', versionRange: '>=2.0.0 <3', filePath: 'index.js' },
5053
functionQuery: { expressionName: 'route', kind: 'Sync' },
5154
},
5255
{
53-
channelName: 'use',
56+
channelName: 'register',
5457
module: { name: 'router', versionRange: '>=2.0.0 <3', filePath: 'index.js' },
5558
functionQuery: { expressionName: 'use', kind: 'Sync' },
5659
},
@@ -66,8 +69,6 @@ export const expressChannels = {
6669
// Layer *registration* (`Router.prototype.route`/`.use`), used to capture each
6770
// layer's registered path pattern so the matched route can be reconstructed
6871
// with its parameters intact (`req.baseUrl` only exposes the resolved prefix).
69-
EXPRESS_ROUTE: 'orchestrion:express:route',
70-
EXPRESS_USE: 'orchestrion:express:use',
71-
ROUTER_ROUTE: 'orchestrion:router:route',
72-
ROUTER_USE: 'orchestrion:router:use',
72+
EXPRESS_REGISTER: 'orchestrion:express:register',
73+
ROUTER_REGISTER: 'orchestrion:router:register',
7374
} as const;

0 commit comments

Comments
 (0)