feat(log): added gRPC access logs

What?

Added gRPC access logging support

Why?

This merge request introduces a new logging system specifically for gRPC services, similar to HTTP server access logs.

The new functionality automatically logs details about incoming gRPC requests, including:

  • Correlation IDs for request tracing
  • Client IP addresses
  • Request sizes
  • Response status codes

The logging system is configurable, allowing developers to include or exclude specific fields. All changes maintain backward compatibility.

Decision log

  • HTTP/gRPC feature parity: We kept the gRPC logging functionality in labkit to maintain feature parity with the HTTP logger. The new gRPC logging package includes features like XFFAllowed and TrustedProxies to ensure consistency.

  • Response size exclusion: We decided not to include response_size in the logs because the standard middleware library omits this feature due to performance considerations. We followed the library maintainers' recommendations.

  • Package structure: Similar to the grpccorrelation package, we split the HTTP and gRPC logging packages into gitlab.com/gitlab-org/labkit/log and gitlab.com/gitlab-org/labkit/log/grpc to maintain a consistent package structure. The HTTP logger package remains unchanged to preserve backward compatibility.

Testing

Test suite: https://gitlab.com/vglafirov/grpc-access-logs/-/tree/main?ref_type=heads

  1. git clone git@gitlab.com:vglafirov/grpc-access-logs.git
  2. make test

Part of: gitlab-com/gl-infra/tenant-scale/cells-infrastructure/team#457 (closed)

Notes

The backward compatibility pipeline is currently failing due to an outdated Go version. This is unrelated to the changes introduced by this MR and will be resolved later. See draft MR.

Edited by Vladimir Glafirov

Merge request reports

Loading