Skip to content

Route path URL is undefined #40

@askareija

Description

@askareija

What version of Elysia is running?

1.2.10

What platform is your computer?

Linux 6.9.3-76060903-generic x86_64 unknown

What steps can reproduce the bug?

  1. Call a route
  2. Check tracing backend (I'm using Jaeger)
  3. You will see "GET undefined" for route path

What is the expected behavior?

route path is not undefined.

What do you see instead?

gambar

gambar

Additional information

Packages installed:

Opentelemetry middleware:

import { opentelemetry } from '@elysiajs/opentelemetry';
import { OTLPTraceExporter } from '@opentelemetry/exporter-trace-otlp-http';
import { BatchSpanProcessor } from '@opentelemetry/sdk-trace-node';
import Elysia from 'elysia';
import { OTLP_TRACE_ENDPOINT, OTLP_TRACE_TOKEN } from '../constants';
import { MongooseInstrumentation } from '@opentelemetry/instrumentation-mongoose';
import { PinoInstrumentation } from '@opentelemetry/instrumentation-pino';

const otelMiddleware = new Elysia({
    name: 'opentelemetry-middleware',
}).use(opentelemetry({
    serviceName: 'main-backend',
    instrumentations: [
        new MongooseInstrumentation(),
        new PinoInstrumentation(),
    ],
    spanProcessors: [
        new BatchSpanProcessor(new OTLPTraceExporter({
            url: `${OTLP_TRACE_ENDPOINT}`,
            // headers: {
            //     Authorization: `Bearer ${OTLP_TRACE_TOKEN}`,
            // }
        }))
    ]
}));

export default otelMiddleware;

Main elysia:

const app = new Elysia()
    .use(
        cors({
            methods: ['GET', 'POST', 'PUT', 'PATCH', 'DELETE', 'OPTIONS'],
            origin: ALLOWED_ORIGINS,
        }),
    )
    // SECTION: Use OpenTelemetry middleware
    .use(otelMiddleware)
    // !SECTION

    // SECTION: Importing controllers
    .use(usersController);

if (!IS_PRODUCTION) {
    app.use(swagger());
}

usersController:

const userService = new UserService();

const usersController = new Elysia({
    name: 'users-controller',
    prefix: '/users',
});

usersController
    .get('/', async ({ query }) => {
        const page = Number(query?.page) || 1;
        const limit = Number(query?.limit) || 10;
        return await record('getUsers', () => userService.getUsers(page, limit));
    })
    .post('/', async ({ body }) => {
        return await userService.createUser(body);
    })
    .get('/:id', async ({ params: { id } }) => {
        return await userService.getUserById(id);
    })
    .put('/:id', async ({ params: { id }, body }) => {
        return await userService.updateUser(id, body);
    })
    .delete('/:id', async ({ params: { id } }) => {
        return await userService.deleteUser(id);
    });

export default usersController;

Have you try removing the node_modules and bun.lockb and try again yet?

yes

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions