Skip to content

Commit b8d011c

Browse files
yashyktpurnesh42H
authored andcommitted
stats/opentelemetry: fix trace attributes message sequence numbers to start from 0 (grpc#8237)
1 parent ed9081b commit b8d011c

File tree

2 files changed

+14
-14
lines changed

2 files changed

+14
-14
lines changed

stats/opentelemetry/e2e_test.go

+12-12
Original file line numberDiff line numberDiff line change
@@ -876,7 +876,7 @@ func (s) TestMetricsAndTracesOptionEnabled(t *testing.T) {
876876
Attributes: []attribute.KeyValue{
877877
{
878878
Key: "sequence-number",
879-
Value: attribute.IntValue(1),
879+
Value: attribute.IntValue(0),
880880
},
881881
{
882882
Key: "message-size",
@@ -893,7 +893,7 @@ func (s) TestMetricsAndTracesOptionEnabled(t *testing.T) {
893893
Attributes: []attribute.KeyValue{
894894
{
895895
Key: "sequence-number",
896-
Value: attribute.IntValue(1),
896+
Value: attribute.IntValue(0),
897897
},
898898
{
899899
Key: "message-size",
@@ -934,7 +934,7 @@ func (s) TestMetricsAndTracesOptionEnabled(t *testing.T) {
934934
Attributes: []attribute.KeyValue{
935935
{
936936
Key: "sequence-number",
937-
Value: attribute.IntValue(1),
937+
Value: attribute.IntValue(0),
938938
},
939939
{
940940
Key: "message-size",
@@ -951,7 +951,7 @@ func (s) TestMetricsAndTracesOptionEnabled(t *testing.T) {
951951
Attributes: []attribute.KeyValue{
952952
{
953953
Key: "sequence-number",
954-
Value: attribute.IntValue(1),
954+
Value: attribute.IntValue(0),
955955
},
956956
{
957957
Key: "message-size",
@@ -1100,7 +1100,7 @@ func (s) TestSpan(t *testing.T) {
11001100
Attributes: []attribute.KeyValue{
11011101
{
11021102
Key: "sequence-number",
1103-
Value: attribute.IntValue(1),
1103+
Value: attribute.IntValue(0),
11041104
},
11051105
{
11061106
Key: "message-size",
@@ -1117,7 +1117,7 @@ func (s) TestSpan(t *testing.T) {
11171117
Attributes: []attribute.KeyValue{
11181118
{
11191119
Key: "sequence-number",
1120-
Value: attribute.IntValue(1),
1120+
Value: attribute.IntValue(0),
11211121
},
11221122
{
11231123
Key: "message-size",
@@ -1158,7 +1158,7 @@ func (s) TestSpan(t *testing.T) {
11581158
Attributes: []attribute.KeyValue{
11591159
{
11601160
Key: "sequence-number",
1161-
Value: attribute.IntValue(1),
1161+
Value: attribute.IntValue(0),
11621162
},
11631163
{
11641164
Key: "message-size",
@@ -1175,7 +1175,7 @@ func (s) TestSpan(t *testing.T) {
11751175
Attributes: []attribute.KeyValue{
11761176
{
11771177
Key: "sequence-number",
1178-
Value: attribute.IntValue(1),
1178+
Value: attribute.IntValue(0),
11791179
},
11801180
{
11811181
Key: "message-size",
@@ -1326,7 +1326,7 @@ func (s) TestSpan_WithW3CContextPropagator(t *testing.T) {
13261326
Attributes: []attribute.KeyValue{
13271327
{
13281328
Key: "sequence-number",
1329-
Value: attribute.IntValue(1),
1329+
Value: attribute.IntValue(0),
13301330
},
13311331
{
13321332
Key: "message-size",
@@ -1343,7 +1343,7 @@ func (s) TestSpan_WithW3CContextPropagator(t *testing.T) {
13431343
Attributes: []attribute.KeyValue{
13441344
{
13451345
Key: "sequence-number",
1346-
Value: attribute.IntValue(1),
1346+
Value: attribute.IntValue(0),
13471347
},
13481348
{
13491349
Key: "message-size",
@@ -1384,7 +1384,7 @@ func (s) TestSpan_WithW3CContextPropagator(t *testing.T) {
13841384
Attributes: []attribute.KeyValue{
13851385
{
13861386
Key: "sequence-number",
1387-
Value: attribute.IntValue(1),
1387+
Value: attribute.IntValue(0),
13881388
},
13891389
{
13901390
Key: "message-size",
@@ -1401,7 +1401,7 @@ func (s) TestSpan_WithW3CContextPropagator(t *testing.T) {
14011401
Attributes: []attribute.KeyValue{
14021402
{
14031403
Key: "sequence-number",
1404-
Value: attribute.IntValue(1),
1404+
Value: attribute.IntValue(0),
14051405
},
14061406
{
14071407
Key: "message-size",

stats/opentelemetry/trace.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -57,19 +57,19 @@ func populateSpan(rs stats.RPCStats, ai *attemptInfo) {
5757
case *stats.InPayload:
5858
// message id - "must be calculated as two different counters starting
5959
// from one for sent messages and one for received messages."
60-
ai.countRecvMsg++
6160
span.AddEvent("Inbound compressed message", trace.WithAttributes(
6261
attribute.Int64("sequence-number", int64(ai.countRecvMsg)),
6362
attribute.Int64("message-size", int64(rs.Length)),
6463
attribute.Int64("message-size-compressed", int64(rs.CompressedLength)),
6564
))
65+
ai.countRecvMsg++
6666
case *stats.OutPayload:
67-
ai.countSentMsg++
6867
span.AddEvent("Outbound compressed message", trace.WithAttributes(
6968
attribute.Int64("sequence-number", int64(ai.countSentMsg)),
7069
attribute.Int64("message-size", int64(rs.Length)),
7170
attribute.Int64("message-size-compressed", int64(rs.CompressedLength)),
7271
))
72+
ai.countSentMsg++
7373
case *stats.End:
7474
if rs.Error != nil {
7575
s := status.Convert(rs.Error)

0 commit comments

Comments
 (0)