-
Notifications
You must be signed in to change notification settings - Fork 372
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
Accessing the root span to mark it as "error" #2740
Comments
Hi @timmhirsens, thanks for bringing this up. Ruby does not expose the root span through the public API, by design (mostly to prevent spaghetti code and other non-deterministic behavior.) To be clear, we consider "root spans" to be an internal detail, and we do not want users to access or modify the root span directly (by some means other than Instead, we have a Our intent is not to preserve "root span aware behavior" but to allow users to specify "trace-level behavior". We prefer users use this While today we have If these limitations are reasonable and still satisfy the use case, then we could consider implementing this. |
@timmhirsens Any thoughts on the suggestion shared above? |
I was stumbling on this issue today. After upgrading to ddtrace v1 we start seeing exceptions where our old code is trying to call |
@bquorning That shouldn't have been an issue, as
|
Yeah sorry, I left out the important details 😄 Based on https://github.com/DataDog/dd-trace-rb/blob/master/docs/UpgradeGuide.md#trace-api we switched from using |
@delner sorry for the late reply, i was not working on the related ruby project for a while. The solution you proposed sounds reasonable. What APIs would |
The I also implemented it manually for now. |
Hi @timmhirsens @bquorning I'm new to Datadog and seeing a similar issue where I'm tagging my exceptions but they're not making their way into |
I am currently working on the same kind of problem @aenand. I can set_error on the active_span and this error is indeed set and viewable in the logs. However in the I suspected it was because the overarching |
Hey @dostaglou I spoke with a few colleagues and they suggested trying to set the Let us know if that works for you :) |
Hey @ivoanjo sorry if I missed this but where would I set the |
It should go on the same span as you're calling |
Answering the original question, I have been able to mark the trace with an error by doing: root_span = Datadog::Tracing.active_trace&.send(:root_span)
root_span&.set_error(exception)
root_span&.set_tag('track_error', true) # Shows the error also in the errors section Doing that the whole trace appears as errored. It's not great to mess with the internal API, but using the |
In our Java Applications we do trace caught exceptions the following way:
This leads to both the erroneous span and the root span in trace to show up as having an error. This leads to the caught exceptions showing up in the "Error Tracking" view in the Datadog UI.
What would be the equivalent in the ruby trace? Currently we only do
Which marks the erroneous span as error but not the root span, which means the errors dont show up in the error tracking view and, probably (?), won't trigger any monitors.
What is the correct way to trace caught errors in ruby using datadog?
The text was updated successfully, but these errors were encountered: