Hello there
Tom here from AppSignal.com.
We have an Hanami integration for our APM, and I’m refactoring it so it’s not/less reliant on monkeypatching Hanami, using Rack middleware and request metadata instead.
I’m most of the way there, but the only metadata I’m 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’s 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’t 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’ll collect in the middleware. I couldn’t find any other events that include information about the action.
Here’s 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!