Compare commits

...
Sign in to create a new pull request.

2 commits

Author SHA1 Message Date
93b681a202
[#21] tracing: Fix typo
Signed-off-by: Dmitrii Stepanov <d.stepanov@yadro.com>
2025-03-21 09:32:46 +03:00
d34e1329c8
[#20] metrics: Add grpc msg send metrics
Streaming RPC has two main metrics: send message and receive message.
But the first one was missed.

Signed-off-by: Dmitrii Stepanov <d.stepanov@yadro.com>
2025-02-12 14:19:29 +03:00
3 changed files with 12 additions and 3 deletions

View file

@ -15,6 +15,9 @@ var clientMetrics = grpcprom.NewClientMetrics(
grpcprom.WithClientStreamRecvHistogram(
grpcprom.WithHistogramBuckets(prometheus.DefBuckets),
),
grpcprom.WithClientStreamSendHistogram(
grpcprom.WithHistogramBuckets(prometheus.DefBuckets),
),
)
func init() {
@ -57,6 +60,12 @@ func init() {
Help: "Histogram of response latency (seconds) of the gRPC single message receive.",
VariableLabels: []string{"grpc_type", "grpc_service", "grpc_method"},
},
{
Name: "grpc_client_msg_send_handling_seconds",
Type: dto.MetricType_HISTOGRAM.String(),
Help: "Histogram of response latency (seconds) of the gRPC single message send.",
VariableLabels: []string{"grpc_type", "grpc_service", "grpc_method"},
},
}
metrics.MustRegister(clientMetrics, descs...)
}

View file

@ -82,7 +82,7 @@ func main() {
cc, err := grpc.NewClient(":7000",
grpc.WithTransportCredentials(insecure.NewCredentials()),
grpc.WithChainUnaryInterceptor(
tracing_grpc.NewUnaryClientInteceptor(),
tracing_grpc.NewUnaryClientInterceptor(),
verifyClientTraceID,
),
grpc.WithChainStreamInterceptor(

View file

@ -15,8 +15,8 @@ import (
"google.golang.org/grpc/status"
)
// NewUnaryClientInteceptor creates new gRPC unary interceptor to save gRPC client traces.
func NewUnaryClientInteceptor() grpc.UnaryClientInterceptor {
// NewUnaryClientInterceptor creates new gRPC unary interceptor to save gRPC client traces.
func NewUnaryClientInterceptor() grpc.UnaryClientInterceptor {
return func(ctx context.Context, method string, req, reply any, cc *grpc.ClientConn, invoker grpc.UnaryInvoker, opts ...grpc.CallOption) error {
ctx, span := startClientSpan(ctx, cc, method)
defer span.End()