-
Notifications
You must be signed in to change notification settings - Fork 47
Question: Why does the API require the developer to manually close spans? #164
Comments
Code I ended up with to bake some expected behaviour into tracing calls
|
To be honest this is question (is the api easily usable for end user use-cases) is poping up time and time again for different method around the tracing API. There is nothing wrong to make a wrapper to match your use-case (i did the same at my company). |
Thanks for the reply @vmarchaud -- it's valuable to confirm I didn't miss something! Happy for this one to be closed unless there is value in using it to host further discussion on the topic |
I think there is value. I would prefer to see these APIs get implemented. I was originally the one that delayed these convenience APIs because there was some talk of having them specified for all languages. I didn't want to implement something like Now I think its pretty clear these convenience APIs are not going to be added to spec and we should be free to implement them as we choose. You can see #163 for an example of that, and I would welcome a mechanism to easily wrap an operation in a span like I think we can close this issue since the question is addressed and we can create new issues for proposed convenience APIs |
I still think that we should be careful in which utils we add in
Besides that it allows to add more and even opinionated helpers as users can then choose to use API directly or choose one of the addon packages available in the wild. This doesn't imply that we should not add simple helper here. |
Context 🧠
I'm working to convert some TypeScript code from being instrumented with Datadog
dd-trace
to OpenTelemetry. I'm finding the tracing API not very friendly or straightforward because of the need to manuallyend()
spans. I read through the discussion at open-telemetry/opentelemetry-js#1923 which highlighted that implementation in other languages (such as Ruby) don't have this issue.With
dd-trace
, once things are initialised then I can easily manually instrument as follows:As part of that API I get this useful behaviour based on the execution of the wrapped callback:
Question ❓
OpenTelemetry is providing me with
tracer.startActiveSpan
but I don't understand why the responsibility is left with me to end the resulting span. For most cases, isn't it reasonable to assume that once the callback context ends I want the span to end? And if it throws to mark the span with the error? Otherwise why the callback-style API?I'm finding myself writing a trace wrapper to make the API workable and apply boilerplate such as error handling to close spans as errors etc. and I don't know why I need to?
The text was updated successfully, but these errors were encountered: