Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

@opentelemetry/instrumentation-express Route and Span Name is incorrect #2102

Open
ray58750034 opened this issue Apr 16, 2024 · 0 comments
Open
Labels
bug Something isn't working

Comments

@ray58750034
Copy link

ray58750034 commented Apr 16, 2024

What version of OpenTelemetry are you using?

@opentelemetry/api 1.8.0
@opentelemetry/instrumentation-express  >0.33.1 & <=0.37.0

What version of Node are you using?

v18.18.2

What did you do?

I use following code to reproduce the issue

(async () => {
  const express = require('express');
  const http = require('http');
  const app = express();
  const port = 6666;
  const server = app.listen(port);

  router.all('/foo', (req, res, next) => {
    res.json({ hello: 'yes' });
    res.end();
    next();
  });

  app.use((req, res, next) => {
    console.log('-------- post handler');
    next();
  });

  http
    .request({
      method: 'POST',
      hostname: '127.0.0.1',
      port,
      path: '/foo'
    })
    .end();

  await TimeUtil.sleep(200);
})();

What did you expect to see?

Span name: POST /foo

What did you see instead?

Span name: POST /

Additional context

I try to debug this issue and found that line 201 change in this commit removed type === ExpressLayerType.REQUEST_HANDLER condition that would cause route to be overwrite in middleware after request handler.

@ray58750034 ray58750034 added the bug Something isn't working label Apr 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant