grpcmon

package
v0.0.0-...-51f9457 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 9, 2021 License: Apache-2.0 Imports: 20 Imported by: 0

Documentation

Overview

Package grpcmon defines gRPC interceptors with monitoring instrumentation.

Index

Constants

This section is empty.

Variables

View Source
var File_go_chromium_org_luci_grpc_grpcmon_echo_proto protoreflect.FileDescriptor

Functions

func NewUnaryClientInterceptor

func NewUnaryClientInterceptor(next grpc.UnaryClientInterceptor) grpc.UnaryClientInterceptor

NewUnaryClientInterceptor returns an interceptor that gathers RPC call metrics and sends them to tsmon.

It can be optionally chained with other interceptor. The reported metrics include time spent in this other interceptor too.

Can be passed to a gRPC client via WithUnaryInterceptor(...) dial option.

Use option.WithGRPCDialOption(grpc.WithUnaryInterceptor(...)) when instrumenting Google Cloud API clients.

It assumes the RPC context has tsmon initialized already.

func RegisterEchoServer

func RegisterEchoServer(s prpc.Registrar, srv EchoServer)

func UnaryServerInterceptor

func UnaryServerInterceptor(ctx context.Context, req interface{}, info *grpc.UnaryServerInfo, handler grpc.UnaryHandler) (resp interface{}, 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 WithClientRPCStatsMonitor

func WithClientRPCStatsMonitor() grpc.DialOption

WithClientRPCStatsMonitor returns a DialOption that specifies a chain of ClientRPCStatsMonitor and Opencensus' gRPC stats handler for all the outgoing gRPC traffic.

ClientRPCStatsMonitor updates the grpcmon metrics, and Opencensus' handler propagates Google Cloud Trace contexts.

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

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

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

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

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL