Repository: open-telemetry/opentelemetry-go-contrib (go)

Issue:
otelgrpc: performance issue about otlpreceiver invoke proto.Size slow path
The opentelemetry collector otlpreceiver consume lots of cpu for proto.Size, marshal to buffer, get buffer size.

related https://github.com/open-telemetry/opentelemetry-collector/issues/6947

I think it shoud try get size from asserting interface `Size() int`, then try to use proto.Size

Pull request description:
Remove expensive calculation of gRPC message size
Signed-off-by: Anthony J Mirabella <a9@aneurysm9.com>

See https://github.com/open-telemetry/opentelemetry-collector/issues/6947.

Fixes #3165.

Patch:
diff --git a/CHANGELOG.md b/CHANGELOG.md
index d3abf6817..9af648b90 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -15,6 +15,10 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm
 - Add missing recommended AWS Lambda resource attributes `faas.instance` and `faas.max_memory` in `go.opentelemetry.io/contrib/detectors/aws/lambda`. (#3148)
 - Improve documentation for `samplers/jaegerremote` by providing examples of sampling endpoints. (#3147)
 
+### Changed
+
+- `otelgrpc`: Remove expensive calculation of uncompressed message size attribute. (#3168)
+
 ## [1.12.0/0.37.0/0.6.0]
 
 ### Added
diff --git a/instrumentation/google.golang.org/grpc/otelgrpc/interceptor.go b/instrumentation/google.golang.org/grpc/otelgrpc/interceptor.go
index aeee1d18d..339e3d140 100644
--- a/instrumentation/google.golang.org/grpc/otelgrpc/interceptor.go
+++ b/instrumentation/google.golang.org/grpc/otelgrpc/interceptor.go
@@ -39,24 +39,16 @@ import (
 type messageType attribute.KeyValue
 
 // Event adds an event of the messageType to the span associated with the
-// passed context with id and size (if message is a proto message).
-func (m messageType) Event(ctx context.Context, id int, message interface{}) {
+// passed context with a message id.
+func (m messageType) Event(ctx context.Context, id int, _ interface{}) {
 	span := trace.SpanFromContext(ctx)
 	if !span.IsRecording() {
 		return
 	}
-	if p, ok := message.(proto.Message); ok {
-		span.AddEvent("message", trace.WithAttributes(
-			attribute.KeyValue(m),
-			RPCMessageIDKey.Int(id),
-			RPCMessageUncompressedSizeKey.Int(proto.Size(p)),
-		))
-	} else {
-		span.AddEvent("message", trace.WithAttributes(
-			attribute.KeyValue(m),
-			RPCMessageIDKey.Int(id),
-		))
-	}
+	span.AddEvent("message", trace.WithAttributes(
+		attribute.KeyValue(m),
+		RPCMessageIDKey.Int(id),
+	))
 }
 
 var (


Test patch:
diff --git a/instrumentation/google.golang.org/grpc/otelgrpc/test/go.mod b/instrumentation/google.golang.org/grpc/otelgrpc/test/go.mod
index e29fd9148..6b37b8294 100644
--- a/instrumentation/google.golang.org/grpc/otelgrpc/test/go.mod
+++ b/instrumentation/google.golang.org/grpc/otelgrpc/test/go.mod
@@ -10,7 +10,6 @@ require (
 	go.opentelemetry.io/otel/sdk/metric v0.34.0
 	go.uber.org/goleak v1.2.0
 	google.golang.org/grpc v1.52.0
-	google.golang.org/protobuf v1.28.1
 )
 
 require (
@@ -30,6 +29,7 @@ require (
 	golang.org/x/text v0.6.0 // indirect
 	google.golang.org/appengine v1.6.7 // indirect
 	google.golang.org/genproto v0.0.0-20221118155620-16455021b5e6 // indirect
+	google.golang.org/protobuf v1.28.1 // indirect
 	gopkg.in/yaml.v3 v3.0.1 // indirect
 )
 
diff --git a/instrumentation/google.golang.org/grpc/otelgrpc/test/grpc_test.go b/instrumentation/google.golang.org/grpc/otelgrpc/test/grpc_test.go
index 9d5a87687..b6154ef50 100644
--- a/instrumentation/google.golang.org/grpc/otelgrpc/test/grpc_test.go
+++ b/instrumentation/google.golang.org/grpc/otelgrpc/test/grpc_test.go
@@ -133,7 +133,6 @@ func checkUnaryClientSpans(t *testing.T, spans []trace.ReadOnlySpan) {
 			Attributes: []attribute.KeyValue{
 				otelgrpc.RPCMessageIDKey.Int(1),
 				otelgrpc.RPCMessageTypeKey.String("SENT"),
-				otelgrpc.RPCMessageUncompressedSizeKey.Int(0),
 			},
 		},
 		{
@@ -141,7 +140,6 @@ func checkUnaryClientSpans(t *testing.T, spans []trace.ReadOnlySpan) {
 			Attributes: []attribute.KeyValue{
 				otelgrpc.RPCMessageIDKey.Int(1),
 				otelgrpc.RPCMessageTypeKey.String("RECEIVED"),
-				otelgrpc.RPCMessageUncompressedSizeKey.Int(0),
 			},
 		},
 	}, emptySpan.Events())
@@ -162,7 +160,6 @@ func checkUnaryClientSpans(t *testing.T, spans []trace.ReadOnlySpan) {
 				otelgrpc.RPCMessageIDKey.Int(1),
 				otelgrpc.RPCMessageTypeKey.String("SENT"),
 				// largeReqSize from "google.golang.org/grpc/interop" + 12 (overhead).
-				otelgrpc.RPCMessageUncompressedSizeKey.Int(271840),
 			},
 		},
 		{
@@ -171,7 +168,6 @@ func checkUnaryClientSpans(t *testing.T, spans []trace.ReadOnlySpan) {
 				otelgrpc.RPCMessageIDKey.Int(1),
 				otelgrpc.RPCMessageTypeKey.String("RECEIVED"),
 				// largeRespSize from "google.golang.org/grpc/interop" + 8 (overhead).
-				otelgrpc.RPCMessageUncompressedSizeKey.Int(314167),
 			},
 		},
 	}, largeSpan.Events())
@@ -196,7 +192,6 @@ func checkStreamClientSpans(t *testing.T, spans []trace.ReadOnlySpan) {
 			Attributes: []attribute.KeyValue{
 				otelgrpc.RPCMessageIDKey.Int(1),
 				otelgrpc.RPCMessageTypeKey.String("SENT"),
-				otelgrpc.RPCMessageUncompressedSizeKey.Int(27190),
 			},
 		},
 		{
@@ -204,7 +199,6 @@ func checkStreamClientSpans(t *testing.T, spans []trace.ReadOnlySpan) {
 			Attributes: []attribute.KeyValue{
 				otelgrpc.RPCMessageIDKey.Int(2),
 				otelgrpc.RPCMessageTypeKey.String("SENT"),
-				otelgrpc.RPCMessageUncompressedSizeKey.Int(12),
 			},
 		},
 		{
@@ -212,7 +206,6 @@ func checkStreamClientSpans(t *testing.T, spans []trace.ReadOnlySpan) {
 			Attributes: []attribute.KeyValue{
 				otelgrpc.RPCMessageIDKey.Int(3),
 				otelgrpc.RPCMessageTypeKey.String("SENT"),
-				otelgrpc.RPCMessageUncompressedSizeKey.Int(1834),
 			},
 		},
 		{
@@ -220,7 +213,6 @@ func checkStreamClientSpans(t *testing.T, spans []trace.ReadOnlySpan) {
 			Attributes: []attribute.KeyValue{
 				otelgrpc.RPCMessageIDKey.Int(4),
 				otelgrpc.RPCMessageTypeKey.String("SENT"),
-				otelgrpc.RPCMessageUncompressedSizeKey.Int(45912),
 			},
 		},
 		// client does not record an event for the server response.
@@ -242,7 +234,6 @@ func checkStreamClientSpans(t *testing.T, spans []trace.ReadOnlySpan) {
 			Attributes: []attribute.KeyValue{
 				otelgrpc.RPCMessageIDKey.Int(1),
 				otelgrpc.RPCMessageTypeKey.String("SENT"),
-				otelgrpc.RPCMessageUncompressedSizeKey.Int(21),
 			},
 		},
 		{
@@ -250,7 +241,6 @@ func checkStreamClientSpans(t *testing.T, spans []trace.ReadOnlySpan) {
 			Attributes: []attribute.KeyValue{
 				otelgrpc.RPCMessageIDKey.Int(1),
 				otelgrpc.RPCMessageTypeKey.String("RECEIVED"),
-				otelgrpc.RPCMessageUncompressedSizeKey.Int(31423),
 			},
 		},
 		{
@@ -258,7 +248,6 @@ func checkStreamClientSpans(t *testing.T, spans []trace.ReadOnlySpan) {
 			Attributes: []attribute.KeyValue{
 				otelgrpc.RPCMessageIDKey.Int(2),
 				otelgrpc.RPCMessageTypeKey.String("RECEIVED"),
-				otelgrpc.RPCMessageUncompressedSizeKey.Int(13),
 			},
 		},
 		{
@@ -266,7 +255,6 @@ func checkStreamClientSpans(t *testing.T, spans []trace.ReadOnlySpan) {
 			Attributes: []attribute.KeyValue{
 				otelgrpc.RPCMessageIDKey.Int(3),
 				otelgrpc.RPCMessageTypeKey.String("RECEIVED"),
-				otelgrpc.RPCMessageUncompressedSizeKey.Int(2659),
 			},
 		},
 		{
@@ -274,7 +262,6 @@ func checkStreamClientSpans(t *testing.T, spans []trace.ReadOnlySpan) {
 			Attributes: []attribute.KeyValue{
 				otelgrpc.RPCMessageIDKey.Int(4),
 				otelgrpc.RPCMessageTypeKey.String("RECEIVED"),
-				otelgrpc.RPCMessageUncompressedSizeKey.Int(58987),
 			},
 		},
 	}, streamOutput.Events())
@@ -294,7 +281,6 @@ func checkStreamClientSpans(t *testing.T, spans []trace.ReadOnlySpan) {
 			Attributes: []attribute.KeyValue{
 				otelgrpc.RPCMessageIDKey.Int(1),
 				otelgrpc.RPCMessageTypeKey.String("SENT"),
-				otelgrpc.RPCMessageUncompressedSizeKey.Int(27196),
 			},
 		},
 		{
@@ -302,7 +288,6 @@ func checkStreamClientSpans(t *testing.T, spans []trace.ReadOnlySpan) {
 			Attributes: []attribute.KeyValue{
 				otelgrpc.RPCMessageIDKey.Int(1),
 				otelgrpc.RPCMessageTypeKey.String("RECEIVED"),
-				otelgrpc.RPCMessageUncompressedSizeKey.Int(31423),
 			},
 		},
 		{
@@ -310,7 +295,6 @@ func checkStreamClientSpans(t *testing.T, spans []trace.ReadOnlySpan) {
 			Attributes: []attribute.KeyValue{
 				otelgrpc.RPCMessageIDKey.Int(2),
 				otelgrpc.RPCMessageTypeKey.String("SENT"),
-				otelgrpc.RPCMessageUncompressedSizeKey.Int(16),
 			},
 		},
 		{
@@ -318,7 +302,6 @@ func checkStreamClientSpans(t *testing.T, spans []trace.ReadOnlySpan) {
 			Attributes: []attribute.KeyValue{
 				otelgrpc.RPCMessageIDKey.Int(2),
 				otelgrpc.RPCMessageTypeKey.String("RECEIVED"),
-				otelgrpc.RPCMessageUncompressedSizeKey.Int(13),
 			},
 		},
 		{
@@ -326,7 +309,6 @@ func checkStreamClientSpans(t *testing.T, spans []trace.ReadOnlySpan) {
 			Attributes: []attribute.KeyValue{
 				otelgrpc.RPCMessageIDKey.Int(3),
 				otelgrpc.RPCMessageTypeKey.String("SENT"),
-				otelgrpc.RPCMessageUncompressedSizeKey.Int(1839),
 			},
 		},
 		{
@@ -334,7 +316,6 @@ func checkStreamClientSpans(t *testing.T, spans []trace.ReadOnlySpan) {
 			Attributes: []attribute.KeyValue{
 				otelgrpc.RPCMessageIDKey.Int(3),
 				otelgrpc.RPCMessageTypeKey.String("RECEIVED"),
-				otelgrpc.RPCMessageUncompressedSizeKey.Int(2659),
 			},
 		},
 		{
@@ -342,7 +323,6 @@ func checkStreamClientSpans(t *testing.T, spans []trace.ReadOnlySpan) {
 			Attributes: []attribute.KeyValue{
 				otelgrpc.RPCMessageIDKey.Int(4),
 				otelgrpc.RPCMessageTypeKey.String("SENT"),
-				otelgrpc.RPCMessageUncompressedSizeKey.Int(45918),
 			},
 		},
 		{
@@ -350,7 +330,6 @@ func checkStreamClientSpans(t *testing.T, spans []trace.ReadOnlySpan) {
 			Attributes: []attribute.KeyValue{
 				otelgrpc.RPCMessageIDKey.Int(4),
 				otelgrpc.RPCMessageTypeKey.String("RECEIVED"),
-				otelgrpc.RPCMessageUncompressedSizeKey.Int(58987),
 			},
 		},
 	}, pingPong.Events())
@@ -375,7 +354,6 @@ func checkStreamServerSpans(t *testing.T, spans []trace.ReadOnlySpan) {
 			Attributes: []attribute.KeyValue{
 				otelgrpc.RPCMessageIDKey.Int(1),
 				otelgrpc.RPCMessageTypeKey.String("RECEIVED"),
-				otelgrpc.RPCMessageUncompressedSizeKey.Int(27190),
 			},
 		},
 		{
@@ -383,7 +361,6 @@ func checkStreamServerSpans(t *testing.T, spans []trace.ReadOnlySpan) {
 			Attributes: []attribute.KeyValue{
 				otelgrpc.RPCMessageIDKey.Int(2),
 				otelgrpc.RPCMessageTypeKey.String("RECEIVED"),
-				otelgrpc.RPCMessageUncompressedSizeKey.Int(12),
 			},
 		},
 		{
@@ -391,7 +368,6 @@ func checkStreamServerSpans(t *testing.T, spans []trace.ReadOnlySpan) {
 			Attributes: []attribute.KeyValue{
 				otelgrpc.RPCMessageIDKey.Int(3),
 				otelgrpc.RPCMessageTypeKey.String("RECEIVED"),
-				otelgrpc.RPCMessageUncompressedSizeKey.Int(1834),
 			},
 		},
 		{
@@ -399,7 +375,6 @@ func checkStreamServerSpans(t *testing.T, spans []trace.ReadOnlySpan) {
 			Attributes: []attribute.KeyValue{
 				otelgrpc.RPCMessageIDKey.Int(4),
 				otelgrpc.RPCMessageTypeKey.String("RECEIVED"),
-				otelgrpc.RPCMessageUncompressedSizeKey.Int(45912),
 			},
 		},
 		{
@@ -407,7 +382,6 @@ func checkStreamServerSpans(t *testing.T, spans []trace.ReadOnlySpan) {
 			Attributes: []attribute.KeyValue{
 				otelgrpc.RPCMessageIDKey.Int(1),
 				otelgrpc.RPCMessageTypeKey.String("SENT"),
-				otelgrpc.RPCMessageUncompressedSizeKey.Int(4),
 			},
 		},
 	}, streamInput.Events())
@@ -428,7 +402,6 @@ func checkStreamServerSpans(t *testing.T, spans []trace.ReadOnlySpan) {
 			Attributes: []attribute.KeyValue{
 				otelgrpc.RPCMessageIDKey.Int(1),
 				otelgrpc.RPCMessageTypeKey.String("RECEIVED"),
-				otelgrpc.RPCMessageUncompressedSizeKey.Int(21),
 			},
 		},
 		{
@@ -436,7 +409,6 @@ func checkStreamServerSpans(t *testing.T, spans []trace.ReadOnlySpan) {
 			Attributes: []attribute.KeyValue{
 				otelgrpc.RPCMessageIDKey.Int(1),
 				otelgrpc.RPCMessageTypeKey.String("SENT"),
-				otelgrpc.RPCMessageUncompressedSizeKey.Int(31423),
 			},
 		},
 		{
@@ -444,7 +416,6 @@ func checkStreamServerSpans(t *testing.T, spans []trace.ReadOnlySpan) {
 			Attributes: []attribute.KeyValue{
 				otelgrpc.RPCMessageIDKey.Int(2),
 				otelgrpc.RPCMessageTypeKey.String("SENT"),
-				otelgrpc.RPCMessageUncompressedSizeKey.Int(13),
 			},
 		},
 		{
@@ -452,7 +423,6 @@ func checkStreamServerSpans(t *testing.T, spans []trace.ReadOnlySpan) {
 			Attributes: []attribute.KeyValue{
 				otelgrpc.RPCMessageIDKey.Int(3),
 				otelgrpc.RPCMessageTypeKey.String("SENT"),
-				otelgrpc.RPCMessageUncompressedSizeKey.Int(2659),
 			},
 		},
 		{
@@ -460,7 +430,6 @@ func checkStreamServerSpans(t *testing.T, spans []trace.ReadOnlySpan) {
 			Attributes: []attribute.KeyValue{
 				otelgrpc.RPCMessageIDKey.Int(4),
 				otelgrpc.RPCMessageTypeKey.String("SENT"),
-				otelgrpc.RPCMessageUncompressedSizeKey.Int(58987),
 			},
 		},
 	}, streamOutput.Events())
@@ -480,7 +449,6 @@ func checkStreamServerSpans(t *testing.T, spans []trace.ReadOnlySpan) {
 			Attributes: []attribute.KeyValue{
 				otelgrpc.RPCMessageIDKey.Int(1),
 				otelgrpc.RPCMessageTypeKey.String("RECEIVED"),
-				otelgrpc.RPCMessageUncompressedSizeKey.Int(27196),
 			},
 		},
 		{
@@ -488,7 +456,6 @@ func checkStreamServerSpans(t *testing.T, spans []trace.ReadOnlySpan) {
 			Attributes: []attribute.KeyValue{
 				otelgrpc.RPCMessageIDKey.Int(1),
 				otelgrpc.RPCMessageTypeKey.String("SENT"),
-				otelgrpc.RPCMessageUncompressedSizeKey.Int(31423),
 			},
 		},
 		{
@@ -496,7 +463,6 @@ func checkStreamServerSpans(t *testing.T, spans []trace.ReadOnlySpan) {
 			Attributes: []attribute.KeyValue{
 				otelgrpc.RPCMessageIDKey.Int(2),
 				otelgrpc.RPCMessageTypeKey.String("RECEIVED"),
-				otelgrpc.RPCMessageUncompressedSizeKey.Int(16),
 			},
 		},
 		{
@@ -504,7 +470,6 @@ func checkStreamServerSpans(t *testing.T, spans []trace.ReadOnlySpan) {
 			Attributes: []attribute.KeyValue{
 				otelgrpc.RPCMessageIDKey.Int(2),
 				otelgrpc.RPCMessageTypeKey.String("SENT"),
-				otelgrpc.RPCMessageUncompressedSizeKey.Int(13),
 			},
 		},
 		{
@@ -512,7 +477,6 @@ func checkStreamServerSpans(t *testing.T, spans []trace.ReadOnlySpan) {
 			Attributes: []attribute.KeyValue{
 				otelgrpc.RPCMessageIDKey.Int(3),
 				otelgrpc.RPCMessageTypeKey.String("RECEIVED"),
-				otelgrpc.RPCMessageUncompressedSizeKey.Int(1839),
 			},
 		},
 		{
@@ -520,7 +484,6 @@ func checkStreamServerSpans(t *testing.T, spans []trace.ReadOnlySpan) {
 			Attributes: []attribute.KeyValue{
 				otelgrpc.RPCMessageIDKey.Int(3),
 				otelgrpc.RPCMessageTypeKey.String("SENT"),
-				otelgrpc.RPCMessageUncompressedSizeKey.Int(2659),
 			},
 		},
 		{
@@ -528,7 +491,6 @@ func checkStreamServerSpans(t *testing.T, spans []trace.ReadOnlySpan) {
 			Attributes: []attribute.KeyValue{
 				otelgrpc.RPCMessageIDKey.Int(4),
 				otelgrpc.RPCMessageTypeKey.String("RECEIVED"),
-				otelgrpc.RPCMessageUncompressedSizeKey.Int(45918),
 			},
 		},
 		{
@@ -536,7 +498,6 @@ func checkStreamServerSpans(t *testing.T, spans []trace.ReadOnlySpan) {
 			Attributes: []attribute.KeyValue{
 				otelgrpc.RPCMessageIDKey.Int(4),
 				otelgrpc.RPCMessageTypeKey.String("SENT"),
-				otelgrpc.RPCMessageUncompressedSizeKey.Int(58987),
 			},
 		},
 	}, pingPong.Events())
@@ -560,7 +521,6 @@ func checkUnaryServerSpans(t *testing.T, spans []trace.ReadOnlySpan) {
 			Attributes: []attribute.KeyValue{
 				otelgrpc.RPCMessageIDKey.Int(1),
 				otelgrpc.RPCMessageTypeKey.String("RECEIVED"),
-				otelgrpc.RPCMessageUncompressedSizeKey.Int(0),
 			},
 		},
 		{
@@ -568,7 +528,6 @@ func checkUnaryServerSpans(t *testing.T, spans []trace.ReadOnlySpan) {
 			Attributes: []attribute.KeyValue{
 				otelgrpc.RPCMessageIDKey.Int(1),
 				otelgrpc.RPCMessageTypeKey.String("SENT"),
-				otelgrpc.RPCMessageUncompressedSizeKey.Int(0),
 			},
 		},
 	}, emptySpan.Events())
@@ -589,7 +548,6 @@ func checkUnaryServerSpans(t *testing.T, spans []trace.ReadOnlySpan) {
 				otelgrpc.RPCMessageIDKey.Int(1),
 				otelgrpc.RPCMessageTypeKey.String("RECEIVED"),
 				// largeReqSize from "google.golang.org/grpc/interop" + 12 (overhead).
-				otelgrpc.RPCMessageUncompressedSizeKey.Int(271840),
 			},
 		},
 		{
@@ -598,7 +556,6 @@ func checkUnaryServerSpans(t *testing.T, spans []trace.ReadOnlySpan) {
 				otelgrpc.RPCMessageIDKey.Int(1),
 				otelgrpc.RPCMessageTypeKey.String("SENT"),
 				// largeRespSize from "google.golang.org/grpc/interop" + 8 (overhead).
-				otelgrpc.RPCMessageUncompressedSizeKey.Int(314167),
 			},
 		},
 	}, largeSpan.Events())
diff --git a/instrumentation/google.golang.org/grpc/otelgrpc/test/interceptor_test.go b/instrumentation/google.golang.org/grpc/otelgrpc/test/interceptor_test.go
index 89bf1beea..ca03eb679 100644
--- a/instrumentation/google.golang.org/grpc/otelgrpc/test/interceptor_test.go
+++ b/instrumentation/google.golang.org/grpc/otelgrpc/test/interceptor_test.go
@@ -39,7 +39,6 @@ import (
 	"google.golang.org/grpc/interop/grpc_testing"
 	"google.golang.org/grpc/metadata"
 	"google.golang.org/grpc/status"
-	"google.golang.org/protobuf/proto"
 )
 
 func getSpanFromRecorder(sr *tracetest.SpanRecorder, name string) (trace.ReadOnlySpan, bool) {
@@ -102,14 +101,12 @@ func TestUnaryClientInterceptor(t *testing.T) {
 			},
 			eventsAttr: []map[attribute.Key]attribute.Value{
 				{
-					otelgrpc.RPCMessageTypeKey:             attribute.StringValue("SENT"),
-					otelgrpc.RPCMessageIDKey:               attribute.IntValue(1),
-					otelgrpc.RPCMessageUncompressedSizeKey: attribute.IntValue(proto.Size(req)),
+					otelgrpc.RPCMessageTypeKey: attribute.StringValue("SENT"),
+					otelgrpc.RPCMessageIDKey:   attribute.IntValue(1),
 				},
 				{
-					otelgrpc.RPCMessageTypeKey:             attribute.StringValue("RECEIVED"),
-					otelgrpc.RPCMessageIDKey:               attribute.IntValue(1),
-					otelgrpc.RPCMessageUncompressedSizeKey: attribute.IntValue(proto.Size(reply)),
+					otelgrpc.RPCMessageTypeKey: attribute.StringValue("RECEIVED"),
+					otelgrpc.RPCMessageIDKey:   attribute.IntValue(1),
 				},
 			},
 		},
@@ -126,14 +123,12 @@ func TestUnaryClientInterceptor(t *testing.T) {
 			},
 			eventsAttr: []map[attribute.Key]attribute.Value{
 				{
-					otelgrpc.RPCMessageTypeKey:             attribute.StringValue("SENT"),
-					otelgrpc.RPCMessageIDKey:               attribute.IntValue(1),
-					otelgrpc.RPCMessageUncompressedSizeKey: attribute.IntValue(proto.Size(req)),
+					otelgrpc.RPCMessageTypeKey: attribute.StringValue("SENT"),
+					otelgrpc.RPCMessageIDKey:   attribute.IntValue(1),
 				},
 				{
-					otelgrpc.RPCMessageTypeKey:             attribute.StringValue("RECEIVED"),
-					otelgrpc.RPCMessageIDKey:               attribute.IntValue(1),
-					otelgrpc.RPCMessageUncompressedSizeKey: attribute.IntValue(proto.Size(reply)),
+					otelgrpc.RPCMessageTypeKey: attribute.StringValue("RECEIVED"),
+					otelgrpc.RPCMessageIDKey:   attribute.IntValue(1),
 				},
 			},
 		},
@@ -150,14 +145,12 @@ func TestUnaryClientInterceptor(t *testing.T) {
 			},
 			eventsAttr: []map[attribute.Key]attribute.Value{
 				{
-					otelgrpc.RPCMessageTypeKey:             attribute.StringValue("SENT"),
-					otelgrpc.RPCMessageIDKey:               attribute.IntValue(1),
-					otelgrpc.RPCMessageUncompressedSizeKey: attribute.IntValue(proto.Size(req)),
+					otelgrpc.RPCMessageTypeKey: attribute.StringValue("SENT"),
+					otelgrpc.RPCMessageIDKey:   attribute.IntValue(1),
 				},
 				{
-					otelgrpc.RPCMessageTypeKey:             attribute.StringValue("RECEIVED"),
-					otelgrpc.RPCMessageIDKey:               attribute.IntValue(1),
-					otelgrpc.RPCMessageUncompressedSizeKey: attribute.IntValue(proto.Size(reply)),
+					otelgrpc.RPCMessageTypeKey: attribute.StringValue("RECEIVED"),
+					otelgrpc.RPCMessageIDKey:   attribute.IntValue(1),
 				},
 			},
 		},
@@ -175,14 +168,12 @@ func TestUnaryClientInterceptor(t *testing.T) {
 			},
 			eventsAttr: []map[attribute.Key]attribute.Value{
 				{
-					otelgrpc.RPCMessageTypeKey:             attribute.StringValue("SENT"),
-					otelgrpc.RPCMessageIDKey:               attribute.IntValue(1),
-					otelgrpc.RPCMessageUncompressedSizeKey: attribute.IntValue(proto.Size(req)),
+					otelgrpc.RPCMessageTypeKey: attribute.StringValue("SENT"),
+					otelgrpc.RPCMessageIDKey:   attribute.IntValue(1),
 				},
 				{
-					otelgrpc.RPCMessageTypeKey:             attribute.StringValue("RECEIVED"),
-					otelgrpc.RPCMessageIDKey:               attribute.IntValue(1),
-					otelgrpc.RPCMessageUncompressedSizeKey: attribute.IntValue(proto.Size(reply)),
+					otelgrpc.RPCMessageTypeKey: attribute.StringValue("RECEIVED"),
+					otelgrpc.RPCMessageIDKey:   attribute.IntValue(1),
 				},
 			},
 			expectErr: true,
@@ -198,14 +189,12 @@ func TestUnaryClientInterceptor(t *testing.T) {
 			},
 			eventsAttr: []map[attribute.Key]attribute.Value{
 				{
-					otelgrpc.RPCMessageTypeKey:             attribute.StringValue("SENT"),
-					otelgrpc.RPCMessageIDKey:               attribute.IntValue(1),
-					otelgrpc.RPCMessageUncompressedSizeKey: attribute.IntValue(proto.Size(req)),
+					otelgrpc.RPCMessageTypeKey: attribute.StringValue("SENT"),
+					otelgrpc.RPCMessageIDKey:   attribute.IntValue(1),
 				},
 				{
-					otelgrpc.RPCMessageTypeKey:             attribute.StringValue("RECEIVED"),
-					otelgrpc.RPCMessageIDKey:               attribute.IntValue(1),
-					otelgrpc.RPCMessageUncompressedSizeKey: attribute.IntValue(proto.Size(reply)),
+					otelgrpc.RPCMessageTypeKey: attribute.StringValue("RECEIVED"),
+					otelgrpc.RPCMessageIDKey:   attribute.IntValue(1),
 				},
 			},
 		},
@@ -222,14 +211,12 @@ func TestUnaryClientInterceptor(t *testing.T) {
 			},
 			eventsAttr: []map[attribute.Key]attribute.Value{
 				{
-					otelgrpc.RPCMessageTypeKey:             attribute.StringValue("SENT"),
-					otelgrpc.RPCMessageIDKey:               attribute.IntValue(1),
-					otelgrpc.RPCMessageUncompressedSizeKey: attribute.IntValue(proto.Size(req)),
+					otelgrpc.RPCMessageTypeKey: attribute.StringValue("SENT"),
+					otelgrpc.RPCMessageIDKey:   attribute.IntValue(1),
 				},
 				{
-					otelgrpc.RPCMessageTypeKey:             attribute.StringValue("RECEIVED"),
-					otelgrpc.RPCMessageIDKey:               attribute.IntValue(1),
-					otelgrpc.RPCMessageUncompressedSizeKey: attribute.IntValue(proto.Size(reply)),
+					otelgrpc.RPCMessageTypeKey: attribute.StringValue("RECEIVED"),
+					otelgrpc.RPCMessageIDKey:   attribute.IntValue(1),
 				},
 			},
 		},
@@ -594,7 +581,6 @@ func TestServerInterceptorError(t *testing.T) {
 	assert.ElementsMatch(t, []attribute.KeyValue{
 		attribute.Key("message.type").String("SENT"),
 		attribute.Key("message.id").Int(1),
-		attribute.Key("message.uncompressed_size").Int(26),
 	}, span.Events()[1].Attributes)
 }