Skip to content

Add Koa auto tracing documentation #1781

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

Closed
wants to merge 3 commits into from

Conversation

arthurM2x
Copy link
Contributor

Also working on some auto span on monitoring middleware and routers, might add later

Also working on some auto span on monitoring middleware and routers, might add later
ctx.__sentry_transaction = transaction
await next()

// if using koa router, a nicer way to capture transaction using th ematched route
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// if using koa router, a nicer way to capture transaction using th ematched route
// if using koa router, a nicer way to capture transaction using the matched route

@dashed
Copy link
Member

dashed commented Jun 24, 2020

@arthurM2x Nice! Just to confirm, did this setup work for your Koa app?

I tried setting up a simple Koa app using the example you wrote, and added a simple handler:

app.use(async ctx => {
  ctx.body = 'Hello World';
});

which generated an error:

$ node index.js
Error: Express middleware takes 2-4 arguments. Got: 1
    at wrap (/sentry/koa-apm/node_modules/@sentry/apm/dist/integrations/express.js:101:19)
    at /sentry/koa-apm/node_modules/@sentry/apm/dist/integrations/express.js:118:20

However, it works fine if I added an un-used 2nd parameter:

app.use(async (ctx, next) => {
  ctx.body = 'Hello World';
});

Hence I'm unsure if the Apm.Integrations.Express integration officially supports Koa.

@rhcarvalho @kamilogorek @HazAT can you confirm?

// enable HTTP calls tracing
new Sentry.Integrations.Http({ tracing: true }),
// enable Express.js middleware tracing
new Apm.Integrations.Express({ app })
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Apm is undefined here.

my bad, copy pasted the above code without thinking
@arthurM2x
Copy link
Contributor Author

My bad, copied the code above without removing the express integration part, the middleware works in my koa application

@dashed
Copy link
Member

dashed commented Jun 24, 2020

@arthurM2x thanks! just a heads up; my colleague, @doralchan, is in the midst of a major refactor for the Performance and Tracing docs: #1782

That might take priority and is slated to be merged soon. The PR should enable any new additions of tracing docs for specific frameworks/libraries such as Koa.

You'll need to rebase your changes after that PR is merged.

@dashed
Copy link
Member

dashed commented Jun 26, 2020

@arthurM2x Looks like the changes at #1782 are merged. would you be able to move the Koa tracing content to this folder? https://github.com/getsentry/sentry-docs/tree/master/src/collections/_documentation/performance-monitoring/configuration

@arthurM2x
Copy link
Contributor Author

Going to close this one as super seeded by #1804

@arthurM2x arthurM2x closed this Jun 29, 2020
@github-actions github-actions bot locked and limited conversation to collaborators Dec 16, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants