-
Notifications
You must be signed in to change notification settings - Fork 2.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
Convert remaining collectors to use ConstMetrics #389
Conversation
c.metric.Set(now) | ||
c.metric.Collect(ch) | ||
return err | ||
ch <- prometheus.MustNewConstMetric(c.desc, prometheus.CounterValue, 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.
Gauge
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.
It was a counter before.. But yeah I remember we discussed that timestamps should be gauges. Will change.
}, nil | ||
} | ||
|
||
func (c *timeCollector) Update(ch chan<- prometheus.Metric) (err error) { | ||
func (c *timeCollector) Update(ch chan<- prometheus.Metric) error { | ||
now := float64(time.Now().Unix()) | ||
log.Debugf("Set time: %f", 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.
Needs updating
@@ -61,8 +49,7 @@ func (c *loadavgCollector) Update(ch chan<- prometheus.Metric) (err error) { | |||
} | |||
for i, load := range loads { | |||
log.Debugf("Set load %d: %f", i, load) |
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.
Needs updating
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.
What needs updating? You want me to remove that debug line?
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.
It's no longer "Set"
} | ||
} | ||
/* |
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 should go
prometheus.NewDesc("node_ipvs_backend_weight", "The current backend weight by local and remote address.", []string{"local_address", "local_port", "remote_address", "remote_port", "proto"}, nil).String(): (<-sink).Desc().String(), | ||
} { | ||
if expected != got { | ||
log.Fatalf("Expected '%s' but got '%s'", expected, got) |
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 should be using t
rather than log
@@ -40,7 +40,7 @@ var ( | |||
|
|||
type diskstatsCollector struct { | |||
ignoredDevicesPattern *regexp.Regexp | |||
metrics []prometheus.Collector | |||
metrics []typedDesc |
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.
descs
would be clearer
cf6dcc3
to
5bbfa65
Compare
Amazing work! 👏 |
@brian-brazil Fixed your comments |
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.
Awesome
5bbfa65
to
8e50b80
Compare
I didn't touch the gmond and megacli collectors since we'll remove them soon anyway.
I also kept devError a regular metric because that seemed appropriate to me since it's about counting all errors that happened in the exporter, not gathering some external state where ConstMetrics should be used.
Closes #240