Skip to content

Commit

Permalink
Remove continue with label (prometheus#1084)
Browse files Browse the repository at this point in the history
Instead of continue with label use helper function
Signed-off-by: dmaiocchi <[email protected]>
  • Loading branch information
MalloZup authored and juliusv committed Oct 5, 2018
1 parent a1ce712 commit 01ec8c5
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 10 deletions.
4 changes: 2 additions & 2 deletions MAINTAINERS.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
* Ben Kochie <[email protected]>
* Johannes 'fish' Ziemke <[email protected]>
* Ben Kochie <[email protected]> @SuperQ
* Johannes 'fish' Ziemke <[email protected]> @discordianfish
26 changes: 18 additions & 8 deletions collector/textfile.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -213,14 +212,13 @@ fileLoop:
error = 1.0
continue
}
if hasTimestamps(parsedFamilies) {
log.Errorf("Textfile %q contains unsupported client-side timestamps, skipping entire file", path)
error = 1.0
continue
}

for _, mf := range parsedFamilies {
for _, m := range mf.Metric {
if m.TimestampMs != nil {
log.Errorf("Textfile %q contains unsupported client-side timestamps, skipping entire file", path)
error = 1.0
continue fileLoop
}
}
if mf.Help == nil {
help := fmt.Sprintf("Metric read from %s", path)
mf.Help = &help
Expand Down Expand Up @@ -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
}

0 comments on commit 01ec8c5

Please sign in to comment.