You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
It is possible to force out the remaining metrics by adding blank lines (or other metrics) to the file:
echo "" >> /tmp/metrics.txt
That will result in the second metric being produced. Likewise with the third.
Additional info:
I was able to track the issue down to the influx.StreamParser and demonstrate the issue. It seems to only be a problem with a continuous io.Reader and doesn't present itself in the current tests which use bytes.NewBuffer.
Here's what I believe is a valid demonstration of the issue. This can be added to plugins/parsers/influx/parser_test.go. I included the second for loop to demonstrated that closing the reader does produce additional metrics. I wouldn't expect that to be part of a delivered test.
funcTestStreamParserProducesAllAvailableMetrics(t*testing.T) {
expectedMetrics:=2r, w:=io.Pipe()
parser:=NewStreamParser(r)
parser.SetTimeFunc(DefaultTime)
metrics:=make(chan telegraf.Metric)
deferclose(metrics)
gofunc() {
w.Write([]byte("metric1 value=1\nmetric2 value=1"))
}()
gofunc() {
for {
fmt.Println("Waiting for a metric")
m, err:=parser.Next()
fmt.Println("Got a metric")
iferr!=nil {
fmt.Println(err)
return
} else {
metrics<-m
}
}
}()
i:=0for ; i<expectedMetrics&&!t.Failed(); i++ {
select {
casem:=<-metrics:
fmt.Println(m)
continuecase<-time.After(1*time.Second):
t.Errorf("Timed out waiting for metrics. Expected %v, but received %v", expectedMetrics, i)
}
}
r.Close()
w.Close()
for ; i<expectedMetrics; i++ {
select {
casem:=<-metrics:
fmt.Println(m)
continuecase<-time.After(1*time.Second):
t.Errorf("Also didn't get the metrics after close. Expected %v, but received %v", expectedMetrics, i)
}
}
}
The text was updated successfully, but these errors were encountered:
Relevant telegraf.conf:
System info:
This was build from master as that's where the latest
execd
code exists.My reproduction is using
ci-1.13.docker
from thescripts
directory.Steps to reproduce:
Expected behavior:
I expect all three metrics to be produced as
tail
is outputting them to stdout.Actual behavior:
Instead, only the first is produced.
It is possible to force out the remaining metrics by adding blank lines (or other metrics) to the file:
That will result in the second metric being produced. Likewise with the third.
Additional info:
I was able to track the issue down to the
influx.StreamParser
and demonstrate the issue. It seems to only be a problem with a continuousio.Reader
and doesn't present itself in the current tests which usebytes.NewBuffer
.Here's what I believe is a valid demonstration of the issue. This can be added to
plugins/parsers/influx/parser_test.go
. I included the secondfor
loop to demonstrated that closing the reader does produce additional metrics. I wouldn't expect that to be part of a delivered test.The text was updated successfully, but these errors were encountered: