-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
feat: Add convenience helper functions for apm #2556
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
Conversation
97e1d50
to
46a5abb
Compare
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.
I'm in favor of something in this direction, just dislike the span x transaction. It means "library" code needs to stick with span, and somewhere in the top level users need to create a transaction; feels like extra cognitive burden.
} | ||
|
||
/** | ||
* Create a span from a callback. Make sure you wrap you `withSpan` calls into a transaction. |
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.
I have a draft of this idea but without the caveat of "make sure you wrap with a transaction".
Generally this is one of the reasons I don't like the transaction x span distinction, because it makes it harder to arbitrarily wrap code.
True, I also don't like it, the problem is we can't get rid of a Transaction and the users need to understand the concept because it has more semantic behind it. |
I like it 👍 |
I am going to close this PR since this one #2600 is the successor |
I want to open a discussion if we want to support such API.
This PR introduced two helper functions
withTransaction
&withSpan
and a helper function on the
Span
to create a child with a callbackspan.withChild
.Functionally can be found in the test cases.
Here is just a brief example of what would be possible with these helpers:
Given:
vs. without helpers
It mostly helps people not to forget to call
finish()
.The idea spawned from a random conversation in Slack.