Skip to content

Commit

Permalink
fix(grpc): Add timing histogram metrics (#243)
Browse files Browse the repository at this point in the history
  • Loading branch information
samcm authored Oct 19, 2023
1 parent 8934ee5 commit 1878369
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
6 changes: 5 additions & 1 deletion pkg/output/xatu/exporter.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (

"github.com/ethpandaops/xatu/pkg/observability"
pb "github.com/ethpandaops/xatu/pkg/proto/xatu"
grpc_prometheus "github.com/grpc-ecosystem/go-grpc-prometheus"
"github.com/sirupsen/logrus"
"go.opentelemetry.io/otel/attribute"
"go.opentelemetry.io/otel/codes"
Expand All @@ -27,7 +28,10 @@ type ItemExporter struct {
}

func NewItemExporter(name string, config *Config, log logrus.FieldLogger) (ItemExporter, error) {
var opts []grpc.DialOption
opts := []grpc.DialOption{
grpc.WithUnaryInterceptor(grpc_prometheus.UnaryClientInterceptor),
grpc.WithStreamInterceptor(grpc_prometheus.StreamClientInterceptor),
}

if config.TLS {
host, _, err := net.SplitHostPort(config.Address)
Expand Down
2 changes: 2 additions & 0 deletions pkg/server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,8 @@ func (x *Xatu) startGrpcServer(ctx context.Context) error {

mb100 := 1024 * 1024 * 100

grpc_prometheus.EnableHandlingTimeHistogram()

opts := []grpc.ServerOption{
grpc.StreamInterceptor(grpc_prometheus.StreamServerInterceptor),
grpc.UnaryInterceptor(grpc_prometheus.UnaryServerInterceptor),
Expand Down

0 comments on commit 1878369

Please sign in to comment.