@@ -102,9 +102,12 @@ func generateFramereader() {
102
102
func updateURLTimestamp (timestamp int64 , name string , url string , body io.Reader ) io.Reader {
103
103
dec := expfmt .NewDecoder (body , expfmt .FmtText )
104
104
pr , pw := io .Pipe ()
105
+ enc := expfmt .NewEncoder (pw , expfmt .FmtText )
105
106
//ts := timestamp * 1000
106
107
107
108
go func () {
109
+ count := 0
110
+
108
111
for {
109
112
var metrics dto.MetricFamily
110
113
err := dec .Decode (& metrics )
@@ -132,10 +135,12 @@ func updateURLTimestamp(timestamp int64, name string, url string, body io.Reader
132
135
metric .Label = append (metric .Label , & urlp )
133
136
}
134
137
135
- enc := expfmt .NewEncoder (pw , expfmt .FmtText )
136
-
137
138
enc .Encode (& metrics )
139
+
140
+ count += 1
138
141
}
142
+
143
+ logrus .Printf ("%d metrics unmarshalled for %s" , count , url )
139
144
pw .Close ()
140
145
}()
141
146
@@ -200,13 +205,13 @@ func main() {
200
205
}
201
206
202
207
decSamples := make (model.Vector , 0 , 1 )
208
+ tempSamples := make (model.Vector , 0 , 1 )
203
209
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 ... )
207
212
}
208
213
209
- logrus .Debugln ("Ingested" , len (decSamples ), "metrics" )
214
+ logrus .Infoln ("Ingested" , len (decSamples ), "metrics" )
210
215
211
216
for sampleAppender .NeedsThrottling () {
212
217
logrus .Debugln ("Waiting 100ms for appender to be ready for more data" )
0 commit comments