Add OpenTelemetry #11659
joaquin-diaz
started this conversation in
Proposals
Add OpenTelemetry
#11659
Replies: 1 comment
-
Do you have any code that you could share that's ready to use? Looking for solutions to instrument react-router codebase |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hi! In my company, we use OpenTelemetry for RUM (Real User Monitoring) by hooking into react-router's listeners, and we thought it might be useful for other users to have this built-in.
For those of you who are not familiar with OpenTelemetry, OpenTelemetry is an Observability framework and toolkit designed to create and manage telemetry data such as traces, metrics, and logs. You can read more about it in their docs.
Essentially, what I'm proposing is adding an event tracking when a user navigates to another route, with a couple of attributes showing the current and next path. I'm following the OpenTelemetry Instrumentation docs, and I think it's worth mentioning that all these API calls are no-op for users without the OpenTelemetry SDK integrated into their apps. Meaning, this will not affect users without OpenTelemetry, although they'll get the
5.4kB
extra size in the bundle (minified, and gzipped).For example:
We could call this function where the handler for navigation is in the
RouterProvider
Then a user can do something like this to add a SpanContext
With OpenTelemetry quickly becoming the standard for backend observability, I believe there's an opportunity to do the same on the client side so that we can establish a consistent standard across the entire stack. Implementing this would enable users to have zero-code instrumentation for react-router and, hopefully, make it easier for frontend observability to gain traction within the community.
I'm happy to discuss further why I think this could be useful and which other spans/attributes could be added in the future, but I believe this is a good starting point
Thanks!
Beta Was this translation helpful? Give feedback.
All reactions