aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDario Maiocchi <MalloZup@users.noreply.github.com>2018-10-05 13:20:30 +0200
committerJulius Volz <julius.volz@gmail.com>2018-10-05 13:20:30 +0200
commit01ec8c5c5c3636a52d6f9e7c6f6cebaeb9f07af4 (patch)
tree806ae0759657b9224ae7fcd83504d5257c879194
parenta1ce712e22d88667ab11ca88a2cec092bcdba6d3 (diff)
downloadprometheus_node_collector-01ec8c5c5c3636a52d6f9e7c6f6cebaeb9f07af4.tar.bz2
prometheus_node_collector-01ec8c5c5c3636a52d6f9e7c6f6cebaeb9f07af4.tar.xz
prometheus_node_collector-01ec8c5c5c3636a52d6f9e7c6f6cebaeb9f07af4.zip
Remove continue with label (#1084)
Instead of continue with label use helper function Signed-off-by: dmaiocchi <dmaiocchi@suse.com>
-rw-r--r--MAINTAINERS.md4
-rw-r--r--collector/textfile.go26
2 files changed, 20 insertions, 10 deletions
diff --git a/MAINTAINERS.md b/MAINTAINERS.md
index 7088f96..ffe9036 100644
--- a/MAINTAINERS.md
+++ b/MAINTAINERS.md
@@ -1,2 +1,2 @@
1* Ben Kochie <superq@gmail.com> 1* Ben Kochie <superq@gmail.com> @SuperQ
2* Johannes 'fish' Ziemke <github@freigeist.org> 2* Johannes 'fish' Ziemke <github@freigeist.org> @discordianfish
diff --git a/collector/textfile.go b/collector/textfile.go
index bc2ac43..ddd88b8 100644
--- a/collector/textfile.go
+++ b/collector/textfile.go
@@ -193,7 +193,6 @@ func (c *textFileCollector) Update(ch chan<- prometheus.Metric) error {
193 error = 1.0 193 error = 1.0
194 } 194 }
195 195
196fileLoop:
197 for _, f := range files { 196 for _, f := range files {
198 if !strings.HasSuffix(f.Name(), ".prom") { 197 if !strings.HasSuffix(f.Name(), ".prom") {
199 continue 198 continue
@@ -213,14 +212,13 @@ fileLoop:
213 error = 1.0 212 error = 1.0
214 continue 213 continue
215 } 214 }
215 if hasTimestamps(parsedFamilies) {
216 log.Errorf("Textfile %q contains unsupported client-side timestamps, skipping entire file", path)
217 error = 1.0
218 continue
219 }
220
216 for _, mf := range parsedFamilies { 221 for _, mf := range parsedFamilies {
217 for _, m := range mf.Metric {
218 if m.TimestampMs != nil {
219 log.Errorf("Textfile %q contains unsupported client-side timestamps, skipping entire file", path)
220 error = 1.0
221 continue fileLoop
222 }
223 }
224 if mf.Help == nil { 222 if mf.Help == nil {
225 help := fmt.Sprintf("Metric read from %s", path) 223 help := fmt.Sprintf("Metric read from %s", path)
226 mf.Help = &help 224 mf.Help = &help
@@ -249,3 +247,15 @@ fileLoop:
249 ) 247 )
250 return nil 248 return nil
251} 249}
250
251// hasTimestamps returns true when metrics contain unsupported timestamps.
252func hasTimestamps(parsedFamilies map[string]*dto.MetricFamily) bool {
253 for _, mf := range parsedFamilies {
254 for _, m := range mf.Metric {
255 if m.TimestampMs != nil {
256 return true
257 }
258 }
259 }
260 return false
261}