Documentation ¶
Overview ¶
Package grpcmon defines gRPC interceptors with monitoring instrumentation.
Index ¶
- Variables
- func RegisterEchoServer(s prpc.Registrar, srv EchoServer)
- func StreamServerInterceptor(srv any, ss grpc.ServerStream, info *grpc.StreamServerInfo, ...) (err error)
- func UnaryServerInterceptor(ctx context.Context, req any, info *grpc.UnaryServerInfo, ...) (resp any, err error)
- func WithMultiStatsHandler(handlers ...stats.Handler) grpc.DialOption
- type ClientRPCStatsMonitor
- func (m *ClientRPCStatsMonitor) HandleConn(context.Context, stats.ConnStats)
- func (m *ClientRPCStatsMonitor) HandleRPC(ctx context.Context, s stats.RPCStats)
- func (m *ClientRPCStatsMonitor) TagConn(ctx context.Context, t *stats.ConnTagInfo) context.Context
- func (m *ClientRPCStatsMonitor) TagRPC(ctx context.Context, tag *stats.RPCTagInfo) context.Context
- type EchoClient
- type EchoServer
- type SayRequest
- type SayResponse
- type UnimplementedEchoServer
Constants ¶
This section is empty.
Variables ¶
var File_go_chromium_org_luci_grpc_grpcmon_echo_proto protoreflect.FileDescriptor
Functions ¶
func RegisterEchoServer ¶
func RegisterEchoServer(s prpc.Registrar, srv EchoServer)
func StreamServerInterceptor ¶
func StreamServerInterceptor(srv any, ss grpc.ServerStream, info *grpc.StreamServerInfo, handler grpc.StreamHandler) (err error)
StreamServerInterceptor is a grpc.StreamServerInterceptor that gathers RPC handler metrics and sends them to tsmon.
It assumes the RPC context has tsmon initialized already.
TODO(vadimsh): Report the number of messages streamed. This will make this interceptor sufficiently different from UnaryServerInterceptor. That's the reason there's no UnifiedServerInterceptor exposed, even though right now implementations of unary and stream interceptors are identical.
func UnaryServerInterceptor ¶
func UnaryServerInterceptor(ctx context.Context, req any, info *grpc.UnaryServerInfo, handler grpc.UnaryHandler) (resp any, err error)
UnaryServerInterceptor is a grpc.UnaryServerInterceptor that gathers RPC handler metrics and sends them to tsmon.
It assumes the RPC context has tsmon initialized already.
func WithMultiStatsHandler ¶
func WithMultiStatsHandler(handlers ...stats.Handler) grpc.DialOption
WithMultiStatsHandler returns a DialOption that chains given stats.Handler(s). The first handler will be executed first, and then next afterwards. nil Handlers are ignored.
Types ¶
type ClientRPCStatsMonitor ¶
type ClientRPCStatsMonitor struct{}
ClientRPCStatsMonitor implements stats.Handler to update tsmon metrics with RPC stats.
Can be passed to a gRPC client via WithStatsHandler(...) dial option. To chain this with other stats handler, use WithMultiStatsHandler.
func (*ClientRPCStatsMonitor) HandleConn ¶
func (m *ClientRPCStatsMonitor) HandleConn(context.Context, stats.ConnStats)
HandleConn processes the Conn stats.
func (*ClientRPCStatsMonitor) HandleRPC ¶
func (m *ClientRPCStatsMonitor) HandleRPC(ctx context.Context, s stats.RPCStats)
HandleRPC processes the RPC stats.
func (*ClientRPCStatsMonitor) TagConn ¶
func (m *ClientRPCStatsMonitor) TagConn(ctx context.Context, t *stats.ConnTagInfo) context.Context
TagConn creates a context for the connection.
The context passed to HandleConn will be derived from the returned context. The context passed to HandleRPC will NOT be derived from the returned context.
func (*ClientRPCStatsMonitor) TagRPC ¶
func (m *ClientRPCStatsMonitor) TagRPC(ctx context.Context, tag *stats.RPCTagInfo) context.Context
TagRPC creates a context for the RPC.
The context used for the rest lifetime of the RPC will be derived from the returned context.
type EchoClient ¶
type EchoClient interface {
Say(ctx context.Context, in *SayRequest, opts ...grpc.CallOption) (*SayResponse, error)
}
EchoClient is the client API for Echo service.
For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream.
func NewEchoClient ¶
func NewEchoClient(cc grpc.ClientConnInterface) EchoClient
func NewEchoPRPCClient ¶
func NewEchoPRPCClient(client *prpc.Client) EchoClient
type EchoServer ¶
type EchoServer interface {
Say(context.Context, *SayRequest) (*SayResponse, error)
}
EchoServer is the server API for Echo service.
type SayRequest ¶
type SayRequest struct { Msg string `protobuf:"bytes,1,opt,name=msg,proto3" json:"msg,omitempty"` // contains filtered or unexported fields }
func (*SayRequest) Descriptor
deprecated
func (*SayRequest) Descriptor() ([]byte, []int)
Deprecated: Use SayRequest.ProtoReflect.Descriptor instead.
func (*SayRequest) GetMsg ¶
func (x *SayRequest) GetMsg() string
func (*SayRequest) ProtoMessage ¶
func (*SayRequest) ProtoMessage()
func (*SayRequest) ProtoReflect ¶
func (x *SayRequest) ProtoReflect() protoreflect.Message
func (*SayRequest) Reset ¶
func (x *SayRequest) Reset()
func (*SayRequest) String ¶
func (x *SayRequest) String() string
type SayResponse ¶
type SayResponse struct { Msg string `protobuf:"bytes,2,opt,name=msg,proto3" json:"msg,omitempty"` // contains filtered or unexported fields }
func (*SayResponse) Descriptor
deprecated
func (*SayResponse) Descriptor() ([]byte, []int)
Deprecated: Use SayResponse.ProtoReflect.Descriptor instead.
func (*SayResponse) GetMsg ¶
func (x *SayResponse) GetMsg() string
func (*SayResponse) ProtoMessage ¶
func (*SayResponse) ProtoMessage()
func (*SayResponse) ProtoReflect ¶
func (x *SayResponse) ProtoReflect() protoreflect.Message
func (*SayResponse) Reset ¶
func (x *SayResponse) Reset()
func (*SayResponse) String ¶
func (x *SayResponse) String() string
type UnimplementedEchoServer ¶
type UnimplementedEchoServer struct { }
UnimplementedEchoServer can be embedded to have forward compatible implementations.
func (*UnimplementedEchoServer) Say ¶
func (*UnimplementedEchoServer) Say(context.Context, *SayRequest) (*SayResponse, error)