@@ -19,6 +19,9 @@ import (
19
19
testpb "google.golang.org/grpc/interop/grpc_testing"
20
20
"google.golang.org/grpc/status"
21
21
22
+ "go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc"
23
+ "go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc/filters"
24
+ "go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc/internal/test"
22
25
"go.opentelemetry.io/otel/attribute"
23
26
"go.opentelemetry.io/otel/sdk/instrumentation"
24
27
"go.opentelemetry.io/otel/sdk/metric"
@@ -27,15 +30,12 @@ import (
27
30
"go.opentelemetry.io/otel/sdk/trace"
28
31
"go.opentelemetry.io/otel/sdk/trace/tracetest"
29
32
semconv "go.opentelemetry.io/otel/semconv/v1.17.0"
30
-
31
- "go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc"
32
- "go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc/filters"
33
- "go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc/internal/test"
34
33
)
35
34
36
35
var (
37
- testSpanAttr = attribute .String ("test_span" , "OK" )
38
- testMetricAttr = attribute .String ("test_metric" , "OK" )
36
+ testSpanAttr = attribute .String ("test_span" , "OK" )
37
+ testMetricAttr = attribute .String ("test_metric" , "OK" )
38
+ customTestMetricAttr = attribute .String ("custom_test_metric" , "OK" )
39
39
)
40
40
41
41
func TestStatsHandler (t * testing.T ) {
@@ -1115,15 +1115,19 @@ func checkServerMetrics(t *testing.T, reader metric.Reader) {
1115
1115
semconv .RPCMethod ("EmptyCall" ),
1116
1116
semconv .RPCService ("grpc.testing.TestService" ),
1117
1117
semconv .RPCSystemGRPC ,
1118
- testMetricAttr ),
1118
+ testMetricAttr ,
1119
+ customTestMetricAttr ,
1120
+ ),
1119
1121
},
1120
1122
{
1121
1123
Attributes : attribute .NewSet (
1122
1124
semconv .RPCGRPCStatusCodeOk ,
1123
1125
semconv .RPCMethod ("UnaryCall" ),
1124
1126
semconv .RPCService ("grpc.testing.TestService" ),
1125
1127
semconv .RPCSystemGRPC ,
1126
- testMetricAttr ),
1128
+ testMetricAttr ,
1129
+ customTestMetricAttr ,
1130
+ ),
1127
1131
},
1128
1132
{
1129
1133
Attributes : attribute .NewSet (
@@ -1164,7 +1168,8 @@ func checkServerMetrics(t *testing.T, reader metric.Reader) {
1164
1168
semconv .RPCMethod ("EmptyCall" ),
1165
1169
semconv .RPCService ("grpc.testing.TestService" ),
1166
1170
semconv .RPCSystemGRPC ,
1167
- testMetricAttr ),
1171
+ testMetricAttr ,
1172
+ ),
1168
1173
Bounds : []float64 {0 , 5 , 10 , 25 , 50 , 75 , 100 , 250 , 500 , 750 , 1000 , 2500 , 5000 , 7500 , 10000 },
1169
1174
BucketCounts : []uint64 {1 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 },
1170
1175
Max : metricdata .NewExtrema (int64 (0 )),
@@ -1177,7 +1182,8 @@ func checkServerMetrics(t *testing.T, reader metric.Reader) {
1177
1182
semconv .RPCMethod ("UnaryCall" ),
1178
1183
semconv .RPCService ("grpc.testing.TestService" ),
1179
1184
semconv .RPCSystemGRPC ,
1180
- testMetricAttr ),
1185
+ testMetricAttr ,
1186
+ ),
1181
1187
Bounds : []float64 {0 , 5 , 10 , 25 , 50 , 75 , 100 , 250 , 500 , 750 , 1000 , 2500 , 5000 , 7500 , 10000 },
1182
1188
BucketCounts : []uint64 {0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 1 },
1183
1189
Max : metricdata .NewExtrema (int64 (271840 )),
@@ -1239,7 +1245,9 @@ func checkServerMetrics(t *testing.T, reader metric.Reader) {
1239
1245
semconv .RPCMethod ("EmptyCall" ),
1240
1246
semconv .RPCService ("grpc.testing.TestService" ),
1241
1247
semconv .RPCSystemGRPC ,
1242
- testMetricAttr ),
1248
+ testMetricAttr ,
1249
+ customTestMetricAttr ,
1250
+ ),
1243
1251
Bounds : []float64 {0 , 5 , 10 , 25 , 50 , 75 , 100 , 250 , 500 , 750 , 1000 , 2500 , 5000 , 7500 , 10000 },
1244
1252
BucketCounts : []uint64 {1 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 },
1245
1253
Max : metricdata .NewExtrema (int64 (0 )),
@@ -1252,7 +1260,9 @@ func checkServerMetrics(t *testing.T, reader metric.Reader) {
1252
1260
semconv .RPCMethod ("UnaryCall" ),
1253
1261
semconv .RPCService ("grpc.testing.TestService" ),
1254
1262
semconv .RPCSystemGRPC ,
1255
- testMetricAttr ),
1263
+ testMetricAttr ,
1264
+ customTestMetricAttr ,
1265
+ ),
1256
1266
Bounds : []float64 {0 , 5 , 10 , 25 , 50 , 75 , 100 , 250 , 500 , 750 , 1000 , 2500 , 5000 , 7500 , 10000 },
1257
1267
BucketCounts : []uint64 {0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 1 },
1258
1268
Max : metricdata .NewExtrema (int64 (314167 )),
@@ -1315,7 +1325,9 @@ func checkServerMetrics(t *testing.T, reader metric.Reader) {
1315
1325
semconv .RPCMethod ("EmptyCall" ),
1316
1326
semconv .RPCService ("grpc.testing.TestService" ),
1317
1327
semconv .RPCSystemGRPC ,
1318
- testMetricAttr ),
1328
+ testMetricAttr ,
1329
+ customTestMetricAttr ,
1330
+ ),
1319
1331
Bounds : []float64 {0 , 5 , 10 , 25 , 50 , 75 , 100 , 250 , 500 , 750 , 1000 , 2500 , 5000 , 7500 , 10000 },
1320
1332
BucketCounts : []uint64 {0 , 1 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 },
1321
1333
Max : metricdata .NewExtrema (int64 (1 )),
@@ -1329,7 +1341,9 @@ func checkServerMetrics(t *testing.T, reader metric.Reader) {
1329
1341
semconv .RPCMethod ("UnaryCall" ),
1330
1342
semconv .RPCService ("grpc.testing.TestService" ),
1331
1343
semconv .RPCSystemGRPC ,
1332
- testMetricAttr ),
1344
+ testMetricAttr ,
1345
+ customTestMetricAttr ,
1346
+ ),
1333
1347
Bounds : []float64 {0 , 5 , 10 , 25 , 50 , 75 , 100 , 250 , 500 , 750 , 1000 , 2500 , 5000 , 7500 , 10000 },
1334
1348
BucketCounts : []uint64 {0 , 1 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 },
1335
1349
Max : metricdata .NewExtrema (int64 (1 )),
@@ -1395,7 +1409,9 @@ func checkServerMetrics(t *testing.T, reader metric.Reader) {
1395
1409
semconv .RPCMethod ("EmptyCall" ),
1396
1410
semconv .RPCService ("grpc.testing.TestService" ),
1397
1411
semconv .RPCSystemGRPC ,
1398
- testMetricAttr ),
1412
+ testMetricAttr ,
1413
+ customTestMetricAttr ,
1414
+ ),
1399
1415
Bounds : []float64 {0 , 5 , 10 , 25 , 50 , 75 , 100 , 250 , 500 , 750 , 1000 , 2500 , 5000 , 7500 , 10000 },
1400
1416
BucketCounts : []uint64 {0 , 1 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 },
1401
1417
Max : metricdata .NewExtrema (int64 (1 )),
@@ -1409,7 +1425,9 @@ func checkServerMetrics(t *testing.T, reader metric.Reader) {
1409
1425
semconv .RPCMethod ("UnaryCall" ),
1410
1426
semconv .RPCService ("grpc.testing.TestService" ),
1411
1427
semconv .RPCSystemGRPC ,
1412
- testMetricAttr ),
1428
+ testMetricAttr ,
1429
+ customTestMetricAttr ,
1430
+ ),
1413
1431
Bounds : []float64 {0 , 5 , 10 , 25 , 50 , 75 , 100 , 250 , 500 , 750 , 1000 , 2500 , 5000 , 7500 , 10000 },
1414
1432
BucketCounts : []uint64 {0 , 1 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 },
1415
1433
Max : metricdata .NewExtrema (int64 (1 )),
0 commit comments