-
Notifications
You must be signed in to change notification settings - Fork 4.4k
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
xds: emit a labeled gauge of connected xDS streams by version #10243
Changes from 2 commits
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 |
---|---|---|
@@ -0,0 +1,3 @@ | ||
```release-note:feature | ||
xds: emit a labeled gauge of connected xDS streams by version | ||
``` |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,6 +19,7 @@ import ( | |
envoy_discovery_v3 "github.com/envoyproxy/go-control-plane/envoy/service/discovery/v3" | ||
envoy_type_v3 "github.com/envoyproxy/go-control-plane/envoy/type/v3" | ||
|
||
"github.com/armon/go-metrics" | ||
"github.com/golang/protobuf/proto" | ||
"github.com/golang/protobuf/ptypes" | ||
"github.com/golang/protobuf/ptypes/wrappers" | ||
|
@@ -118,6 +119,7 @@ type testServerScenario struct { | |
server *Server | ||
mgr *testManager | ||
envoy *TestEnvoy | ||
sink *metrics.InmemSink | ||
errCh <-chan error | ||
} | ||
|
||
|
@@ -155,6 +157,16 @@ func newTestServerScenarioInner( | |
envoy.Close() | ||
}) | ||
|
||
sink := metrics.NewInmemSink(1*time.Minute, 1*time.Minute) | ||
cfg := metrics.DefaultConfig("consul.xds.test") | ||
cfg.EnableHostname = false | ||
rboyer marked this conversation as resolved.
Show resolved
Hide resolved
|
||
metrics.NewGlobal(cfg, sink) | ||
|
||
t.Cleanup(func() { | ||
sink := &metrics.BlackholeSink{} | ||
metrics.NewGlobal(cfg, sink) | ||
}) | ||
|
||
s := NewServer( | ||
testutil.Logger(t), | ||
mgr, | ||
|
@@ -178,6 +190,7 @@ func newTestServerScenarioInner( | |
server: s, | ||
mgr: mgr, | ||
envoy: envoy, | ||
sink: sink, | ||
errCh: errCh, | ||
} | ||
} | ||
|
@@ -647,3 +660,23 @@ func runStep(t *testing.T, name string, fn func(t *testing.T)) { | |
t.FailNow() | ||
} | ||
} | ||
|
||
func requireProtocolVersionGauge( | ||
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. Do you expect that we will call this from other places? Right now it's only called from one place so it might be good to keep it next to the one call site. 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. It's called in two places: |
||
t *testing.T, | ||
scenario *testServerScenario, | ||
xdsVersion string, | ||
expected int, | ||
) { | ||
data := scenario.sink.Data() | ||
require.Len(t, data, 1) | ||
|
||
item := data[0] | ||
require.Len(t, item.Gauges, 1) | ||
|
||
val, ok := item.Gauges["consul.xds.test.xds.server.streams;version="+xdsVersion] | ||
require.True(t, ok) | ||
|
||
require.Equal(t, "consul.xds.test.xds.server.streams", val.Name) | ||
require.Equal(t, expected, int(val.Value)) | ||
require.Equal(t, []metrics.Label{{Name: "version", Value: xdsVersion}}, val.Labels) | ||
} |
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.
Am I correct in assuming that there can only be one Server instance per host? Do we run multiple servers on different ports or anything like that?
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.
There is exactly one xDS server per consul agent.