stats/opentelemetry: fix trace attributes message sequence numbers to start from 0 (#8237) (#8252)

This commit is contained in:
Purnesh Dixit 2025-04-15 21:17:24 +05:30 committed by GitHub
parent 57a2605e35
commit 79ca1744ed
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 14 additions and 14 deletions

View File

@ -869,7 +869,7 @@ func (s) TestMetricsAndTracesOptionEnabled(t *testing.T) {
Attributes: []attribute.KeyValue{
{
Key: "sequence-number",
Value: attribute.IntValue(1),
Value: attribute.IntValue(0),
},
{
Key: "message-size",
@ -886,7 +886,7 @@ func (s) TestMetricsAndTracesOptionEnabled(t *testing.T) {
Attributes: []attribute.KeyValue{
{
Key: "sequence-number",
Value: attribute.IntValue(1),
Value: attribute.IntValue(0),
},
{
Key: "message-size",
@ -927,7 +927,7 @@ func (s) TestMetricsAndTracesOptionEnabled(t *testing.T) {
Attributes: []attribute.KeyValue{
{
Key: "sequence-number",
Value: attribute.IntValue(1),
Value: attribute.IntValue(0),
},
{
Key: "message-size",
@ -944,7 +944,7 @@ func (s) TestMetricsAndTracesOptionEnabled(t *testing.T) {
Attributes: []attribute.KeyValue{
{
Key: "sequence-number",
Value: attribute.IntValue(1),
Value: attribute.IntValue(0),
},
{
Key: "message-size",
@ -1093,7 +1093,7 @@ func (s) TestSpan(t *testing.T) {
Attributes: []attribute.KeyValue{
{
Key: "sequence-number",
Value: attribute.IntValue(1),
Value: attribute.IntValue(0),
},
{
Key: "message-size",
@ -1110,7 +1110,7 @@ func (s) TestSpan(t *testing.T) {
Attributes: []attribute.KeyValue{
{
Key: "sequence-number",
Value: attribute.IntValue(1),
Value: attribute.IntValue(0),
},
{
Key: "message-size",
@ -1151,7 +1151,7 @@ func (s) TestSpan(t *testing.T) {
Attributes: []attribute.KeyValue{
{
Key: "sequence-number",
Value: attribute.IntValue(1),
Value: attribute.IntValue(0),
},
{
Key: "message-size",
@ -1168,7 +1168,7 @@ func (s) TestSpan(t *testing.T) {
Attributes: []attribute.KeyValue{
{
Key: "sequence-number",
Value: attribute.IntValue(1),
Value: attribute.IntValue(0),
},
{
Key: "message-size",
@ -1319,7 +1319,7 @@ func (s) TestSpan_WithW3CContextPropagator(t *testing.T) {
Attributes: []attribute.KeyValue{
{
Key: "sequence-number",
Value: attribute.IntValue(1),
Value: attribute.IntValue(0),
},
{
Key: "message-size",
@ -1336,7 +1336,7 @@ func (s) TestSpan_WithW3CContextPropagator(t *testing.T) {
Attributes: []attribute.KeyValue{
{
Key: "sequence-number",
Value: attribute.IntValue(1),
Value: attribute.IntValue(0),
},
{
Key: "message-size",
@ -1377,7 +1377,7 @@ func (s) TestSpan_WithW3CContextPropagator(t *testing.T) {
Attributes: []attribute.KeyValue{
{
Key: "sequence-number",
Value: attribute.IntValue(1),
Value: attribute.IntValue(0),
},
{
Key: "message-size",
@ -1394,7 +1394,7 @@ func (s) TestSpan_WithW3CContextPropagator(t *testing.T) {
Attributes: []attribute.KeyValue{
{
Key: "sequence-number",
Value: attribute.IntValue(1),
Value: attribute.IntValue(0),
},
{
Key: "message-size",

View File

@ -57,19 +57,19 @@ func populateSpan(rs stats.RPCStats, ai *attemptInfo) {
case *stats.InPayload:
// message id - "must be calculated as two different counters starting
// from one for sent messages and one for received messages."
ai.countRecvMsg++
span.AddEvent("Inbound compressed message", trace.WithAttributes(
attribute.Int64("sequence-number", int64(ai.countRecvMsg)),
attribute.Int64("message-size", int64(rs.Length)),
attribute.Int64("message-size-compressed", int64(rs.CompressedLength)),
))
ai.countRecvMsg++
case *stats.OutPayload:
ai.countSentMsg++
span.AddEvent("Outbound compressed message", trace.WithAttributes(
attribute.Int64("sequence-number", int64(ai.countSentMsg)),
attribute.Int64("message-size", int64(rs.Length)),
attribute.Int64("message-size-compressed", int64(rs.CompressedLength)),
))
ai.countSentMsg++
case *stats.End:
if rs.Error != nil {
s := status.Convert(rs.Error)