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

Add hooking for Closures #1904

Merged
merged 3 commits into from
Feb 9, 2023
Merged

Add hooking for Closures #1904

merged 3 commits into from
Feb 9, 2023

Conversation

bwoebi
Copy link
Collaborator

@bwoebi bwoebi commented Feb 3, 2023

Description

Extracted from my experiments with revolt; the DDTrace\install_hook() API now got proper instrumentation for Closures. Note that hooks applied to closures only apply to the lifetime of the specific hooked closure.

This makes it trivial to check with a WeakMap whether the Closure already has been hooked.

Additionally the DDTrace\HookData API got a span() method which must be called in the begin handler at least once if the hook is to be traced.

Readiness checklist

  • (only for Members) Changelog has been added to the release document.
  • Tests added for this feature/bug.

Reviewer checklist

  • Appropriate labels assigned.
  • Milestone is set.
  • Changelog has been added to the release document. For community contributors the reviewer is in charge of this task.

@bwoebi bwoebi added this to the 0.85.0 milestone Feb 3, 2023
@bwoebi bwoebi requested a review from a team as a code owner February 3, 2023 03:24
@bwoebi bwoebi force-pushed the bob/closure-hooking branch 3 times, most recently from 3365ebf to 1762539 Compare February 7, 2023 14:57
ext/hook/uhook.c Outdated Show resolved Hide resolved
@bwoebi bwoebi force-pushed the bob/closure-hooking branch from 1762539 to 510eeee Compare February 7, 2023 15:40
Copy link
Collaborator

@morrisonlevi morrisonlevi left a comment

Choose a reason for hiding this comment

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

We reviewed the code together over Zoom. There are some things like leaving code comments, but overall it looks good, as far as I can tell.

The ability to trace closures in important, so unless the overhead of doing this is too high, I don't see a reason to block this.

@morrisonlevi morrisonlevi added the 🍏 core Changes to the core tracing functionality label Feb 7, 2023
@bwoebi bwoebi force-pushed the bob/closure-hooking branch 3 times, most recently from 0078907 to 58f2bfd Compare February 9, 2023 00:41
Signed-off-by: Bob Weinand <bob.weinand@datadoghq.com>
Signed-off-by: Bob Weinand <bob.weinand@datadoghq.com>
@bwoebi bwoebi force-pushed the bob/closure-hooking branch 2 times, most recently from e3c710b to dad7ebe Compare February 9, 2023 22:27
Signed-off-by: Bob Weinand <bob.weinand@datadoghq.com>
@bwoebi bwoebi force-pushed the bob/closure-hooking branch from dad7ebe to bdcd0e3 Compare February 9, 2023 22:28
@bwoebi bwoebi merged commit 32c70fc into master Feb 9, 2023
@bwoebi bwoebi deleted the bob/closure-hooking branch February 9, 2023 23:17
@bwoebi bwoebi mentioned this pull request Mar 14, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🍏 core Changes to the core tracing functionality
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants