@@ -22,6 +22,7 @@ import (
22
22
"github.com/stretchr/testify/assert"
23
23
"github.com/stretchr/testify/require"
24
24
"google.golang.org/grpc"
25
+ "google.golang.org/grpc/codes"
25
26
"google.golang.org/grpc/interop"
26
27
pb "google.golang.org/grpc/interop/grpc_testing"
27
28
"google.golang.org/grpc/test/bufconn"
@@ -136,9 +137,10 @@ func checkUnaryClientSpans(t *testing.T, spans []*tracetest.Span) {
136
137
},
137
138
}, noTimestamp (emptySpan .Events ()))
138
139
assert .Equal (t , map [label.Key ]label.Value {
139
- semconv .RPCMethodKey : label .StringValue ("EmptyCall" ),
140
- semconv .RPCServiceKey : label .StringValue ("grpc.testing.TestService" ),
141
- semconv .RPCSystemGRPC .Key : semconv .RPCSystemGRPC .Value ,
140
+ semconv .RPCMethodKey : label .StringValue ("EmptyCall" ),
141
+ semconv .RPCServiceKey : label .StringValue ("grpc.testing.TestService" ),
142
+ semconv .RPCSystemGRPC .Key : semconv .RPCSystemGRPC .Value ,
143
+ otelgrpc .GRPCStatusCodeKey : label .Uint32Value (uint32 (codes .OK )),
142
144
}, emptySpan .Attributes ())
143
145
144
146
largeSpan := spans [1 ]
@@ -165,9 +167,10 @@ func checkUnaryClientSpans(t *testing.T, spans []*tracetest.Span) {
165
167
},
166
168
}, noTimestamp (largeSpan .Events ()))
167
169
assert .Equal (t , map [label.Key ]label.Value {
168
- semconv .RPCMethodKey : label .StringValue ("UnaryCall" ),
169
- semconv .RPCServiceKey : label .StringValue ("grpc.testing.TestService" ),
170
- semconv .RPCSystemGRPC .Key : semconv .RPCSystemGRPC .Value ,
170
+ semconv .RPCMethodKey : label .StringValue ("UnaryCall" ),
171
+ semconv .RPCServiceKey : label .StringValue ("grpc.testing.TestService" ),
172
+ semconv .RPCSystemGRPC .Key : semconv .RPCSystemGRPC .Value ,
173
+ otelgrpc .GRPCStatusCodeKey : label .Uint32Value (uint32 (codes .OK )),
171
174
}, largeSpan .Attributes ())
172
175
}
173
176
@@ -214,9 +217,10 @@ func checkStreamClientSpans(t *testing.T, spans []*tracetest.Span) {
214
217
// client does not record an event for the server response.
215
218
}, noTimestamp (streamInput .Events ()))
216
219
assert .Equal (t , map [label.Key ]label.Value {
217
- semconv .RPCMethodKey : label .StringValue ("StreamingInputCall" ),
218
- semconv .RPCServiceKey : label .StringValue ("grpc.testing.TestService" ),
219
- semconv .RPCSystemGRPC .Key : semconv .RPCSystemGRPC .Value ,
220
+ semconv .RPCMethodKey : label .StringValue ("StreamingInputCall" ),
221
+ semconv .RPCServiceKey : label .StringValue ("grpc.testing.TestService" ),
222
+ semconv .RPCSystemGRPC .Key : semconv .RPCSystemGRPC .Value ,
223
+ otelgrpc .GRPCStatusCodeKey : label .Uint32Value (uint32 (codes .OK )),
220
224
}, streamInput .Attributes ())
221
225
222
226
streamOutput := spans [1 ]
@@ -266,9 +270,10 @@ func checkStreamClientSpans(t *testing.T, spans []*tracetest.Span) {
266
270
},
267
271
}, noTimestamp (streamOutput .Events ()))
268
272
assert .Equal (t , map [label.Key ]label.Value {
269
- semconv .RPCMethodKey : label .StringValue ("StreamingOutputCall" ),
270
- semconv .RPCServiceKey : label .StringValue ("grpc.testing.TestService" ),
271
- semconv .RPCSystemGRPC .Key : semconv .RPCSystemGRPC .Value ,
273
+ semconv .RPCMethodKey : label .StringValue ("StreamingOutputCall" ),
274
+ semconv .RPCServiceKey : label .StringValue ("grpc.testing.TestService" ),
275
+ semconv .RPCSystemGRPC .Key : semconv .RPCSystemGRPC .Value ,
276
+ otelgrpc .GRPCStatusCodeKey : label .Uint32Value (uint32 (codes .OK )),
272
277
}, streamOutput .Attributes ())
273
278
274
279
pingPong := spans [2 ]
@@ -341,9 +346,10 @@ func checkStreamClientSpans(t *testing.T, spans []*tracetest.Span) {
341
346
},
342
347
}, noTimestamp (pingPong .Events ()))
343
348
assert .Equal (t , map [label.Key ]label.Value {
344
- semconv .RPCMethodKey : label .StringValue ("FullDuplexCall" ),
345
- semconv .RPCServiceKey : label .StringValue ("grpc.testing.TestService" ),
346
- semconv .RPCSystemGRPC .Key : semconv .RPCSystemGRPC .Value ,
349
+ semconv .RPCMethodKey : label .StringValue ("FullDuplexCall" ),
350
+ semconv .RPCServiceKey : label .StringValue ("grpc.testing.TestService" ),
351
+ semconv .RPCSystemGRPC .Key : semconv .RPCSystemGRPC .Value ,
352
+ otelgrpc .GRPCStatusCodeKey : label .Uint32Value (uint32 (codes .OK )),
347
353
}, pingPong .Attributes ())
348
354
}
349
355
@@ -397,9 +403,10 @@ func checkStreamServerSpans(t *testing.T, spans []*tracetest.Span) {
397
403
},
398
404
}, noTimestamp (streamInput .Events ()))
399
405
assert .Equal (t , map [label.Key ]label.Value {
400
- semconv .RPCMethodKey : label .StringValue ("StreamingInputCall" ),
401
- semconv .RPCServiceKey : label .StringValue ("grpc.testing.TestService" ),
402
- semconv .RPCSystemGRPC .Key : semconv .RPCSystemGRPC .Value ,
406
+ semconv .RPCMethodKey : label .StringValue ("StreamingInputCall" ),
407
+ semconv .RPCServiceKey : label .StringValue ("grpc.testing.TestService" ),
408
+ semconv .RPCSystemGRPC .Key : semconv .RPCSystemGRPC .Value ,
409
+ otelgrpc .GRPCStatusCodeKey : label .Uint32Value (uint32 (codes .OK )),
403
410
}, streamInput .Attributes ())
404
411
405
412
streamOutput := spans [1 ]
@@ -449,9 +456,10 @@ func checkStreamServerSpans(t *testing.T, spans []*tracetest.Span) {
449
456
},
450
457
}, noTimestamp (streamOutput .Events ()))
451
458
assert .Equal (t , map [label.Key ]label.Value {
452
- semconv .RPCMethodKey : label .StringValue ("StreamingOutputCall" ),
453
- semconv .RPCServiceKey : label .StringValue ("grpc.testing.TestService" ),
454
- semconv .RPCSystemGRPC .Key : semconv .RPCSystemGRPC .Value ,
459
+ semconv .RPCMethodKey : label .StringValue ("StreamingOutputCall" ),
460
+ semconv .RPCServiceKey : label .StringValue ("grpc.testing.TestService" ),
461
+ semconv .RPCSystemGRPC .Key : semconv .RPCSystemGRPC .Value ,
462
+ otelgrpc .GRPCStatusCodeKey : label .Uint32Value (uint32 (codes .OK )),
455
463
}, streamOutput .Attributes ())
456
464
457
465
pingPong := spans [2 ]
@@ -524,9 +532,10 @@ func checkStreamServerSpans(t *testing.T, spans []*tracetest.Span) {
524
532
},
525
533
}, noTimestamp (pingPong .Events ()))
526
534
assert .Equal (t , map [label.Key ]label.Value {
527
- semconv .RPCMethodKey : label .StringValue ("FullDuplexCall" ),
528
- semconv .RPCServiceKey : label .StringValue ("grpc.testing.TestService" ),
529
- semconv .RPCSystemGRPC .Key : semconv .RPCSystemGRPC .Value ,
535
+ semconv .RPCMethodKey : label .StringValue ("FullDuplexCall" ),
536
+ semconv .RPCServiceKey : label .StringValue ("grpc.testing.TestService" ),
537
+ semconv .RPCSystemGRPC .Key : semconv .RPCSystemGRPC .Value ,
538
+ otelgrpc .GRPCStatusCodeKey : label .Uint32Value (uint32 (codes .OK )),
530
539
}, pingPong .Attributes ())
531
540
}
532
541
@@ -555,9 +564,10 @@ func checkUnaryServerSpans(t *testing.T, spans []*tracetest.Span) {
555
564
},
556
565
}, noTimestamp (emptySpan .Events ()))
557
566
assert .Equal (t , map [label.Key ]label.Value {
558
- semconv .RPCMethodKey : label .StringValue ("EmptyCall" ),
559
- semconv .RPCServiceKey : label .StringValue ("grpc.testing.TestService" ),
560
- semconv .RPCSystemGRPC .Key : semconv .RPCSystemGRPC .Value ,
567
+ semconv .RPCMethodKey : label .StringValue ("EmptyCall" ),
568
+ semconv .RPCServiceKey : label .StringValue ("grpc.testing.TestService" ),
569
+ semconv .RPCSystemGRPC .Key : semconv .RPCSystemGRPC .Value ,
570
+ otelgrpc .GRPCStatusCodeKey : label .Uint32Value (uint32 (codes .OK )),
561
571
}, emptySpan .Attributes ())
562
572
563
573
largeSpan := spans [1 ]
@@ -584,9 +594,10 @@ func checkUnaryServerSpans(t *testing.T, spans []*tracetest.Span) {
584
594
},
585
595
}, noTimestamp (largeSpan .Events ()))
586
596
assert .Equal (t , map [label.Key ]label.Value {
587
- semconv .RPCMethodKey : label .StringValue ("UnaryCall" ),
588
- semconv .RPCServiceKey : label .StringValue ("grpc.testing.TestService" ),
589
- semconv .RPCSystemGRPC .Key : semconv .RPCSystemGRPC .Value ,
597
+ semconv .RPCMethodKey : label .StringValue ("UnaryCall" ),
598
+ semconv .RPCServiceKey : label .StringValue ("grpc.testing.TestService" ),
599
+ semconv .RPCSystemGRPC .Key : semconv .RPCSystemGRPC .Value ,
600
+ otelgrpc .GRPCStatusCodeKey : label .Uint32Value (uint32 (codes .OK )),
590
601
}, largeSpan .Attributes ())
591
602
}
592
603
0 commit comments