Skip to content

Conversation

@AlekSi
Copy link

@AlekSi AlekSi commented Dec 3, 2019

No description provided.


// makePrometheusMetrics returns all Prometheus metrics for given osMetrics.
func (m *osMetrics) makePrometheusMetrics(region string) []prometheus.Metric {
func (m *osMetrics) makePrometheusMetrics(region string, labels map[string]string) []prometheus.Metric {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function 'makePrometheusMetrics' has too many statements (44 > 40) (from funlen)

"instance": m.InstanceID,
"region": region,
}
for n, v := range labels {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ranges should only be cuddled with assignments used in the iteration (from wsl)

AWSSecretKey string `yaml:"aws_secret_key"` // may be empty
Labels map[string]string `yaml:"labels"` // may be empty

// TODO Type InstanceType `yaml:"type"` // may be empty for old pmm-managed

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

config/config.go:27: Line contains TODO/BUG/FIXME: "TODO Type InstanceType yaml:"type" // ..." (from godox)

)

func getExporter(t *testing.T) *Exporter {
func getCollector(t *testing.T) *Collector {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

func getCollector is unused (from unused)

}

type Exporter struct {
type Collector struct {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

exported type Collector should have comment or be unexported (from golint)

}

func (e *Exporter) Collect(ch chan<- prometheus.Metric) {
func (e *Collector) Describe(ch chan<- *prometheus.Desc) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

exported method Collector.Describe should have comment or be unexported (from golint)

// unchecked collector
}

func (e *Collector) Collect(ch chan<- prometheus.Metric) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

exported method Collector.Collect should have comment or be unexported (from golint)

}

func NewScraper(instance *config.Instance, exporter *Exporter, ch chan<- prometheus.Metric) *Scraper {
func NewScraper(instance *config.Instance, collector *Collector, ch chan<- prometheus.Metric) *Scraper {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

exported function NewScraper should have comment or be unexported (from golint)

wg.Add(len(instances))
for _, instance := range instances {
wg.Add(len(e.config.Instances))
for _, instance := range e.config.Instances {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ranges should only be cuddled with assignments used in the iteration (from wsl)

"region": instance.Region,
"instance": instance.Instance,
}
for n, v := range instance.Labels {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ranges should only be cuddled with assignments used in the iteration (from wsl)

wg.Add(len(s.collector.metrics))
for _, metric := range s.collector.metrics {
metric := metric
go func() {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

go statements can only invoke functions assigned on line above (from wsl)

// Get the metric.
v := aws.Float64Value(dp.Average)
switch metric.Name {
switch metric.cwName {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

switch statements should only be cuddled with variables switched (from wsl)

@AlekSi AlekSi marked this pull request as ready for review December 3, 2019 07:27
@AlekSi AlekSi requested a review from BupycHuk December 3, 2019 07:27
@AlekSi AlekSi self-assigned this Dec 3, 2019
Copy link
Member

@BupycHuk BupycHuk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tests are failing.
Let's add labels to readme.

labels := []string{
instance.Instance,
instance.Region,
constLabels := prometheus.Labels{
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

constLabels? What's the difference?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Constant labels are part of the metric's description; variable labels are not. The distinction is important for checked Collectors, but we switched to unchecked in this PR. Some more info: https://godoc.org/github.com/prometheus/client_golang/prometheus#hdr-Custom_Collectors_and_constant_Metrics

@AlekSi
Copy link
Author

AlekSi commented Dec 3, 2019

Tests are failing.

Due to https://jira.percona.com/browse/PMM-1772. Nothing we can do right now.

BupycHuk
BupycHuk previously approved these changes Dec 3, 2019
Copy link
Member

@BupycHuk BupycHuk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's update readme and merge.

s.exporter.l.With("metric", metric.Name).Error(err)
}
wg.Add(len(s.collector.metrics))
for _, metric := range s.collector.metrics {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ranges should only be cuddled with assignments used in the iteration (from wsl)

@AlekSi AlekSi merged commit 80355c9 into master Dec 4, 2019
@AlekSi AlekSi deleted the PMM-4474-extra-labels branch December 4, 2019 12:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants