Skip to content

Commit 85240a5

Browse files
authored
stats: change non-standard units to annotations (#8481)
1 parent ac13172 commit 85240a5

File tree

12 files changed

+40
-40
lines changed

12 files changed

+40
-40
lines changed

balancer/pickfirst/pickfirstleaf/metrics_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,7 @@ func (s) TestPickFirstMetricsE2E(t *testing.T) {
204204
{
205205
Name: "grpc.lb.pick_first.connection_attempts_succeeded",
206206
Description: "EXPERIMENTAL. Number of successful connection attempts.",
207-
Unit: "attempt",
207+
Unit: "{attempt}",
208208
Data: metricdata.Sum[int64]{
209209
DataPoints: []metricdata.DataPoint[int64]{
210210
{
@@ -219,7 +219,7 @@ func (s) TestPickFirstMetricsE2E(t *testing.T) {
219219
{
220220
Name: "grpc.lb.pick_first.connection_attempts_failed",
221221
Description: "EXPERIMENTAL. Number of failed connection attempts.",
222-
Unit: "attempt",
222+
Unit: "{attempt}",
223223
Data: metricdata.Sum[int64]{
224224
DataPoints: []metricdata.DataPoint[int64]{
225225
{
@@ -234,7 +234,7 @@ func (s) TestPickFirstMetricsE2E(t *testing.T) {
234234
{
235235
Name: "grpc.lb.pick_first.disconnections",
236236
Description: "EXPERIMENTAL. Number of times the selected subchannel becomes disconnected.",
237-
Unit: "disconnection",
237+
Unit: "{disconnection}",
238238
Data: metricdata.Sum[int64]{
239239
DataPoints: []metricdata.DataPoint[int64]{
240240
{

balancer/pickfirst/pickfirstleaf/pickfirstleaf.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -67,21 +67,21 @@ var (
6767
disconnectionsMetric = expstats.RegisterInt64Count(expstats.MetricDescriptor{
6868
Name: "grpc.lb.pick_first.disconnections",
6969
Description: "EXPERIMENTAL. Number of times the selected subchannel becomes disconnected.",
70-
Unit: "disconnection",
70+
Unit: "{disconnection}",
7171
Labels: []string{"grpc.target"},
7272
Default: false,
7373
})
7474
connectionAttemptsSucceededMetric = expstats.RegisterInt64Count(expstats.MetricDescriptor{
7575
Name: "grpc.lb.pick_first.connection_attempts_succeeded",
7676
Description: "EXPERIMENTAL. Number of successful connection attempts.",
77-
Unit: "attempt",
77+
Unit: "{attempt}",
7878
Labels: []string{"grpc.target"},
7979
Default: false,
8080
})
8181
connectionAttemptsFailedMetric = expstats.RegisterInt64Count(expstats.MetricDescriptor{
8282
Name: "grpc.lb.pick_first.connection_attempts_failed",
8383
Description: "EXPERIMENTAL. Number of failed connection attempts.",
84-
Unit: "attempt",
84+
Unit: "{attempt}",
8585
Labels: []string{"grpc.target"},
8686
Default: false,
8787
})

balancer/rls/balancer.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ var (
8282
cacheEntriesMetric = estats.RegisterInt64Gauge(estats.MetricDescriptor{
8383
Name: "grpc.lb.rls.cache_entries",
8484
Description: "EXPERIMENTAL. Number of entries in the RLS cache.",
85-
Unit: "entry",
85+
Unit: "{entry}",
8686
Labels: []string{"grpc.target", "grpc.lb.rls.server_target", "grpc.lb.rls.instance_uuid"},
8787
Default: false,
8888
})
@@ -96,21 +96,21 @@ var (
9696
defaultTargetPicksMetric = estats.RegisterInt64Count(estats.MetricDescriptor{
9797
Name: "grpc.lb.rls.default_target_picks",
9898
Description: "EXPERIMENTAL. Number of LB picks sent to the default target.",
99-
Unit: "pick",
99+
Unit: "{pick}",
100100
Labels: []string{"grpc.target", "grpc.lb.rls.server_target", "grpc.lb.rls.data_plane_target", "grpc.lb.pick_result"},
101101
Default: false,
102102
})
103103
targetPicksMetric = estats.RegisterInt64Count(estats.MetricDescriptor{
104104
Name: "grpc.lb.rls.target_picks",
105105
Description: "EXPERIMENTAL. Number of LB picks sent to each RLS target. Note that if the default target is also returned by the RLS server, RPCs sent to that target from the cache will be counted in this metric, not in grpc.rls.default_target_picks.",
106-
Unit: "pick",
106+
Unit: "{pick}",
107107
Labels: []string{"grpc.target", "grpc.lb.rls.server_target", "grpc.lb.rls.data_plane_target", "grpc.lb.pick_result"},
108108
Default: false,
109109
})
110110
failedPicksMetric = estats.RegisterInt64Count(estats.MetricDescriptor{
111111
Name: "grpc.lb.rls.failed_picks",
112112
Description: "EXPERIMENTAL. Number of LB picks failed due to either a failed RLS request or the RLS channel being throttled.",
113-
Unit: "pick",
113+
Unit: "{pick}",
114114
Labels: []string{"grpc.target", "grpc.lb.rls.server_target"},
115115
Default: false,
116116
})

balancer/rls/metrics_test.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ func (s) TestRLSTargetPickMetric(t *testing.T) {
9090
{
9191
Name: "grpc.lb.rls.target_picks",
9292
Description: "EXPERIMENTAL. Number of LB picks sent to each RLS target. Note that if the default target is also returned by the RLS server, RPCs sent to that target from the cache will be counted in this metric, not in grpc.rls.default_target_picks.",
93-
Unit: "pick",
93+
Unit: "{pick}",
9494
Data: metricdata.Sum[int64]{
9595
DataPoints: []metricdata.DataPoint[int64]{
9696
{
@@ -107,7 +107,7 @@ func (s) TestRLSTargetPickMetric(t *testing.T) {
107107
{
108108
Name: "grpc.lb.rls.cache_entries",
109109
Description: "EXPERIMENTAL. Number of entries in the RLS cache.",
110-
Unit: "entry",
110+
Unit: "{entry}",
111111
Data: metricdata.Gauge[int64]{
112112
DataPoints: []metricdata.DataPoint[int64]{
113113
{
@@ -201,7 +201,7 @@ func (s) TestRLSDefaultTargetPickMetric(t *testing.T) {
201201
{
202202
Name: "grpc.lb.rls.default_target_picks",
203203
Description: "EXPERIMENTAL. Number of LB picks sent to the default target.",
204-
Unit: "pick",
204+
Unit: "{pick}",
205205
Data: metricdata.Sum[int64]{
206206
DataPoints: []metricdata.DataPoint[int64]{
207207
{
@@ -218,7 +218,7 @@ func (s) TestRLSDefaultTargetPickMetric(t *testing.T) {
218218
{
219219
Name: "grpc.lb.rls.cache_entries",
220220
Description: "EXPERIMENTAL. Number of entries in the RLS cache.",
221-
Unit: "entry",
221+
Unit: "{entry}",
222222
Data: metricdata.Gauge[int64]{
223223
DataPoints: []metricdata.DataPoint[int64]{
224224
{
@@ -299,7 +299,7 @@ func (s) TestRLSFailedRPCMetric(t *testing.T) {
299299
{
300300
Name: "grpc.lb.rls.failed_picks",
301301
Description: "EXPERIMENTAL. Number of LB picks failed due to either a failed RLS request or the RLS channel being throttled.",
302-
Unit: "pick",
302+
Unit: "{pick}",
303303
Data: metricdata.Sum[int64]{
304304
DataPoints: []metricdata.DataPoint[int64]{
305305
{
@@ -315,7 +315,7 @@ func (s) TestRLSFailedRPCMetric(t *testing.T) {
315315
{
316316
Name: "grpc.lb.rls.cache_entries",
317317
Description: "EXPERIMENTAL. Number of entries in the RLS cache.",
318-
Unit: "entry",
318+
Unit: "{entry}",
319319
Data: metricdata.Gauge[int64]{
320320
DataPoints: []metricdata.DataPoint[int64]{
321321
{

balancer/weightedroundrobin/balancer.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ var (
6060
rrFallbackMetric = estats.RegisterInt64Count(estats.MetricDescriptor{
6161
Name: "grpc.lb.wrr.rr_fallback",
6262
Description: "EXPERIMENTAL. Number of scheduler updates in which there were not enough endpoints with valid weight, which caused the WRR policy to fall back to RR behavior.",
63-
Unit: "update",
63+
Unit: "{update}",
6464
Labels: []string{"grpc.target"},
6565
OptionalLabels: []string{"grpc.lb.locality"},
6666
Default: false,
@@ -69,7 +69,7 @@ var (
6969
endpointWeightNotYetUsableMetric = estats.RegisterInt64Count(estats.MetricDescriptor{
7070
Name: "grpc.lb.wrr.endpoint_weight_not_yet_usable",
7171
Description: "EXPERIMENTAL. Number of endpoints from each scheduler update that don't yet have usable weight information (i.e., either the load report has not yet been received, or it is within the blackout period).",
72-
Unit: "endpoint",
72+
Unit: "{endpoint}",
7373
Labels: []string{"grpc.target"},
7474
OptionalLabels: []string{"grpc.lb.locality"},
7575
Default: false,
@@ -78,15 +78,15 @@ var (
7878
endpointWeightStaleMetric = estats.RegisterInt64Count(estats.MetricDescriptor{
7979
Name: "grpc.lb.wrr.endpoint_weight_stale",
8080
Description: "EXPERIMENTAL. Number of endpoints from each scheduler update whose latest weight is older than the expiration period.",
81-
Unit: "endpoint",
81+
Unit: "{endpoint}",
8282
Labels: []string{"grpc.target"},
8383
OptionalLabels: []string{"grpc.lb.locality"},
8484
Default: false,
8585
})
8686
endpointWeightsMetric = estats.RegisterFloat64Histo(estats.MetricDescriptor{
8787
Name: "grpc.lb.wrr.endpoint_weights",
8888
Description: "EXPERIMENTAL. Weight of each endpoint, recorded on every scheduler update. Endpoints without usable weights will be recorded as weight 0.",
89-
Unit: "endpoint",
89+
Unit: "{endpoint}",
9090
Labels: []string{"grpc.target"},
9191
OptionalLabels: []string{"grpc.lb.locality"},
9292
Default: false,

experimental/stats/metricregistry_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ func (s) TestPanic(t *testing.T) {
5252
// set by the metric registry.
5353
Name: "simple counter",
5454
Description: "number of times recorded on tests",
55-
Unit: "calls",
55+
Unit: "{call}",
5656
}
5757
RegisterInt64Count(desc)
5858
RegisterInt64Gauge(desc)

stats/opentelemetry/client_metrics.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ func (h *clientMetricsHandler) initializeMetrics() {
5454
metrics = DefaultMetrics()
5555
}
5656

57-
h.clientMetrics.attemptStarted = createInt64Counter(metrics.Metrics(), "grpc.client.attempt.started", meter, otelmetric.WithUnit("attempt"), otelmetric.WithDescription("Number of client call attempts started."))
57+
h.clientMetrics.attemptStarted = createInt64Counter(metrics.Metrics(), "grpc.client.attempt.started", meter, otelmetric.WithUnit("{attempt}"), otelmetric.WithDescription("Number of client call attempts started."))
5858
h.clientMetrics.attemptDuration = createFloat64Histogram(metrics.Metrics(), "grpc.client.attempt.duration", meter, otelmetric.WithUnit("s"), otelmetric.WithDescription("End-to-end time taken to complete a client call attempt."), otelmetric.WithExplicitBucketBoundaries(DefaultLatencyBounds...))
5959
h.clientMetrics.attemptSentTotalCompressedMessageSize = createInt64Histogram(metrics.Metrics(), "grpc.client.attempt.sent_total_compressed_message_size", meter, otelmetric.WithUnit("By"), otelmetric.WithDescription("Compressed message bytes sent per client call attempt."), otelmetric.WithExplicitBucketBoundaries(DefaultSizeBounds...))
6060
h.clientMetrics.attemptRcvdTotalCompressedMessageSize = createInt64Histogram(metrics.Metrics(), "grpc.client.attempt.rcvd_total_compressed_message_size", meter, otelmetric.WithUnit("By"), otelmetric.WithDescription("Compressed message bytes received per call attempt."), otelmetric.WithExplicitBucketBoundaries(DefaultSizeBounds...))

stats/opentelemetry/csm/observability_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -523,7 +523,7 @@ func (s) TestXDSLabels(t *testing.T) {
523523
{
524524
Name: "grpc.client.attempt.started",
525525
Description: "Number of client call attempts started.",
526-
Unit: "attempt",
526+
Unit: "{attempt}",
527527
Data: metricdata.Sum[int64]{
528528
DataPoints: []metricdata.DataPoint[int64]{
529529
{

stats/opentelemetry/e2e_test.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -361,7 +361,7 @@ func (s) TestMethodAttributeFilter(t *testing.T) {
361361
{
362362
Name: "grpc.client.attempt.started",
363363
Description: "Number of client call attempts started.",
364-
Unit: "attempt",
364+
Unit: "{attempt}",
365365
Data: metricdata.Sum[int64]{
366366
DataPoints: []metricdata.DataPoint[int64]{
367367
{
@@ -487,7 +487,7 @@ func (s) TestAllMetricsOneFunction(t *testing.T) {
487487
{
488488
Name: "grpc.client.attempt.started",
489489
Description: "Number of client call attempts started.",
490-
Unit: "attempt",
490+
Unit: "{attempt}",
491491
Data: metricdata.Sum[int64]{
492492
DataPoints: []metricdata.DataPoint[int64]{
493493
{
@@ -510,7 +510,7 @@ func (s) TestAllMetricsOneFunction(t *testing.T) {
510510
{
511511
Name: "grpc.server.call.started",
512512
Description: "Number of server calls started.",
513-
Unit: "call",
513+
Unit: "{call}",
514514
Data: metricdata.Sum[int64]{
515515
DataPoints: []metricdata.DataPoint[int64]{
516516
{
@@ -704,7 +704,7 @@ func (s) TestWRRMetrics(t *testing.T) {
704704
{
705705
Name: "grpc.lb.wrr.rr_fallback",
706706
Description: "EXPERIMENTAL. Number of scheduler updates in which there were not enough endpoints with valid weight, which caused the WRR policy to fall back to RR behavior.",
707-
Unit: "update",
707+
Unit: "{update}",
708708
Data: metricdata.Sum[int64]{
709709
DataPoints: []metricdata.DataPoint[int64]{
710710
{
@@ -720,7 +720,7 @@ func (s) TestWRRMetrics(t *testing.T) {
720720
{
721721
Name: "grpc.lb.wrr.endpoint_weight_not_yet_usable",
722722
Description: "EXPERIMENTAL. Number of endpoints from each scheduler update that don't yet have usable weight information (i.e., either the load report has not yet been received, or it is within the blackout period).",
723-
Unit: "endpoint",
723+
Unit: "{endpoint}",
724724
Data: metricdata.Sum[int64]{
725725
DataPoints: []metricdata.DataPoint[int64]{
726726
{
@@ -735,7 +735,7 @@ func (s) TestWRRMetrics(t *testing.T) {
735735
{
736736
Name: "grpc.lb.wrr.endpoint_weights",
737737
Description: "EXPERIMENTAL. Weight of each endpoint, recorded on every scheduler update. Endpoints without usable weights will be recorded as weight 0.",
738-
Unit: "endpoint",
738+
Unit: "{endpoint}",
739739
Data: metricdata.Histogram[float64]{
740740
DataPoints: []metricdata.HistogramDataPoint[float64]{
741741
{
@@ -757,7 +757,7 @@ func (s) TestWRRMetrics(t *testing.T) {
757757
eventuallyWantMetric := metricdata.Metrics{
758758
Name: "grpc.lb.wrr.endpoint_weight_stale",
759759
Description: "EXPERIMENTAL. Number of endpoints from each scheduler update whose latest weight is older than the expiration period.",
760-
Unit: "endpoint",
760+
Unit: "{endpoint}",
761761
Data: metricdata.Sum[int64]{
762762
DataPoints: []metricdata.DataPoint[int64]{
763763
{

stats/opentelemetry/internal/testutils/testutils.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@ func MetricDataUnary(options MetricDataOptions) []metricdata.Metrics {
181181
{
182182
Name: "grpc.client.attempt.started",
183183
Description: "Number of client call attempts started.",
184-
Unit: "attempt",
184+
Unit: "{attempt}",
185185
Data: metricdata.Sum[int64]{
186186
DataPoints: []metricdata.DataPoint[int64]{
187187
{
@@ -264,7 +264,7 @@ func MetricDataUnary(options MetricDataOptions) []metricdata.Metrics {
264264
{
265265
Name: "grpc.server.call.started",
266266
Description: "Number of server calls started.",
267-
Unit: "call",
267+
Unit: "{call}",
268268
Data: metricdata.Sum[int64]{
269269
DataPoints: []metricdata.DataPoint[int64]{
270270
{
@@ -356,7 +356,7 @@ func MetricDataStreaming(options MetricDataOptions) []metricdata.Metrics {
356356
{
357357
Name: "grpc.client.attempt.started",
358358
Description: "Number of client call attempts started.",
359-
Unit: "attempt",
359+
Unit: "{attempt}",
360360
Data: metricdata.Sum[int64]{
361361
DataPoints: []metricdata.DataPoint[int64]{
362362
{
@@ -439,7 +439,7 @@ func MetricDataStreaming(options MetricDataOptions) []metricdata.Metrics {
439439
{
440440
Name: "grpc.server.call.started",
441441
Description: "Number of server calls started.",
442-
Unit: "call",
442+
Unit: "{call}",
443443
Data: metricdata.Sum[int64]{
444444
DataPoints: []metricdata.DataPoint[int64]{
445445
{
@@ -555,7 +555,7 @@ func MetricData(options MetricDataOptions) []metricdata.Metrics {
555555
{
556556
Name: "grpc.client.attempt.started",
557557
Description: "Number of client call attempts started.",
558-
Unit: "attempt",
558+
Unit: "{attempt}",
559559
Data: metricdata.Sum[int64]{
560560
DataPoints: []metricdata.DataPoint[int64]{
561561
{
@@ -670,7 +670,7 @@ func MetricData(options MetricDataOptions) []metricdata.Metrics {
670670
{
671671
Name: "grpc.server.call.started",
672672
Description: "Number of server calls started.",
673-
Unit: "call",
673+
Unit: "{call}",
674674
Data: metricdata.Sum[int64]{
675675
DataPoints: []metricdata.DataPoint[int64]{
676676
{

0 commit comments

Comments
 (0)