Skip to content

ChainStats is a simple Go library that allows you to chain multiple `grpc.StatsHandler` instances.

License

Notifications You must be signed in to change notification settings

inigohu/chainstats

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ChainStats

ChainStats is a simple Go library that allows you to chain multiple grpc.StatsHandler instances.

Installation

go get github.com/inigohu/chainstats

Usage

package main

import (
 "context"
 "google.golang.org/grpc"
 "google.golang.org/grpc/stats"
 "github.com/inigohu/chainstats"
)

// Example custom stats handler
type customStatsHandler struct{}

func (h *customStatsHandler) TagRPC(ctx context.Context, info *stats.RPCTagInfo) context.Context {
 // Add custom logic here
 return ctx
}

func (h *customStatsHandler) HandleRPC(ctx context.Context, stat stats.RPCStats) {
 // Add custom logic here
}

func (h *customStatsHandler) TagConn(ctx context.Context, info *stats.ConnTagInfo) context.Context {
 // Add custom logic here
 return ctx
}

func (h *customStatsHandler) HandleConn(ctx context.Context, stat stats.ConnStats) {
 // Add custom logic here
}

func main() {
 customHandler1 := &customStatsHandler{}
 customHandler2 := &customStatsHandler{}

 statsHandler := chainstats.NewChainStatsHandler(customHandler1, customHandler2)

 server := grpc.NewServer(grpc.StatsHandler(statsHandler))

 // Register your gRPC services and start the server
}

About

ChainStats is a simple Go library that allows you to chain multiple `grpc.StatsHandler` instances.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages