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

Signed-off-by: Li Ling <liiling@google.com>
This commit is contained in:
Li Ling 2020-08-20 14:09:55 +02:00
parent 3b035c8fa1
commit f0332993ef
3 changed files with 10 additions and 2 deletions

View File

@ -89,7 +89,7 @@ func (c *pressureStatsCollector) Update(ch chan<- prometheus.Metric) error {
vals, err := c.fs.PSIStatsForResource(res)
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")
return nil
return ErrNoData
}
switch res {
case "cpu":

View File

@ -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.
zones, err := sysfs.GetRaplZones(c.fs)
if err != nil {
return nil
return ErrNoData
}
for _, rz := range zones {

View File

@ -65,6 +65,14 @@ func NewZFSCollector(logger log.Logger) (Collector, 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 {
if err := c.updateZfsStats(subsystem, ch); err != nil {
if err == errZFSNotAvailable {