Skip to content

Commit

Permalink
record time cost for metrics reportting (#803)
Browse files Browse the repository at this point in the history
  • Loading branch information
kongfei605 committed Feb 21, 2024
1 parent e55acdc commit d944d18
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion writer/writers.go
Expand Up @@ -59,7 +59,7 @@ func (ws *Writers) LoopRead() {
for {
series := ws.queue.PopBackN(config.Config.WriterOpt.Batch)
if len(series) == 0 {
time.Sleep(time.Millisecond * 400)
time.Sleep(time.Millisecond * 100)
continue
}

Expand Down Expand Up @@ -125,6 +125,7 @@ func WriteTimeSeries(timeSeries []prompb.TimeSeries) {
return
}

now := time.Now()
wg := sync.WaitGroup{}
for key := range writers.writerMap {
wg.Add(1)
Expand All @@ -134,6 +135,10 @@ func WriteTimeSeries(timeSeries []prompb.TimeSeries) {
}(key)
}
wg.Wait()
if config.Config.DebugMode {
log.Println("D!, write", len(timeSeries), "time series to all writers, cost:",
time.Since(now).Milliseconds(), "ms")
}
}

func printTestMetrics(samples []*types.Sample) {
Expand Down

0 comments on commit d944d18

Please sign in to comment.