Hello there Tom here from AppSignal.com.
We have an Hanami integration for our APM, and I鈥檓 refactoring it so it鈥檚 not/less reliant on monkeypatching Hanami, using Rack middleware and request metadata instead.
I鈥檓 most of the way there, but the only metadata I鈥檓 missing is the name of the Action class to group requests we monitor per Action class.
Is there a way to get the action class instance from the Hanami request object or router somehow?
For example: in Rails there鈥檚 an action_controller.instance
key on the request environment we can fetch this information from. A dry monitor event with this information in the payload would also work.
I tried using the router like app.router.recognize("/")
, but this doesn鈥檛 return any route metadata like the action class or route name.
I listened to the dry-monitor events for Rack, but this only included timings and response status, which we鈥檒l collect in the middleware. I couldn鈥檛 find any other events that include information about the action.
Here鈥檚 my PR with the work so far on our Ruby gem: Update Hanami to use Rack middleware by tombruijn 路 Pull Request #1113 路 appsignal/appsignal-ruby 路 GitHub
It only has one monkeypatch left in the lib/appsignal/integrations/hanami.rb
file to set the action name.
Any help is appreciated!