From 4f79357bfbfb466b288e58b4f8f3df15a06a35eb Mon Sep 17 00:00:00 2001 From: Vinothkumar Date: Mon, 21 Jul 2025 07:01:42 +0000 Subject: [PATCH] Removed client retry attributes from server span --- stats/opentelemetry/e2e_test.go | 50 --------------------------------- stats/opentelemetry/trace.go | 13 ++++++--- 2 files changed, 9 insertions(+), 54 deletions(-) diff --git a/stats/opentelemetry/e2e_test.go b/stats/opentelemetry/e2e_test.go index 4e29f51ae..e6629509f 100644 --- a/stats/opentelemetry/e2e_test.go +++ b/stats/opentelemetry/e2e_test.go @@ -868,14 +868,6 @@ func (s) TestMetricsAndTracesOptionEnabled(t *testing.T) { Key: "FailFast", Value: attribute.BoolValue(false), }, - { - Key: "previous-rpc-attempts", - Value: attribute.IntValue(0), - }, - { - Key: "transparent-retry", - Value: attribute.BoolValue(false), - }, }, events: []trace.Event{ { @@ -990,14 +982,6 @@ func (s) TestMetricsAndTracesOptionEnabled(t *testing.T) { Key: "FailFast", Value: attribute.BoolValue(false), }, - { - Key: "previous-rpc-attempts", - Value: attribute.IntValue(0), - }, - { - Key: "transparent-retry", - Value: attribute.BoolValue(false), - }, }, events: nil, }, @@ -1092,14 +1076,6 @@ func (s) TestSpan(t *testing.T) { Key: "FailFast", Value: attribute.BoolValue(false), }, - { - Key: "previous-rpc-attempts", - Value: attribute.IntValue(0), - }, - { - Key: "transparent-retry", - Value: attribute.BoolValue(false), - }, }, events: []trace.Event{ { @@ -1198,14 +1174,6 @@ func (s) TestSpan(t *testing.T) { Key: "FailFast", Value: attribute.BoolValue(false), }, - { - Key: "previous-rpc-attempts", - Value: attribute.IntValue(0), - }, - { - Key: "transparent-retry", - Value: attribute.BoolValue(false), - }, }, events: nil, }, @@ -1302,14 +1270,6 @@ func (s) TestSpan_WithW3CContextPropagator(t *testing.T) { Key: "FailFast", Value: attribute.BoolValue(false), }, - { - Key: "previous-rpc-attempts", - Value: attribute.IntValue(0), - }, - { - Key: "transparent-retry", - Value: attribute.BoolValue(false), - }, }, events: []trace.Event{ { @@ -1408,14 +1368,6 @@ func (s) TestSpan_WithW3CContextPropagator(t *testing.T) { Key: "FailFast", Value: attribute.BoolValue(false), }, - { - Key: "previous-rpc-attempts", - Value: attribute.IntValue(0), - }, - { - Key: "transparent-retry", - Value: attribute.BoolValue(false), - }, }, events: nil, }, @@ -1766,8 +1718,6 @@ func (s) TestStreamingRPC_TraceSequenceNumbers(t *testing.T) { attributes: []attribute.KeyValue{ attribute.Bool("Client", false), attribute.Bool("FailFast", false), - attribute.Int("previous-rpc-attempts", 0), - attribute.Bool("transparent-retry", false), }, }, { diff --git a/stats/opentelemetry/trace.go b/stats/opentelemetry/trace.go index efafdd075..680290bc3 100644 --- a/stats/opentelemetry/trace.go +++ b/stats/opentelemetry/trace.go @@ -44,12 +44,17 @@ func populateSpan(rs stats.RPCStats, ai *attemptInfo) { // Note: Go always added Client and FailFast attributes even though they are not // defined by the OpenCensus gRPC spec. Thus, they are unimportant for // correctness. - span.SetAttributes( + attrs := []attribute.KeyValue{ attribute.Bool("Client", rs.Client), attribute.Bool("FailFast", rs.FailFast), - attribute.Int64("previous-rpc-attempts", int64(ai.previousRPCAttempts)), - attribute.Bool("transparent-retry", rs.IsTransparentRetryAttempt), - ) + } + if rs.Client { + attrs = append(attrs, + attribute.Int64("previous-rpc-attempts", int64(ai.previousRPCAttempts)), + attribute.Bool("transparent-retry", rs.IsTransparentRetryAttempt), + ) + } + span.SetAttributes(attrs...) // increment previous rpc attempts applicable for next attempt atomic.AddUint32(&ai.previousRPCAttempts, 1) case *stats.PickerUpdated: