import cors from '@elysiajs/cors';
import Elysia from 'elysia';
import apm from './lib/apm';
new Elysia()
.use(
cors({
origin: true,
methods: ['OPTIONS', 'GET', 'DELETE'],
allowedHeaders: ['Content-Type'],
exposedHeaders: '*',
credentials: false,
preflight: true,
maxAge: 86400
})
)
.onRequest(({ request }) => {
const url = new URL(request.url),
pathname = url.pathname;
if (pathname !== '/ping') {
apm.startTransaction();
apm.setTransactionName(`${request.method} ${pathname}`);
}
})
.onAfterHandle(() => {
apm.endTransaction();
})
.get('/ping', ({ set }) => {
set.status = 200;
return 'pong';
})
.listen(process.env.SERVICE_PORT ?? 5001);
@zx8086 I finally was able to capture stuff. It's more of a manual effort since the apm doesn't seem to be able to hook into Elysia's framework. If you want to capture requests downstream, you're going to have to instrument it yourself:
Apache, Apache Lucene, Apache Hadoop, Hadoop, HDFS and the yellow elephant
logo are trademarks of the
Apache Software Foundation
in the United States and/or other countries.