-
Notifications
You must be signed in to change notification settings - Fork 107
Description
Rails and other gems provide lots of instrumentation data through ActiveSupport::Notifications subscriptions.
For now I am mainly interested in instrumenting ViewComponent which already has instrumentation built in and provides all the data using ActiveSupport::Notifications. The notifications from ViewComponent are documented here. Right now, when we use lots of components all their time is recorded under View without any granularity visible in Scout UI.
Basic code to consume notifications looks like this:
ActiveSupport::Notifications.subscribe("render.view_component") do |event| # or !render.view_component
event.name # => "render.view_component"
event.duration # => 10 (in milliseconds)
event.allocations # => 1826 (objects)
event.payload # => { name: "MyComponent", identifier: "/Users/mona/project/app/components/my_component.rb" }
endLook at ActiveSupport::Notifications::Event to find all information that is available.
It would be great if Scout agent would provide a way to easily ingest data from ActiveSupport::Notifications. It could probably even subscribe to some of them by default when gems are detected (like ViewComponent).
I would be happy to try to implement proof of concept with some guidance or try any testing version you would have.
From what I can tell and from discussion with @lancetarn on Discord I adding children ScoutApm::Layers under the View one as components are rendered could be possible. Is this the way to go or should I explore anything else?