-
Notifications
You must be signed in to change notification settings - Fork 4.7k
balancer: remove grpc.lb.pick_first.* metrics #9215
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from 3 commits
643ead2
cbb45a2
ebca066
5fb5a92
45070d4
b5627a3
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -62,9 +62,8 @@ func init() { | |
| }`, pickfirst.Name) | ||
| } | ||
|
|
||
| // TestPickFirstMetrics tests pick first metrics. It configures a pick first | ||
| // balancer, causes it to connect and then disconnect, and expects the | ||
| // subsequent metrics to emit from that. | ||
| // TestPickFirstMetrics verifies that a pick_first channel emits the correct | ||
| // subchannel metrics on connect and disconnect. | ||
| func (s) TestPickFirstMetrics(t *testing.T) { | ||
| ctx, cancel := context.WithTimeout(context.Background(), defaultTestTimeout) | ||
| defer cancel() | ||
|
|
@@ -97,17 +96,6 @@ func (s) TestPickFirstMetrics(t *testing.T) { | |
| t.Fatalf("EmptyCall() failed: %v", err) | ||
| } | ||
|
|
||
| if got, _ := tmr.Metric("grpc.lb.pick_first.connection_attempts_succeeded"); got != 1 { | ||
| t.Errorf("Unexpected data for metric %v, got: %v, want: %v", "grpc.lb.pick_first.connection_attempts_succeeded", got, 1) | ||
| } | ||
| if got, _ := tmr.Metric("grpc.lb.pick_first.connection_attempts_failed"); got != 0 { | ||
| t.Errorf("Unexpected data for metric %v, got: %v, want: %v", "grpc.lb.pick_first.connection_attempts_failed", got, 0) | ||
| } | ||
| if got, _ := tmr.Metric("grpc.lb.pick_first.disconnections"); got != 0 { | ||
| t.Errorf("Unexpected data for metric %v, got: %v, want: %v", "grpc.lb.pick_first.disconnections", got, 0) | ||
| } | ||
|
|
||
| // Checking for subchannel metrics as well | ||
| if got, _ := tmr.Metric("grpc.subchannel.connection_attempts_succeeded"); got != 1 { | ||
| t.Errorf("Unexpected data for metric %v, got: %v, want: %v", "grpc.subchannel.connection_attempts_succeeded", got, 1) | ||
| } | ||
|
|
@@ -123,9 +111,6 @@ func (s) TestPickFirstMetrics(t *testing.T) { | |
|
|
||
| ss.Stop() | ||
| testutils.AwaitState(ctx, t, cc, connectivity.Idle) | ||
| if got, _ := tmr.Metric("grpc.lb.pick_first.disconnections"); got != 1 { | ||
| t.Errorf("Unexpected data for metric %v, got: %v, want: %v", "grpc.lb.pick_first.disconnections", got, 1) | ||
| } | ||
| if got, _ := tmr.Metric("grpc.subchannel.disconnections"); got != 1 { | ||
| t.Errorf("Unexpected data for metric %v, got: %v, want: %v", "grpc.subchannel.disconnections", got, 1) | ||
| } | ||
|
|
@@ -161,20 +146,19 @@ func (s) TestPickFirstMetricsFailure(t *testing.T) { | |
| t.Fatalf("EmptyCall() passed when expected to fail") | ||
| } | ||
|
|
||
| if got, _ := tmr.Metric("grpc.lb.pick_first.connection_attempts_succeeded"); got != 0 { | ||
| t.Errorf("Unexpected data for metric %v, got: %v, want: %v", "grpc.lb.pick_first.connection_attempts_succeeded", got, 0) | ||
| if got, _ := tmr.Metric("grpc.subchannel.connection_attempts_succeeded"); got != 0 { | ||
| t.Errorf("Unexpected data for metric %v, got: %v, want: %v", "grpc.subchannel.connection_attempts_succeeded", got, 0) | ||
| } | ||
| if got, _ := tmr.Metric("grpc.lb.pick_first.connection_attempts_failed"); got != 1 { | ||
| t.Errorf("Unexpected data for metric %v, got: %v, want: %v", "grpc.lb.pick_first.connection_attempts_failed", got, 1) | ||
| if got, _ := tmr.Metric("grpc.subchannel.connection_attempts_failed"); got != 1 { | ||
| t.Errorf("Unexpected data for metric %v, got: %v, want: %v", "grpc.subchannel.connection_attempts_failed", got, 1) | ||
| } | ||
| if got, _ := tmr.Metric("grpc.lb.pick_first.disconnections"); got != 0 { | ||
| t.Errorf("Unexpected data for metric %v, got: %v, want: %v", "grpc.lb.pick_first.disconnections", got, 0) | ||
| if got, _ := tmr.Metric("grpc.subchannel.disconnections"); got != 0 { | ||
| t.Errorf("Unexpected data for metric %v, got: %v, want: %v", "grpc.subchannel.disconnections", got, 0) | ||
| } | ||
| } | ||
|
|
||
| // TestPickFirstMetricsE2E tests the pick first metrics end to end. It | ||
| // configures a channel with an OpenTelemetry plugin, induces all 3 pick first | ||
| // metrics to emit, and makes sure the correct OpenTelemetry metrics atoms emit. | ||
| // TestPickFirstMetricsE2E tests subchannel metrics emitted during a pickfirst | ||
| // connection lifecycle: failure, success, and disconnection. | ||
| func (s) TestPickFirstMetricsE2E(t *testing.T) { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @mbissa : I don't quite understand why this test uses the OTel stats handler while the other tests in this file seem to use a test stats handler? Should we consider unifying these tests to use a consistent approach? Or is there value in doing what is being currently done?
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is the only test that runs E2E and hence using actual Otel plugin. The test stats handler ones are more geared towards checking the label value plumbing rather than the actual metric value. We could in new tests have unified tests - certainly clean it up. |
||
| ctx, cancel := context.WithTimeout(context.Background(), defaultTestTimeout) | ||
| defer cancel() | ||
|
|
@@ -199,7 +183,7 @@ func (s) TestPickFirstMetricsE2E(t *testing.T) { | |
| provider := metric.NewMeterProvider(metric.WithReader(reader)) | ||
| mo := opentelemetry.MetricsOptions{ | ||
| MeterProvider: provider, | ||
| Metrics: opentelemetry.DefaultMetrics().Add("grpc.lb.pick_first.disconnections", "grpc.lb.pick_first.connection_attempts_succeeded", "grpc.lb.pick_first.connection_attempts_failed"), | ||
| Metrics: opentelemetry.DefaultMetrics().Add("grpc.subchannel.disconnections", "grpc.subchannel.connection_attempts_succeeded", "grpc.subchannel.connection_attempts_failed"), | ||
| } | ||
|
|
||
| cc, err := grpc.NewClient(grpcTarget, opentelemetry.DialOption(opentelemetry.Options{MetricsOptions: mo}), grpc.WithTransportCredentials(insecure.NewCredentials()), grpc.WithResolvers(r)) | ||
|
|
@@ -227,7 +211,7 @@ func (s) TestPickFirstMetricsE2E(t *testing.T) { | |
| testutils.AwaitState(ctx, t, cc, connectivity.Idle) | ||
| wantMetrics := []metricdata.Metrics{ | ||
| { | ||
| Name: "grpc.lb.pick_first.connection_attempts_succeeded", | ||
| Name: "grpc.subchannel.connection_attempts_succeeded", | ||
| Description: "EXPERIMENTAL. Number of successful connection attempts.", | ||
| Unit: "{attempt}", | ||
| Data: metricdata.Sum[int64]{ | ||
|
|
@@ -242,7 +226,7 @@ func (s) TestPickFirstMetricsE2E(t *testing.T) { | |
| }, | ||
| }, | ||
| { | ||
| Name: "grpc.lb.pick_first.connection_attempts_failed", | ||
| Name: "grpc.subchannel.connection_attempts_failed", | ||
| Description: "EXPERIMENTAL. Number of failed connection attempts.", | ||
| Unit: "{attempt}", | ||
| Data: metricdata.Sum[int64]{ | ||
|
|
@@ -257,7 +241,7 @@ func (s) TestPickFirstMetricsE2E(t *testing.T) { | |
| }, | ||
| }, | ||
| { | ||
| Name: "grpc.lb.pick_first.disconnections", | ||
| Name: "grpc.subchannel.disconnections", | ||
| Description: "EXPERIMENTAL. Number of times the selected subchannel becomes disconnected.", | ||
| Unit: "{disconnection}", | ||
| Data: metricdata.Sum[int64]{ | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2009,20 +2009,11 @@ func (s) TestPickFirstLeaf_HappyEyeballs_TF_AfterEndOfList(t *testing.T) { | |
| waitForMetric(ctx, t, tmr, "grpc.subchannel.connection_attempts_failed") | ||
|
|
||
| // Only connection attempt fails in this test. | ||
| if got, _ := tmr.Metric("grpc.lb.pick_first.connection_attempts_succeeded"); got != 0 { | ||
| t.Errorf("Unexpected data for metric %v, got: %v, want: %v", "grpc.lb.pick_first.connection_attempts_succeeded", got, 0) | ||
| } | ||
| if got, _ := tmr.Metric("grpc.lb.pick_first.connection_attempts_failed"); got != 1 { | ||
| t.Errorf("Unexpected data for metric %v, got: %v, want: %v", "grpc.lb.pick_first.connection_attempts_failed", got, 1) | ||
| } | ||
| if got, _ := tmr.Metric("grpc.lb.pick_first.disconnections"); got != 0 { | ||
| t.Errorf("Unexpected data for metric %v, got: %v, want: %v", "grpc.lb.pick_first.disconnections", got, 0) | ||
| } | ||
| if got, _ := tmr.Metric("grpc.subchannel.connection_attempts_failed"); got != 1 { | ||
| t.Errorf("Unexpected data for metric %v, got: %v, want: %v", "grpc.subchannel.connection_attempts_failed", got, 1) | ||
| } | ||
| if got, _ := tmr.Metric("grpc.lb.subchannel.connection_attempts_succeeded"); got != 0 { | ||
| t.Errorf("Unexpected data for metric %v, got: %v, want: %v", "grpc.lb.subchannel.connection_attempts_succeeded", got, 0) | ||
|
Comment on lines
-2024
to
-2025
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Interesting. Was this broken all this while then, @mbissa ?
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes. looks like it. I think when tmr.Metric is queried with the typo'd name, it does not find any recorded values, returning (0, false). Since the test code only checked got (which defaults to 0 when not found) and asserted got != 0, the condition 0 != 0 evaluated to false, and the test incorrectly passed instead of failing. |
||
| if got, _ := tmr.Metric("grpc.subchannel.connection_attempts_succeeded"); got != 0 { | ||
| t.Errorf("Unexpected data for metric %v, got: %v, want: %v", "grpc.subchannel.connection_attempts_succeeded", got, 0) | ||
| } | ||
| } | ||
|
|
||
|
|
@@ -2075,16 +2066,6 @@ func (s) TestPickFirstLeaf_HappyEyeballs_TriggerConnectionDelay(t *testing.T) { | |
| testutils.AwaitState(ctx, t, cc, connectivity.Ready) | ||
| waitForMetric(ctx, t, tmr, "grpc.subchannel.connection_attempts_succeeded") | ||
| // Only connection attempt successes in this test. | ||
| if got, _ := tmr.Metric("grpc.lb.pick_first.connection_attempts_succeeded"); got != 1 { | ||
| t.Errorf("Unexpected data for metric %v, got: %v, want: %v", "grpc.lb.pick_first.connection_attempts_succeeded", got, 1) | ||
| } | ||
| if got, _ := tmr.Metric("grpc.lb.pick_first.connection_attempts_failed"); got != 0 { | ||
| t.Errorf("Unexpected data for metric %v, got: %v, want: %v", "grpc.lb.pick_first.connection_attempts_failed", got, 0) | ||
| } | ||
| if got, _ := tmr.Metric("grpc.lb.pick_first.disconnections"); got != 0 { | ||
| t.Errorf("Unexpected data for metric %v, got: %v, want: %v", "grpc.lb.pick_first.disconnections", got, 0) | ||
| } | ||
|
|
||
| if got, _ := tmr.Metric("grpc.subchannel.connection_attempts_succeeded"); got != 1 { | ||
| t.Errorf("Unexpected data for metric %v, got: %v, want: %v", "grpc.subchannel.connection_attempts_succeeded", got, 1) | ||
| } | ||
|
|
@@ -2153,9 +2134,6 @@ func (s) TestPickFirstLeaf_HappyEyeballs_TF_ThenTimerFires(t *testing.T) { | |
| if holds[1].Wait(ctx) != true { | ||
| t.Fatalf("Timeout waiting for server %d with address %q to be contacted", 1, addrs[1]) | ||
| } | ||
| if got, _ := tmr.Metric("grpc.lb.pick_first.connection_attempts_failed"); got != 1 { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @mbissa : For all of these removed lines, what was the original plan? Would the pick_first tests continue to track the subchannel metrics or did we plan to have other tests that would track with these metrics?
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The plan was to move the tests to different place which is more apt for subchannel and not keep them in pickfirst. |
||
| t.Errorf("Unexpected data for metric %v, got: %v, want: %v", "grpc.lb.pick_first.connection_attempts_failed", got, 1) | ||
| } | ||
| if got, _ := tmr.Metric("grpc.subchannel.connection_attempts_failed"); got != 1 { | ||
| t.Errorf("Unexpected data for metric %v, got: %v, want: %v", "grpc.subchannel.connection_attempts_failed", got, 1) | ||
| } | ||
|
|
@@ -2179,11 +2157,8 @@ func (s) TestPickFirstLeaf_HappyEyeballs_TF_ThenTimerFires(t *testing.T) { | |
| if got, _ := tmr.Metric("grpc.subchannel.connection_attempts_succeeded"); got != 1 { | ||
| t.Errorf("Unexpected data for metric %v, got: %v, want: %v", "grpc.subchannel.connection_attempts_succeeded", got, 1) | ||
| } | ||
| if got, _ := tmr.Metric("grpc.lb.pick_first.connection_attempts_succeeded"); got != 1 { | ||
| t.Errorf("Unexpected data for metric %v, got: %v, want: %v", "grpc.lb.pick_first.connection_attempts_succeeded", got, 1) | ||
| } | ||
| if got, _ := tmr.Metric("grpc.lb.pick_first.disconnections"); got != 0 { | ||
| t.Errorf("Unexpected data for metric %v, got: %v, want: %v", "grpc.lb.pick_first.disconnections", got, 0) | ||
| if got, _ := tmr.Metric("grpc.subchannel.disconnections"); got != 0 { | ||
| t.Errorf("Unexpected data for metric %v, got: %v, want: %v", "grpc.subchannel.disconnections", got, 0) | ||
| } | ||
| } | ||
|
|
||
|
|
@@ -2256,13 +2231,6 @@ func (s) TestPickFirstLeaf_HappyEyeballs_Ignore_Inflight_Cancellations(t *testin | |
| } | ||
| } | ||
|
|
||
| // LB Metrics Check | ||
| if got, _ := tmr.Metric("grpc.lb.pick_first.connection_attempts_succeeded"); got != 1 { | ||
| t.Errorf("Unexpected data for metric %v, got: %v, want: 1", "grpc.lb.pick_first.connection_attempts_succeeded", got) | ||
| } | ||
| if got, _ := tmr.Metric("grpc.lb.pick_first.connection_attempts_failed"); got != 0 { | ||
| t.Errorf("Unexpected data for metric %v, got: %v, want: 0", "grpc.lb.pick_first.connection_attempts_failed", got) | ||
| } | ||
| } | ||
|
|
||
| func (s) TestPickFirstLeaf_InterleavingIPV4Preferred(t *testing.T) { | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -73,14 +73,6 @@ func main() { | |
| so := opentelemetry.ServerOption(opentelemetry.Options{ | ||
| MetricsOptions: opentelemetry.MetricsOptions{ | ||
| MeterProvider: meterProvider, | ||
| // These are example experimental gRPC metrics, which are disabled | ||
| // by default and must be explicitly enabled. For the full, | ||
| // up-to-date list of metrics, see: | ||
| // https://grpc.io/docs/guides/opentelemetry-metrics/#instruments | ||
| Metrics: opentelemetry.DefaultMetrics().Add( | ||
| "grpc.lb.pick_first.connection_attempts_succeeded", | ||
| "grpc.lb.pick_first.connection_attempts_failed", | ||
| ), | ||
|
Comment on lines
-76
to
-83
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why is this different to the change in
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The |
||
| }, | ||
| TraceOptions: oteltracing.TraceOptions{TracerProvider: traceProvider, TextMapPropagator: textMapPropagator}}) | ||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: "a pick_first channel" is very confusing. What we probably want is "a gRPC channel configured with the pick_first LB policy".
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is no longer applicable after the test move.
TestPickFirstMetricswas removed, and the OTel coverage now lives instats/opentelemetry/e2e_test.go.