add tracer.trace() and tracer.wrap() as high level APIs#457
Conversation
gbbr
left a comment
There was a problem hiding this comment.
As requested, left some nits. I think this is great to have such thorough documentation making it crystal clear what's happening.
|
👍 |
|
One thing I'm not sure is what should the default resource name be? Right now it's the default from the tracer. @brettlangdon Thoughts? |
|
@rochdev in |
|
@brettlangdon This is the same right now as it's the tracer default, but I was wondering if we could use a smarter default for |
|
Yeah, that is at least consistent with the other tracers, not sure we need to try and be fancy here. |
This PR adds a
tracer.trace()andtracer.wrap()as high level APIs to make it easier to do manual instrumentation without having to manage the span and scope lifecycle manually.For example, the following are equivalent:
tracer.trace()
tracer.wrap()
It also allows to wait for a promise to be resolved or a callback to be called before finishing the span, which makes it a lot simpler to manually instrument asynchronous operations.
For example, the following are equivalent for wrapping a function that returns a promise: