Better Appsignal logs for Her

Josua Schmid
2 min readApr 30, 2020

Her is a Ruby gem which maps REST resources to Ruby objects. We use it to conveniently consume APIs. Appsignal on the other hand is a software monitoring service. We use the Ruby integration to log slow requests in our Rails app. So each time Her makes a request to our APIs, Appsignal tracks that. On the dashboard this looks like this:

Appsignal instrumentation log for slow requests
Standard Appsignal instrumentation logs for slow requests with only method, protocol and host

It would be nice to have a bit more information here. While we could use Appsignal.instrument in our Her base model to manually inject some more context, there’s a nice out-of-the box solution for that. There are three things we need to have in mind for that:

The only thing we need to do, is to activate Faraday::Request::Instrumentation for Her in its setup code:

Her::API.setup url: 'https://api.example.com' do |c|

c.use Faraday::Request::Instrumentation

end

After this, your Appsignal request logs will include an new tree node request.faraday. It includes now method, protocol, host and path — how nice!

Faraday instrumentation in Appsignal: now with more information

This is only the map to the rabbit hole. You can get wild with your own Rack middleware for Her or Faraday, with ActiveSupport::Notifications or directly with Appsignal’s powerful helpers like method instrumentation.

--

--