-
Notifications
You must be signed in to change notification settings - Fork 806
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
fix(asynchooks-scope): fix context loss using .with() #1101 #1099
fix(asynchooks-scope): fix context loss using .with() #1101 #1099
Conversation
669a33a
to
77b67fe
Compare
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
e9fb5fc
to
e0f1bc5
Compare
e0f1bc5
to
eceac37
Compare
Codecov Report
@@ Coverage Diff @@
## master #1099 +/- ##
==========================================
- Coverage 92.36% 92.32% -0.05%
==========================================
Files 115 115
Lines 3407 3389 -18
Branches 686 683 -3
==========================================
- Hits 3147 3129 -18
Misses 260 260
|
eceac37
to
006a5ac
Compare
Good news, i found a way to make |
006a5ac
to
f0b4c0e
Compare
packages/opentelemetry-context-async-hooks/src/AsyncHooksContextManager.ts
Outdated
Show resolved
Hide resolved
packages/opentelemetry-context-async-hooks/src/AsyncHooksContextManager.ts
Outdated
Show resolved
Hide resolved
packages/opentelemetry-context-async-hooks/src/AsyncHooksContextManager.ts
Show resolved
Hide resolved
packages/opentelemetry-context-async-hooks/src/AsyncHooksContextManager.ts
Show resolved
Hide resolved
packages/opentelemetry-context-async-hooks/src/AsyncHooksContextManager.ts
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is great work thanks so much for this
@open-telemetry/javascript-approvers this is very high priority. I want to get this merged and released as a patch release which means not merging any breaking changes until this is in. @mayurkale22 wdyt? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
looks great
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice!
I totally agree. In the next release, we can try to combine all the breaking changes (mostly related to metrics work). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM! Out of curiosity, what's the perf difference with the added before/after hooks?
We don't really have a great way to compare the performance here, but it should be relatively minimal as they are only called when async contexts are created/destroyed. Sync function calls should have no performance impact from this. Moreover, even if there is a performance impact, correctness is more important than speed. |
My concern was more about the work done on entry/exit of the async context - with the introduction of the before and after hooks there is going to be some extra work for all network/fs/promise/async resource/etc work done by the runtime. These changes have perf implications for a user beyond how they interact with the OTel API. In my experience, the async hook overhead is smaller than the alternatives and the work in the hook is minimal so I'm not terribly concerned because I totally agree with you here.
It would be nice to have benchmarks for these kinds of things in the future, but considering it covers a gap in functionality maybe it's just gravy at this point. |
IMO if people want performance over UX (by UX i mean getting all traces automatically), they must not use the async hooks scope manager and trace manually the operations they want to.
I agree that we should have some benchmark in place, plus they are not really hard to implement. Ive opened #1123 |
Co-authored-by: Amir Blum <amir@aspecto.io> Co-authored-by: Valentin Marchaud <contact@vmarchaud.fr>
This one was kinda hard to debug and fix but it finally works !I had to remove different test cases that were working in the past:- cases where we expected that.bind
of a function will propagate the context across async operations, which is essentially leaking because.bind
is only synchronous.- cases where we wanted to usewithAsync
inside of awith
which doesn't work because as said above,with
is only sync.Started this refactor for #1013 but considering the bug in #1101 (that this refactor fixes) as discussed at the SIG, we should merge that first and then try to fixwithAsync
Lot of edit for this one but its worth, i found a way to fix the initial issue #752 without using
await
so i removedwithAsync
which should fixes #1013 and it works with #1101. Finally !closes #1101 #752 #1013