Skip to content

Commit

Permalink
Log metrics sent latency
Browse files Browse the repository at this point in the history
  • Loading branch information
jwilder committed Jan 12, 2024
1 parent c6bb152 commit 2985041
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
6 changes: 5 additions & 1 deletion collector/scraper.go
Original file line number Diff line number Diff line change
Expand Up @@ -393,7 +393,11 @@ func (s *Scraper) sendBatch(ctx context.Context, wr *prompb.WriteRequest) error
}
}

logger.Infof("Sending %d timeseries to %d endpoints", len(wr.Timeseries), len(s.opts.Endpoints))
start := time.Now()
defer func() {
logger.Infof("Sending %d timeseries to %d endpoints duration=%s", len(wr.Timeseries), len(s.opts.Endpoints), time.Since(start))
}()

g, gCtx := errgroup.WithContext(ctx)
for _, endpoint := range s.opts.Endpoints {
endpoint := endpoint
Expand Down
7 changes: 6 additions & 1 deletion pkg/promremote/proxy.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package promremote
import (
"context"
"strings"
"time"

"github.com/Azure/adx-mon/pkg/logger"
"github.com/Azure/adx-mon/pkg/prompb"
Expand Down Expand Up @@ -50,8 +51,12 @@ func (r *RemoteWriteProxy) Write(ctx context.Context, wr prompb.WriteRequest) er
}

endpoint := r.Endpoints[i]
logger.Infof("Sending %d timeseries to %s", len(batch.Timeseries), endpoint)
g.Go(func() error {
start := time.Now()
defer func() {
logger.Infof("Sending %d timeseries duration=%s", len((&batch).Timeseries), time.Since(start))
}()

return r.Client.Write(gCtx, endpoint, &batch)
})
}
Expand Down

0 comments on commit 2985041

Please sign in to comment.