Empty collection should return success=0 (#1323, #1723)

Signed-off-by: Li Ling <liiling@google.com>
pull/1816/head
Li Ling 4 years ago
parent 3b035c8fa1
commit f0332993ef

@ -89,7 +89,7 @@ func (c *pressureStatsCollector) Update(ch chan<- prometheus.Metric) error {
vals, err := c.fs.PSIStatsForResource(res) vals, err := c.fs.PSIStatsForResource(res)
if err != nil { if err != nil {
level.Debug(c.logger).Log("msg", "pressure information is unavailable, you need a Linux kernel >= 4.20 and/or CONFIG_PSI enabled for your kernel") level.Debug(c.logger).Log("msg", "pressure information is unavailable, you need a Linux kernel >= 4.20 and/or CONFIG_PSI enabled for your kernel")
return nil return ErrNoData
} }
switch res { switch res {
case "cpu": case "cpu":

@ -50,7 +50,7 @@ func (c *raplCollector) Update(ch chan<- prometheus.Metric) error {
// nil zones are fine when platform doesn't have powercap files present. // nil zones are fine when platform doesn't have powercap files present.
zones, err := sysfs.GetRaplZones(c.fs) zones, err := sysfs.GetRaplZones(c.fs)
if err != nil { if err != nil {
return nil return ErrNoData
} }
for _, rz := range zones { for _, rz := range zones {

@ -65,6 +65,14 @@ func NewZFSCollector(logger log.Logger) (Collector, error) {
} }
func (c *zfsCollector) Update(ch chan<- prometheus.Metric) error { func (c *zfsCollector) Update(ch chan<- prometheus.Metric) error {
if _, err := c.openProcFile(c.linuxProcpathBase); err != nil {
if err == errZFSNotAvailable {
level.Debug(c.logger).Log("err", err)
return ErrNoData
}
}
for subsystem := range c.linuxPathMap { for subsystem := range c.linuxPathMap {
if err := c.updateZfsStats(subsystem, ch); err != nil { if err := c.updateZfsStats(subsystem, ch); err != nil {
if err == errZFSNotAvailable { if err == errZFSNotAvailable {

Loading…
Cancel
Save