diff --git a/instrumentation/google.golang.org/grpc/otelgrpc/stats_handler.go b/instrumentation/google.golang.org/grpc/otelgrpc/stats_handler.go index 491bd37dd7c..8e7927614ea 100644 --- a/instrumentation/google.golang.org/grpc/otelgrpc/stats_handler.go +++ b/instrumentation/google.golang.org/grpc/otelgrpc/stats_handler.go @@ -149,6 +149,8 @@ func (c *config) handleRPC(ctx context.Context, rs stats.RPCStats, isServer bool switch rs := rs.(type) { case *stats.InPayload: if gctx != nil { + messageId = atomic.AddInt64(&gctx.messagesReceived, 1) + // Run this once on InPayload and record the attributes for the entire RPC. if c.MetricAttributesFn != nil { fnMetricAttrs := c.MetricAttributesFn(ctx, rs.Payload)