# grpctrace -- import "go.opencensus.io/plugin/grpc/grpctrace" Package grpctrace is a package to assist with tracing incoming and outgoing gRPC requests. ## Usage #### type ClientStatsHandler ```go type ClientStatsHandler struct{} ``` ClientStatsHandler is a an implementation of grpc.StatsHandler that can be passed to grpc.Dial using grpc.WithStatsHandler to enable trace context propagation and automatic span creation for outgoing gRPC requests. #### func NewClientStatsHandler ```go func NewClientStatsHandler() *ClientStatsHandler ``` NewClientStatsHandler returns a StatsHandler that can be passed to grpc.Dial using grpc.WithStatsHandler to enable trace context propagation and automatic span creation for outgoing gRPC requests. #### func (*ClientStatsHandler) HandleConn ```go func (c *ClientStatsHandler) HandleConn(ctx context.Context, cs stats.ConnStats) ``` HandleConn is a no-op for this StatsHandler. #### func (*ClientStatsHandler) HandleRPC ```go func (c *ClientStatsHandler) HandleRPC(ctx context.Context, rs stats.RPCStats) ``` HandleRPC processes the RPC stats, adding information to the current trace span. #### func (*ClientStatsHandler) TagConn ```go func (c *ClientStatsHandler) TagConn(ctx context.Context, cti *stats.ConnTagInfo) context.Context ``` TagConn is a no-op for this StatsHandler. #### func (*ClientStatsHandler) TagRPC ```go func (c *ClientStatsHandler) TagRPC(ctx context.Context, rti *stats.RPCTagInfo) context.Context ``` TagRPC creates a new trace span for the client side of the RPC. It returns ctx with the new trace span added and a serialization of the SpanContext added to the outgoing gRPC metadata. #### type ServerStatsHandler ```go type ServerStatsHandler struct{} ``` ServerStatsHandler is a an implementation of grpc.StatsHandler that can be passed to grpc.NewServer using grpc.StatsHandler to enable trace context propagation and automatic span creation for incoming gRPC requests.. #### func NewServerStatsHandler ```go func NewServerStatsHandler() *ServerStatsHandler ``` NewServerStatsHandler returns a StatsHandler that can be passed to grpc.NewServer using grpc.StatsHandler to enable trace context propagation and automatic span creation for incoming gRPC requests. #### func (*ServerStatsHandler) HandleConn ```go func (s *ServerStatsHandler) HandleConn(ctx context.Context, cs stats.ConnStats) ``` HandleConn is a no-op for this StatsHandler. #### func (*ServerStatsHandler) HandleRPC ```go func (s *ServerStatsHandler) HandleRPC(ctx context.Context, rs stats.RPCStats) ``` HandleRPC processes the RPC stats, adding information to the current trace span. #### func (*ServerStatsHandler) TagConn ```go func (s *ServerStatsHandler) TagConn(ctx context.Context, cti *stats.ConnTagInfo) context.Context ``` TagConn is a no-op for this StatsHandler. #### func (*ServerStatsHandler) TagRPC ```go func (s *ServerStatsHandler) TagRPC(ctx context.Context, rti *stats.RPCTagInfo) context.Context ``` TagRPC creates a new trace span for the server side of the RPC. It checks the incoming gRPC metadata in ctx for a SpanContext, and if it finds one, uses that SpanContext as the parent context of the new span. It returns ctx, with the new trace span added.