• Sean McGivern's avatar
    Always log remote_ip and client_id for API routes · 54a75245
    Sean McGivern authored
    Some API requests are handled by Grape directly without ever going
    through `before` blocks. We can still log `remote_ip` (and hence
    `client_id`) for those requests, as that doesn't depend on anything
    application-specific.
    
    We handle this by putting it in the logger itself as well as the
    `before` block. This is because `client_id` is computed based on an
    ApplicationContext instance, but this is backed by a Labkit::Context. A
    Labkit::Context isn't aware of our models, and so `user` is only
    inherited as a string, not an object - which means that `client_id`
    could end up incorrectly using the IP rather than the user ID.
    54a75245
base_spec.rb 45.5 KB