Skip to content

Commit 137fba9

Browse files
committed
promplay: append all the decoded metrics
1 parent 46ce6ec commit 137fba9

File tree

2 files changed

+12
-13
lines changed

2 files changed

+12
-13
lines changed

Gopkg.lock

Lines changed: 1 addition & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

bin/promplay/main.go

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -102,9 +102,12 @@ func generateFramereader() {
102102
func updateURLTimestamp(timestamp int64, name string, url string, body io.Reader) io.Reader {
103103
dec := expfmt.NewDecoder(body, expfmt.FmtText)
104104
pr, pw := io.Pipe()
105+
enc := expfmt.NewEncoder(pw, expfmt.FmtText)
105106
//ts := timestamp * 1000
106107

107108
go func() {
109+
count := 0
110+
108111
for {
109112
var metrics dto.MetricFamily
110113
err := dec.Decode(&metrics)
@@ -132,10 +135,12 @@ func updateURLTimestamp(timestamp int64, name string, url string, body io.Reader
132135
metric.Label = append(metric.Label, &urlp)
133136
}
134137

135-
enc := expfmt.NewEncoder(pw, expfmt.FmtText)
136-
137138
enc.Encode(&metrics)
139+
140+
count += 1
138141
}
142+
143+
logrus.Printf("%d metrics unmarshalled for %s", count, url)
139144
pw.Close()
140145
}()
141146

@@ -200,13 +205,13 @@ func main() {
200205
}
201206

202207
decSamples := make(model.Vector, 0, 1)
208+
tempSamples := make(model.Vector, 0, 1)
203209

204-
if err := sdec.Decode(&decSamples); err != nil {
205-
logrus.Errorln("Could not decode metric:", err)
206-
continue
210+
for err := sdec.Decode(&tempSamples); err == nil; err = sdec.Decode(&tempSamples) {
211+
decSamples = append(decSamples, tempSamples...)
207212
}
208213

209-
logrus.Debugln("Ingested", len(decSamples), "metrics")
214+
logrus.Infoln("Ingested", len(decSamples), "metrics")
210215

211216
for sampleAppender.NeedsThrottling() {
212217
logrus.Debugln("Waiting 100ms for appender to be ready for more data")

0 commit comments

Comments
 (0)