-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Support/make use of Async Hooks #3660
Comments
I will reply in detail later bit we are already using domains to solve this. Express sets up a domain per request and for as long as you use domains correctly we should be using the tight isolation. We are going to also support async hooks in the future but fundamentally they were solving the same issue. |
Could you have a look at #2172 (comment)? I tried using domains but couldn't get it to work. Maybe I'm doing it wrong? |
I can confirm elastic/apm-agent-nodejs (which we've been using for some time before considering sentry's offering) works like a charm. Is this connected to the strange bit of code that's appears to be needed to make a transaction async aware? I've used a few APM libraries now and this is the first time I had to include this just to have what I consider to be default/basic behaviour to kick in:
|
You need to wrap your code in |
There is no function to wrap in hapi's case, as far as I understood domain.enter would do the same, is that not the case? https://nodejs.org/docs/latest-v14.x/api/domain.html#domain_domain_enter (it seems like breadcrumbs do work better with the domain code but not tested in depth) |
Another thing I found that might be interesting for this is https://github.com/open-telemetry/opentelemetry-js/tree/main/packages/opentelemetry-context-async-hooks |
I've never built anything with Hapi before, so I don't know it's architecture, but moving away from domains in favor of async_hooks is definitely on our roadmap. It won't be a quick think though, as domains are in the very core of the SDK, and a lot of moving pieces rely on them. From what I see https://github.com/hydra-newmedia/hapi-sentry are also using domains in their plugin, but not sure how accurate it is. If there's something specific that's currently not working, I'm more than happy to look into finding a workaround if a small repro case is provided. |
I understand it won't be quick but I don't see the current implementation working. I also based my implementation on https://github.com/hydra-newmedia/hapi-sentry. |
Thanks, I totally get your use case explanation, but because I've never used Hapi before, could you please gather those pieces you described above together and put into a single gist file that I could run locally? |
@kamilogorek I unfortunately don't have the time atm to provide you with a full example. |
Hi! is this been worked on? thanks in advance! |
This issue has gone three weeks without activity. In another week, I will close it. But! If you comment or otherwise update it, I will reset the clock, and if you label it "A weed is but an unloved flower." ― Ella Wheeler Wilcox 🥀 |
Please don't close this issue, it is still relevant |
The big problem that The other thing about this is that people who care about this problem are very likely already using For my use case it would be enough if Sentry provided a way to register a function to be called when it needs to get the current scope, then I could just wrap that up with my own context provider and everything would work. Right now what happens (mostly) is that it calls You can almost get it to work by replacing the |
For anyone else who ends up here hoping to find a way to make Sentry work with |
Any updates? |
Hey - we're finally working on this! Take a look at #7691 to see our migration path. This should be fully backwards compat, and require no changes to existing code. Node 12 and below will still continue using domains, Node 14 and above will get Would also like to remind everyone though that domains actually use |
With the If you want to manually wrap methods in an async context to isolate breadcrumbs/scope/spans, you can use |
Package + Version
@sentry/browser
@sentry/node
raven-js
raven-node
(raven for node)Version:
Description
I've talked about this extensivly in #2172.
But since that issue seems to have stalled and others are also seeming to request this (see #2817 (comment)) I thought it would be nicer to open an official dedicated issue.
Why:
Some examples of agents who do use Async Hooks:
Atm I don't see how one can use Sentry's performance offering using Node without this being fixed (unless you only serve 1 request at the same time, which isn't realistic).
I hope I'm missing something since we do want to use your offering but don't see a way of doing that at this time.
The text was updated successfully, but these errors were encountered: