Documentation ¶
Index ¶
- func DefaultClientErrorToLevel(err error) slog.Level
- func DefaultServerErrorToLevel(err error) slog.Level
- func FullMethod(ii *otelgrpc.InterceptorInfo) string
- func InterceptorFilterIgnoreReflection(ii *otelgrpc.InterceptorInfo) bool
- func JsonPB(m proto.Message) any
- func ReplaceAttrJsonPB(group []string, a slog.Attr) slog.Attr
- func SlogStreamClientInterceptor(opts ...Option) grpc.StreamClientInterceptor
- func SlogStreamServerInterceptor(opts ...Option) grpc.StreamServerInterceptor
- func SlogUnaryClientInterceptor(opts ...Option) grpc.UnaryClientInterceptor
- func SlogUnaryServerInterceptor(opts ...Option) grpc.UnaryServerInterceptor
- type AppendToAttributes
- type Call
- type ErrorToLevel
- type InterceptorFilter
- type Option
- type Payload
- type Peer
- type Result
- type Role
- type StreamInfo
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DefaultClientErrorToLevel ¶
DefaultClientErrorToLevel is the helper mapper that maps gRPC return errors/codes to log levels for client side.
func DefaultServerErrorToLevel ¶
DefaultServerErrorToLevel is the helper mapper that maps gRPC return errors/codes to log levels for server side.
func FullMethod ¶
func FullMethod(ii *otelgrpc.InterceptorInfo) string
FullMethod returns the full grpc method name, when given an *otelgrpc.InterceptorInfo
func InterceptorFilterIgnoreReflection ¶
func InterceptorFilterIgnoreReflection(ii *otelgrpc.InterceptorInfo) bool
InterceptorFilterIgnoreReflection returns an InterceptorFilter that will ignore all grpc Reflection calls.
func JsonPB ¶
JsonPB turns a protobuf message into json, and should be used when logging a protobuf message, instead of the "encoding/json" package. It will marshal the protobuf using jsonpb (the official Proto<->JSON spec), instead of a json package that doesn't know how to handle well known types.
func SlogStreamClientInterceptor ¶
func SlogStreamClientInterceptor(opts ...Option) grpc.StreamClientInterceptor
SlogStreamClientInterceptor returns a grpc.StreamClientInterceptor suitable for use in a grpc.NewClient or grpc.WithChainStreamInterceptor call. This interceptor will log stream start, sends and receives.
func SlogStreamServerInterceptor ¶
func SlogStreamServerInterceptor(opts ...Option) grpc.StreamServerInterceptor
SlogStreamServerInterceptor returns a grpc.StreamServerInterceptor suitable for use in a grpc.NewServer call. This interceptor will log stream start, sends and receives.
func SlogUnaryClientInterceptor ¶
func SlogUnaryClientInterceptor(opts ...Option) grpc.UnaryClientInterceptor
SlogUnaryClientInterceptor returns a grpc.UnaryClientInterceptor suitable for use in a grpc.NewClient or grpc.WithChainUnaryInterceptor call. This interceptor will log requests and responses.
func SlogUnaryServerInterceptor ¶
func SlogUnaryServerInterceptor(opts ...Option) grpc.UnaryServerInterceptor
SlogUnaryServerInterceptor returns a grpc.UnaryServerInterceptor suitable for use in a grpc.NewServer or grpc.ChainUnaryInterceptor call. This interceptor will log requests and responses.
Types ¶
type AppendToAttributes ¶
AppendToAttributes allows customizing the attributes, including disabling some
type Call ¶
type Call struct { System string `json:"system,omitempty"` Package string `json:"package,omitempty"` Service string `json:"service,omitempty"` Method string `json:"method,omitempty"` }
Call contains information about the grpc call being made
type ErrorToLevel ¶
ErrorToLevel defines the mapping between the gRPC return error/code to a log level
type InterceptorFilter ¶
type InterceptorFilter func(*otelgrpc.InterceptorInfo) bool
InterceptorFilter is a predicate used to determine whether a given request in interceptor info should be instrumented. A InterceptorFilter must return true if the request should be traced.
type Option ¶
type Option interface {
// contains filtered or unexported methods
}
Option applies an option value for a config.
func WithAppendToAttributes ¶
func WithAppendToAttributes(f AppendToAttributes) Option
WithAppendToAttributes returns an Option to use the appending function
func WithErrorToLevel ¶
func WithErrorToLevel(f ErrorToLevel) Option
WithErrorToLevel returns an Option to use the error to level function
func WithInterceptorFilter ¶
func WithInterceptorFilter(f InterceptorFilter) Option
WithInterceptorFilter returns an Option to use the request filter.
type Payload ¶
type Payload struct {
Payload any `json:"payload,omitempty"`
}
Payload contains the protobuf message and metadata about it
type Result ¶
type Result struct { Error error `json:"error,omitempty"` // Call status.FromError() to get the status code, message, and details Elapsed time.Duration `json:"elapsed,omitempty"` }
Result contains information about the end result of the grpc call
type Role ¶
type Role struct { Role string `json:"role,omitempty"` ClientStream bool `json:"client_stream,omitempty"` ServerStream bool `json:"server_stream,omitempty"` }
Role contains information about the server and client
type StreamInfo ¶
type StreamInfo struct {
MsgID int64 `json:"msg_id,omitempty"` // Incrementing ID
}
StreamInfo contains information specific to streaming Sends and Receives