DataDog / dd-trace-rb

Datadog Tracing Ruby Client
https://docs.datadoghq.com/tracing/
Other
299 stars 368 forks source link

Resource tagging/management of Rails Engines dynamically mounted on initialization (SubSystem Resources) #3635

Open davidhatten opened 1 month ago

davidhatten commented 1 month ago

Is your feature request related to a problem? Please describe. Problem: I mount engines to my Rails app which are entirely defined within an external gem (ex: Flipper UI, Sidekiq UI). When Datadog attempts to process the users making a request to one of these engines via link on the app dashboard UI, but Datadog groups the resource as a Rack request using the quantized name (GET 304) instead of something like Flipper#features (as though it were a proper resource defined by the application)

Describe the goal of the feature To be able to view Engine-based resources as distinct traffic, labeled like the rest of my rails resources that Datadog shows me on the Service. EX: something like Flipper#features instead of a resource name of GET 304 with the path_group inside the trace being my info

Describe alternatives you've considered I've played with the after_request hook to try to manually tag the traces, but that's going away in a future version.

I could try to monkey-patch something into the gems but that's fragile and opaque, and would have to be custom for each gem.

Additional context I've specified flipper, but I am also doing this with the sidekiq UI.

The app in question does not run sidekiq or flipper itself either.

Basic code example:

routes.rb
...
mount Flipper::UI.app(flipper_adapter), at: '/flipper/my_app'
...

datadog.rb
...
c.tracing.instrument rails
...

How does datadog help you? Love the profiling especially, incredible tool for checking behaviors and visualizing problems you don't know you have

marcotc commented 1 month ago

Hey @davidhatten, would be fair to summarize this as having applications there mounted separately from your main Rails application (ex: Flipper UI, Sidekiq UI) be displayed separately from the main Rails application requests?

For example: Flipper UI or Sidekiq UI would be the trace resource name for these mounted 3rd-party applications, in order to clearly show that they are not yet another Rack request or Rail controller from the main application.

davidhatten commented 1 month ago

Hello! That summary is exactly correct from top to bottom!

The only thing I would add is that currently, the trace/resource name for these mounted 3rd-party applications is GET 302, GET 304, GET 202, etc etc.

Your suggestion of "Flipper UI/Sidekiq UI" would definitely be enough to work in my current workflow.

Thank you!