Our latest version of our JS SDKs
(@sentry/browser>= 5.2, @sentry/node>= 5.2) and sentry-python>= 0.7.13 now come with a Tracing integration.
What is tracing?
Our first version of tracing is there to correlate errors between different platforms. So for example you are using our JS SDK in the frontend and the Python SDK in the backend. With that we are able to tell that the frontend error was caused by a specific error on the backend.
We already use it ourself and in the following screenshot you are able to see that a query was causing and 500 internal server error that was calso causing and frontend error. This information can be really valuable.
What do I need to do to get this?
So this is on purpose not fully documented yet since we will ship more features + depending on the feedback we get things might change. Also the story/UX in Sentry itself is nearly not finished we are working on that. Right now only tags will be emitted to match these issues.
Sentry.init({
dsn: "YOUR DSN",
integrations: [
new Tracing(),
],
});
With that we instrument all outgoing XHR / fetch requests.
Make sure to have the counterpart on the server setup, if you have a node server running our express handlers it should already work.
Using Python? If youâre using one of our web framework integrations it will automatically work with no additional configuration.
If you read this far itâs already amazing and we would like to get your opinion about this. Support for the other SDKs will come once things stabilize.
Here are the corresponding PRs integrating this into Sentry:
You are right they use the same DSN but note the filter on the right hand side. The issues also have the same trace ID. The sdks automatically correlate the events.
So on the screenshot you can see multiple issues that all have the same trace (see content of the search field).
When using the tracing integration we emit a âtraceâ tag which can be used to search for issues that belong to the same trace (across different projects / platforms). That way you are able to tell for example if your backend caused a frontend error.
So regarding 1.
This depends on your setup, if you log all incoming headers you will see the trace_id but we are not logging anything anywhere by default.
Regarding 2.
Yes, you can do it now like (this may change in the future, thatâs why itâs not documented yet):
import * as Sentry from '@sentry/browser';
import { Span } from '@sentry/hub';
Sentry.configureScope(scope => {
scope.setSpan(new Span('YOUR TRACE ID'));
});
Okay, thanks! So we can grab the trace information from the headers (assuming those header names remain the same). Also, what is the difference between the span_id and the trace_id? How should they each be thought of / which should be of interest to users?
The header might change very soon to itâs final form. So please be aware of that.
trace_id can be seen as something similar to a session_id, all spans that are in a trace have the same trace_id. A span_id uniquely identifies a span which can be seen as an action during a trace.
The use case is simply to include the trace id in log messages, e.g. as discussed in this recent talk at PyCon 2019 (US) (Alex Landau - Building a Culture of Observability - https://www.youtube.com/watch?v=-6Hk9rcgM94&t=7m30s - direct link to portion of talk mentioning trace idâs), and have it match what Sentry uses.
Two cases that can come up that are related to this are: (1) maybe you want to start logging before Sentry has chosen a trace id, which is the case where you might yourself want to set the trace id that Sentry should use, and (2) if you cross a service boundary where youâre not using Sentry, and come back, youâd want to be able to link that back to Sentry and have Sentry resume picking that up. Hence it would be good to know what headers, etc. one should use to let Sentry know.
Any easily generated format should be fine (e.g. UUID).
This is really amazing stuff and would love to use this with the Java SDK. What is the current status of the tracing capability, @HazAT? And/or is there a newer/better way to do cross-service request tracing?
The plan is to gradually roll out support for other SDKs over time. We want to make sure the overall experience is good before we support all SDKs. But rest assured, once we are confident enough that the âAPMâ story in Sentry is good enough, Java is high on our list for SDKs to support this.
Would love to implement this, but it looks like the tracing integration has been moved to the APM package @HazAT? Is the automatic tracing still working? If so - are there any additional steps required to get the error tracing up and running for JS Browser and server running express after the move?
@HazAT: I am using React js in frontend and Koa as backend. Using same dns for both of them⌠But I donât see spans child created for spans and also db query detail??