Skip to content

Commit 435affe

Browse files
committed
misc: improve APM transaction names
1 parent 8c1b1cd commit 435affe

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

Diff for: src/lib/http/server.ts

+7-2
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,9 @@ const publicPath = url.fileURLToPath(new URL('.', import.meta.url)) + '/../../..
3636
const docsHost = config.get<string>('server.docsHost');
3737

3838
const rootRouter = new Router({ strict: true, sensitive: true });
39-
rootRouter.prefix('/');
39+
40+
rootRouter.prefix('/')
41+
.use(koaElasticUtils.middleware(apmAgent));
4042

4143
// GET /
4244
rootRouter.get<object, CustomContext>('/', '/', (ctx) => {
@@ -52,6 +54,7 @@ rootRouter.get<object, CustomContext>('/', '/', (ctx) => {
5254
const apiRouter = new Router({ strict: true, sensitive: true });
5355

5456
apiRouter.prefix('/v1')
57+
.use(koaElasticUtils.middleware(apmAgent, { prefix: '/v1' }))
5558
.use(isAdminMw)
5659
.use(isSystemMw);
5760

@@ -71,6 +74,8 @@ registerAlternativeIpRoute(apiRouter);
7174
registerLimitsRoute(apiRouter);
7275

7376
const healthRouter = new Router({ strict: true, sensitive: true });
77+
healthRouter.use(koaElasticUtils.middleware(apmAgent));
78+
7479
// GET /health
7580
registerHealthRoute(healthRouter);
7681

@@ -86,11 +91,11 @@ app
8691
// Error handler must always be the first middleware in a chain unless you know what you are doing ;)
8792
.use(errorHandlerMw)
8893
.use(corsHandler())
89-
.use(koaElasticUtils.middleware(apmAgent))
9094
.use(rootRouter.routes())
9195
.use(healthRouter.routes())
9296
.use(apiRouter.routes())
9397
.use(apiRouter.allowedMethods())
98+
.use(koaElasticUtils.middleware(apmAgent))
9499
.use(koaStatic(publicPath, { format: false }));
95100

96101
app.on('error', errorHandler);

0 commit comments

Comments
 (0)