-
Couldn't load subscription status.
- Fork 87
PMM-4474 Add extra labels. #32
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
Conversation
|
|
||
| // 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 { |
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.
Function 'makePrometheusMetrics' has too many statements (44 > 40) (from funlen)
| "instance": m.InstanceID, | ||
| "region": region, | ||
| } | ||
| for n, v := range 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.
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 |
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.
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 { |
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.
func getCollector is unused (from unused)
| } | ||
|
|
||
| type Exporter struct { | ||
| type Collector struct { |
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.
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) { |
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.
exported method Collector.Describe should have comment or be unexported (from golint)
| // unchecked collector | ||
| } | ||
|
|
||
| func (e *Collector) Collect(ch chan<- prometheus.Metric) { |
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.
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 { |
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.
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 { |
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.
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 { |
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.
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() { |
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.
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 { |
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.
switch statements should only be cuddled with variables switched (from wsl)
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.
Tests are failing.
Let's add labels to readme.
| labels := []string{ | ||
| instance.Instance, | ||
| instance.Region, | ||
| constLabels := prometheus.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.
constLabels? What's the difference?
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.
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
Due to https://jira.percona.com/browse/PMM-1772. Nothing we can do right now. |
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.
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 { |
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.
ranges should only be cuddled with assignments used in the iteration (from wsl)
No description provided.