-
Notifications
You must be signed in to change notification settings - Fork 47
Conversation
Add withSpan helper to execute a function on a context holding a given span.
Codecov Report
@@ Coverage Diff @@
## main #7 +/- ##
==========================================
+ Coverage 89.82% 89.95% +0.13%
==========================================
Files 33 33
Lines 452 458 +6
Branches 77 77
==========================================
+ Hits 406 412 +6
Misses 46 46
Continue to review full report at Codecov.
|
hmm I created an issue #1923 with a purpose to come to an agreement first and after this add it. But we shall all agreed for it beforehand not to duplicate our work, but here I see you just added something already, please assign yrself to a task first next time, thx. |
I think we had generally agreed on |
/cc @tedsuo |
Yes but it was added on context and we were discussing to have it directly on api
|
In open-telemetry/opentelemetry-js#1923 there was no final agreement. We had at least
This PR is to nail this down. As indicated above I'm happy to move it if this is preferred. I decided to go for a PR instead an extra issue as the amount of work to add this is small but it has the advantage that people can try it and comment at the source itself. Regarding the location. In general I'm in favor of namespaces therefore it would be // withSpan on context but getSpan on api
api.context.withSpan(span, () => {
// non context namespace here...
const span = api.getSpan(context.active());
}); |
I'm in favor of namespacing too so either |
Exactly, so I don't understand why did you create a PR and just chose one. The main idea of adding helper is to help the end user to keep things simple, post from @tedsuo simply accelerated the discussion again, but if you pay a closer look at last comments |
anyone feel free to grap the change from my branch. I have no motivation to continue with this. |
Add
withSpan
helper to execute a function on a context holding a given span.fixes: open-telemetry/opentelemetry-js#1923
I put the new API next to the existing helpers
setSpan
,getSpan
,... as it seem to me the best match currently.open-telemetry/opentelemetry-js#1750 discusses to use more namespacing but as of now this seems the best place form user point of view.
In open-telemetry/opentelemetry-js#1923 there were several proposals where to place it. I'm fine with moving it if consensus is on
api.trace
orapi.context
or ...