Browse Source

Remove continue with label (#1084)

Instead of continue with label use helper function
Signed-off-by: dmaiocchi <dmaiocchi@suse.com>
pull/1101/head
Dario Maiocchi 6 years ago committed by Julius Volz
parent
commit
01ec8c5c5c
  1. 4
      MAINTAINERS.md
  2. 22
      collector/textfile.go

4
MAINTAINERS.md

@ -1,2 +1,2 @@
* Ben Kochie <superq@gmail.com>
* Johannes 'fish' Ziemke <github@freigeist.org>
* Ben Kochie <superq@gmail.com> @SuperQ
* Johannes 'fish' Ziemke <github@freigeist.org> @discordianfish

22
collector/textfile.go

@ -193,7 +193,6 @@ func (c *textFileCollector) Update(ch chan<- prometheus.Metric) error {
error = 1.0
}
fileLoop:
for _, f := range files {
if !strings.HasSuffix(f.Name(), ".prom") {
continue
@ -213,14 +212,13 @@ fileLoop:
error = 1.0
continue
}
for _, mf := range parsedFamilies {
for _, m := range mf.Metric {
if m.TimestampMs != nil {
if hasTimestamps(parsedFamilies) {
log.Errorf("Textfile %q contains unsupported client-side timestamps, skipping entire file", path)
error = 1.0
continue fileLoop
}
continue
}
for _, mf := range parsedFamilies {
if mf.Help == nil {
help := fmt.Sprintf("Metric read from %s", path)
mf.Help = &help
@ -249,3 +247,15 @@ fileLoop:
)
return nil
}
// hasTimestamps returns true when metrics contain unsupported timestamps.
func hasTimestamps(parsedFamilies map[string]*dto.MetricFamily) bool {
for _, mf := range parsedFamilies {
for _, m := range mf.Metric {
if m.TimestampMs != nil {
return true
}
}
}
return false
}

Loading…
Cancel
Save