Documentation ¶
Overview ¶
Package grpclogging provides client and server interceptors to log grpc requests, responses, errors and other metadata which is helpful for debugging and analysis. This package assumes the caller is running in a skia-infra managed GKE cluster, such that stdout is parsed as newline-delimited json and passed to StackDriver logging for storage.
Index ¶
- type GRPCLogger
- func (l *GRPCLogger) ClientStreamLoggingInterceptor(ctx context.Context, desc *grpc.StreamDesc, cc *grpc.ClientConn, method string, ...) (grpc.ClientStream, error)
- func (l *GRPCLogger) ClientUnaryLoggingInterceptor(ctx context.Context, method string, req, resp any, cc *grpc.ClientConn, ...) error
- func (l *GRPCLogger) ServerUnaryLoggingInterceptor(ctx context.Context, req any, info *grpc.UnaryServerInfo, ...) (any, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type GRPCLogger ¶
type GRPCLogger struct {
// contains filtered or unexported fields
}
GRPCLogger provides interceptor methods for grpc clients and servers to log the request and response activity going through them.
func New ¶
func New(projectID string, w io.Writer) *GRPCLogger
New returns a new GRPCLogger instance that will write json-encoded log lines to w, using projectID to format the exported trace key as projects/<projectID>/traces/<traceID>, described in more detail here: https://cloud.google.com/logging/docs/structured-logging#structured_logging_special_fields
func (*GRPCLogger) ClientStreamLoggingInterceptor ¶
func (l *GRPCLogger) ClientStreamLoggingInterceptor(ctx context.Context, desc *grpc.StreamDesc, cc *grpc.ClientConn, method string, streamer grpc.Streamer, opts ...grpc.CallOption) (grpc.ClientStream, error)
ClientStreamLoggingInterceptor implements grpc.StreamClientInterceptor.
func (*GRPCLogger) ClientUnaryLoggingInterceptor ¶
func (l *GRPCLogger) ClientUnaryLoggingInterceptor(ctx context.Context, method string, req, resp any, cc *grpc.ClientConn, invoker grpc.UnaryInvoker, opts ...grpc.CallOption) error
ClientUnaryLoggingInterceptor implements grpc.UnaryClientInterceptor.
func (*GRPCLogger) ServerUnaryLoggingInterceptor ¶
func (l *GRPCLogger) ServerUnaryLoggingInterceptor(ctx context.Context, req any, info *grpc.UnaryServerInfo, handler grpc.UnaryHandler) (any, error)
ServerUnaryLoggingInterceptor implements grpc.UnaryServerInterceptor.