-
Notifications
You must be signed in to change notification settings - Fork 88
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
PMM-1901 Metrics endpoint and collectors filtering. #40
Changes from all commits
6255119
ef6e472
1abd364
50e61e4
c17fe8d
834396b
a907a9d
39ed8c3
9016759
57f1f36
0f01209
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 |
---|---|---|
|
@@ -13,19 +13,36 @@ import ( | |
"github.com/percona/rds_exporter/sessions" | ||
) | ||
|
||
func getExporter(t *testing.T) *Exporter { | ||
func getExporter(t *testing.T, enableMetrics OverlappingMetrics) *Exporter { | ||
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. func |
||
t.Helper() | ||
|
||
cfg, err := config.Load("../config.yml") | ||
require.NoError(t, err) | ||
client := client.New() | ||
sess, err := sessions.New(cfg.Instances, client.HTTP(), false) | ||
require.NoError(t, err) | ||
return New(cfg, sess) | ||
return New(cfg, sess, enableMetrics) | ||
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. return statements should not be cuddled if block has more than two lines (from |
||
} | ||
|
||
func TestCollector_Describe(t *testing.T) { | ||
c := getExporter(t) | ||
c := getExporter(t, DisableOverlapping) | ||
ch := make(chan *prometheus.Desc) | ||
go func() { | ||
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. only one cuddle assignment allowed before go statement (from |
||
c.Describe(ch) | ||
close(ch) | ||
}() | ||
|
||
const expected = 47 | ||
descs := make([]*prometheus.Desc, 0, expected) | ||
for d := range ch { | ||
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. only one cuddle assignment allowed before range statement (from |
||
descs = append(descs, d) | ||
} | ||
|
||
assert.Equal(t, expected, len(descs), "%+v", descs) | ||
} | ||
|
||
func TestCollector_Describe_WithOverlappingMetrics(t *testing.T) { | ||
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. func |
||
c := getExporter(t, EnableOverlapping) | ||
ch := make(chan *prometheus.Desc) | ||
go func() { | ||
c.Describe(ch) | ||
|
@@ -42,7 +59,24 @@ func TestCollector_Describe(t *testing.T) { | |
} | ||
|
||
func TestCollector_Collect(t *testing.T) { | ||
c := getExporter(t) | ||
c := getExporter(t, DisableOverlapping) | ||
ch := make(chan prometheus.Metric) | ||
go func() { | ||
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. only one cuddle assignment allowed before go statement (from |
||
c.Collect(ch) | ||
close(ch) | ||
}() | ||
|
||
const expected = 91 | ||
metrics := make([]helpers.Metric, 0, expected) | ||
for m := range ch { | ||
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. only one cuddle assignment allowed before range statement (from |
||
metrics = append(metrics, *helpers.ReadMetric(m)) | ||
} | ||
|
||
assert.Equal(t, expected, len(metrics), "%+v", metrics) | ||
} | ||
|
||
func TestCollector_Collect_WithOverlappingMetrics(t *testing.T) { | ||
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. func |
||
c := getExporter(t, EnableOverlapping) | ||
ch := make(chan prometheus.Metric) | ||
go func() { | ||
c.Collect(ch) | ||
|
This file was deleted.
This file was deleted.
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.
only one cuddle assignment allowed before if statement (from
wsl
)