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
labkitto maintain feature parity with the HTTP logger. The new gRPC logging package includes features likeXFFAllowedandTrustedProxiesto ensure consistency. -
Response size exclusion: We decided not to include
response_sizein 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
grpccorrelationpackage, we split the HTTP and gRPC logging packages intogitlab.com/gitlab-org/labkit/logandgitlab.com/gitlab-org/labkit/log/grpcto 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
git clone git@gitlab.com:vglafirov/grpc-access-logs.gitmake 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.