-
-
Notifications
You must be signed in to change notification settings - Fork 111
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add the action instance to the request environment #446
Conversation
I created a [new topic] on the Hanami Discourse about improving the AppSignal APM instrumentation. To group requests, we would like to know what action it took place in. This information is currently not available in the request environment. For us, the easiest would be to access the action instance. That gives us the class information and a way to access the `params_class` to fetch all the parameters of the request: query params and the body payload. This change adds the action instance on a new request environment key `hanami.action_instance`. [new topic]: https://discourse.hanamirb.org/t/questions-for-improving-the-appsignal-apm-integration-with-hanami-2/989/3 I had to update one test to not fail on the action instance being returned, which is not important for that spec I think. Closes hanami#445
This way we don’t interfere with the expected contents of params when actions are unit tested manually and params are passed as a plain hash.
6a329ea
to
7bd7802
Compare
Hi @tombruijn!! Thanks for your patience with this one. The Hanami 2.2 release is happening in a couple of days, and I've found myself with enough time to look at getting this PR in. I'd done some changes to the params handling and tests in this repo, so I've rebased over the main branch and force pushed to this PR's branch, I hope you don't mind. I've also made one other change (this commit): I delayed setting I've looked at the way you inspect the env for Rails' I'm sorry for the short notice, but if you can confirm this in the next day or two, I'll be able to include this in the Hanami 2.2 release, which would be wonderful 😄 Thanks! |
You know what? I might just go ahead and merge this. I suspect it'll still do the trick, and if we need to adjust it, that's easy to do in a patch release :) |
Hi @timriley! That seems good 👍 Most of our instrumentations set things like the action name after the request is done already. We've found a lot of libraries don't know things like the action name, parsed params, route name, etc. beforehand, so our gem can handle this order of data being available. Thanks for updating it and merging it! We'll update our Ruby gem to take advantage of it so we have to do no/less monkeypatching for Hanami 😁 |
I created a new topic on the Hanami Discourse about improving the AppSignal APM instrumentation.
To group requests, we would like to know what action it took place in. This information is currently not available in the request environment.
For us, the easiest would be to access the action instance. That gives us the class information and a way to access the
params_class
to fetch all the parameters of the request: query params and the body payload.This change adds the action instance on a new request environment key
hanami.action_instance
.I had to update one test to not fail on the action instance being returned, which is not important for that spec I think.
Closes #445
Let me know what you think!