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

[Koa] Some koa middleware spans have weird data #2220

Open
mydea opened this issue May 17, 2024 · 0 comments
Open

[Koa] Some koa middleware spans have weird data #2220

mydea opened this issue May 17, 2024 · 0 comments
Labels

Comments

@mydea
Copy link
Contributor

mydea commented May 17, 2024

We are seeing some spans emitted by the koa instrumentation that look like this:

{
  attributes: {
      'koa.name': '',
      'koa.type': 'middleware',
    },
    name: 'middleware - ',
}

Which I guess comes from here: https://github.com/open-telemetry/opentelemetry-js-contrib/blob/main/plugins/node/opentelemetry-instrumentation-koa/src/utils.ts#L43

I guess there needs to be some more checking there, and/or some fallback behavior if layer.name is empty 🤔

The app that triggers this span is basically:

const Koa = require('koa');
const Router = require('@koa/router');

const app1 = new Koa();

router1.get('/test-transaction', ctx => {
  // do something here...

  ctx.body = {};
});

app1.use(router1.routes()).use(router1.allowedMethods());

app1.listen(port1);

And then visiting /test-transaction.

Note that the router span seems correct:

{
  attributes: {
    'http.route': '/test-transaction',
    'koa.name': '/test-transaction',
    'koa.type': 'router',
  },
  name: 'router - /test-transaction',
}
@mydea mydea added the bug Something isn't working label May 17, 2024
mydea added a commit to getsentry/sentry-javascript that referenced this issue May 21, 2024
This ensures we have correct op, name & origin for all koa middleware
spans.

I also updated the E2E test to actually check this as well.

I also noticed a problem in the instrumentation where the name is
sometimes empty here, opened an upstream issue:
open-telemetry/opentelemetry-js-contrib#2220
to look into this.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants