package statshandler

import "google.golang.org/grpc/examples/features/stats_monitoring/statshandler"

Package statshandler is an example pkg to illustrate the use of the stats handler.

Index

Types

type Handler

type Handler struct{}

Handler implements stats.Handler(https://pkg.go.dev/google.golang.org/grpc/stats#Handler) interface.

func New

func New() *Handler

New returns a new implementation of stats.Handler(https://pkg.go.dev/google.golang.org/grpc/stats#Handler) interface.

func (*Handler) HandleConn

func (st *Handler) HandleConn(ctx context.Context, stat stats.ConnStats)

HandleConn processes the Conn stats.

func (*Handler) HandleRPC

func (st *Handler) HandleRPC(ctx context.Context, stat stats.RPCStats)

HandleRPC processes the RPC stats. Note: All stat fields are read-only.

func (*Handler) TagConn

func (st *Handler) TagConn(ctx context.Context, stat *stats.ConnTagInfo) context.Context

TagConn can attach some information to the given context. The context used in HandleConn for this connection will be derived from the context returned. In the gRPC client: The context used in HandleRPC for RPCs on this connection will be the user's context and NOT derived from the context returned here. In the gRPC server: The context used in HandleRPC for RPCs on this connection will be derived from the context returned here.

func (*Handler) TagRPC

func (st *Handler) TagRPC(ctx context.Context, stat *stats.RPCTagInfo) context.Context

TagRPC can attach some information to the given context. The context used for the rest lifetime of the RPC will be derived from the returned context.

Source Files

handler.go

Version
v0.0.0-20250418172310-54e7e26a1f32 (latest)
Published
Apr 18, 2025
Platform
linux/amd64
Imports
5 packages
Last checked
1 day ago

Tools for package owners.