Skip to content

Koa integration doesn't work or documentation is wrong #17441

@mahnunchik

Description

@mahnunchik

Is there an existing issue for this?

How do you use Sentry?

Sentry Saas (sentry.io)

Which SDK are you using?

@sentry/node - koa

SDK Version

10.5.0

Framework Version

@sentry/node 10.5.0

Link to Sentry event

issues/6828293379/events/54291303047a4f4da02675d234af3250/ project=4509886747639808

Reproduction Example/SDK Setup

import Koa from 'koa';
import Router from '@koa/router';

import * as Sentry from "@sentry/node";

// Ensure to call this before importing any other modules!
Sentry.init({
  dsn: "___",

  // Adds request headers and IP for users, for more info visit:
  // https://docs.sentry.io/platforms/javascript/guides/node/configuration/options/#sendDefaultPii
  sendDefaultPii: true,
});


const app = new Koa();

Sentry.setupKoaErrorHandler(app);

const router = new Router();

router.get('/', (ctx, next) => {
  ctx.body = { status: 'ok' };
});

router.get('/foobar', (ctx, next) => {
  throw new Error('3 err');
  ctx.body = { foo: 'bar' };
});

app
  .use(router.routes())
  .use(router.allowedMethods());

app.listen(3000);

Steps to Reproduce

  1. setup sdk
  2. open http://localhost:3000/foobar

Expected Result

According to the documentation Koa integration is enabled by default https://docs.sentry.io/platforms/javascript/guides/koa/configuration/integrations/koa/

So method and route should be reported

getIsolationScope().setTransactionName(`${method} ${route}`);

Actual Result

No method and route data in issue

Metadata

Metadata

Assignees

No one assigned

    Projects

    Status

    Waiting for: Community

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions