Skip to content

Add instrumentation for ETag cache hits (log 304, 429 responses)

Aakriti Gupta requested to merge ag-log-304-from-etag-caching-middleware into master

What does this MR do?

Original Issue: #26941 (closed)

This MR adds instrumentation for ETag Cache hits. This middleware short-circuits Lograge, hence Lograge does not pick up these 304 or 429 responses.

Here, we inject an invent once cache has been hit.

Ideally, ActiveSupport::Notifications.instrument... would be called with a block where the request takes place, but since we arrive as a conclusion to respond with 304 over multiple if-then-else blocks, it seems better to send out the notification after the response has been decided.

We want the logging format to be as close to a response log format as possibly, e.g. Completed 304..., so we send the same event as sent out from controllers.

The controller and action are not known at this point of execution, so we set them both as unknown. The path can still be used to determine which requests hit cache most.

Screenshots

Does this MR meet the acceptance criteria?

Conformity

Availability and Testing

Security

If this MR contains changes to processing or storing of credentials or tokens, authorization and authentication methods and other items described in the security review guidelines:

  • Label as security and @ mention @gitlab-com/gl-security/appsec
  • The MR includes necessary changes to maintain consistency between UI, API, email, or other methods
  • Security reports checked/validated by a reviewer from the AppSec team
Edited by Aakriti Gupta

Merge request reports