Documentation ¶
Overview ¶
Package observability provides logging and metrics collection middleware for YARPC.
Index ¶
- type Config
- type ContextExtractor
- type Middleware
- func (m *Middleware) Call(ctx context.Context, req *transport.Request, out transport.UnaryOutbound) (*transport.Response, error)
- func (m *Middleware) CallOneway(ctx context.Context, req *transport.Request, out transport.OnewayOutbound) (transport.Ack, error)
- func (m *Middleware) CallStream(ctx context.Context, request *transport.StreamRequest, ...) (*transport.ClientStream, error)
- func (m *Middleware) Handle(ctx context.Context, req *transport.Request, w transport.ResponseWriter, ...) error
- func (m *Middleware) HandleOneway(ctx context.Context, req *transport.Request, h transport.OnewayHandler) error
- func (m *Middleware) HandleStream(serverStream *transport.ServerStream, h transport.StreamHandler) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Config ¶ added in v1.36.0
type Config struct { // Logger to which messages will be logged. Logger *zap.Logger // Scope to which metrics are emitted. Scope *metrics.Scope // Extracts request-scoped information from the context for logging. ContextExtractor ContextExtractor // Log level used to log successful inbound and outbound calls. // // Defaults to DebugLevel. SuccessLevel *zapcore.Level // Log level used to log failed inbound and outbound calls. This includes // low-level network errors, TChannel error frames, etc. // // Defaults to ErrorLevel. FailureLevel *zapcore.Level // Log level used to log calls that failed with an application error. All // Thrift exceptions are considered application errors. // // Defaults to ErrorLevel. ApplicationErrorLevel *zapcore.Level }
Config configures the observability middleware.
type ContextExtractor ¶
A ContextExtractor pulls any relevant request-scoped data (e.g., tracing spans) from the request's Context.
func NewNopContextExtractor ¶
func NewNopContextExtractor() ContextExtractor
NewNopContextExtractor returns a no-op ContextExtractor.
type Middleware ¶
type Middleware struct {
// contains filtered or unexported fields
}
Middleware is logging and metrics middleware for all RPC types.
func NewMiddleware ¶
func NewMiddleware(cfg Config) *Middleware
NewMiddleware constructs an observability middleware with the provided configuration.
func (*Middleware) Call ¶
func (m *Middleware) Call(ctx context.Context, req *transport.Request, out transport.UnaryOutbound) (*transport.Response, error)
Call implements middleware.UnaryOutbound.
func (*Middleware) CallOneway ¶
func (m *Middleware) CallOneway(ctx context.Context, req *transport.Request, out transport.OnewayOutbound) (transport.Ack, error)
CallOneway implements middleware.OnewayOutbound.
func (*Middleware) CallStream ¶ added in v1.27.0
func (m *Middleware) CallStream(ctx context.Context, request *transport.StreamRequest, out transport.StreamOutbound) (*transport.ClientStream, error)
CallStream implements middleware.StreamOutbound.
func (*Middleware) Handle ¶
func (m *Middleware) Handle(ctx context.Context, req *transport.Request, w transport.ResponseWriter, h transport.UnaryHandler) error
Handle implements middleware.UnaryInbound.
func (*Middleware) HandleOneway ¶
func (m *Middleware) HandleOneway(ctx context.Context, req *transport.Request, h transport.OnewayHandler) error
HandleOneway implements middleware.OnewayInbound.
func (*Middleware) HandleStream ¶ added in v1.27.0
func (m *Middleware) HandleStream(serverStream *transport.ServerStream, h transport.StreamHandler) error
HandleStream implements middleware.StreamInbound.