Skip to content

Commit

Permalink
chore: add download size metric
Browse files Browse the repository at this point in the history
  • Loading branch information
acha-bill committed Oct 19, 2023
1 parent 2489b23 commit ff3aec3
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
3 changes: 2 additions & 1 deletion pkg/check/longavailability/longavailability.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,14 +73,15 @@ func (c *Check) Run(ctx context.Context, cluster orchestration.Cluster, o interf
c.logger.Infof("node %s: download attempt %d for %s", node.Name(), i+1, addr)

start := time.Now()
_, _, err = node.Client().DownloadFile(ctx, addr)
size, _, err := node.Client().DownloadFile(ctx, addr)
if err != nil {
c.metrics.DownloadErrors.Inc()
c.logger.Errorf("node %s: download %s error: %v", node.Name(), addr, err)
c.logger.Infof("retrying in: %v", opts.RetryWait)
time.Sleep(opts.RetryWait)
continue
}
c.metrics.DownloadSize.Set(float64(size))
dur := time.Since(start)
c.metrics.DownloadDuration.Observe(dur.Seconds())
c.logger.Infof("node %s: downloaded %s successfully in %v", node.Name(), addr, dur)
Expand Down
9 changes: 9 additions & 0 deletions pkg/check/longavailability/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ type metrics struct {
DownloadErrors prometheus.Counter
DownloadAttempts prometheus.Counter
DownloadDuration prometheus.Histogram
DownloadSize prometheus.Gauge
}

func newMetrics(subsystem string) metrics {
Expand All @@ -34,6 +35,14 @@ func newMetrics(subsystem string) metrics {
Name: "data_download_duration",
Help: "Data download duration through the /bytes endpoint.",
}),
DownloadSize: prometheus.NewGauge(
prometheus.GaugeOpts{
Namespace: m.Namespace,
Subsystem: subsystem,
Name: "download_size",
Help: "Amount of data downloaded per download.",
},
),
}
}

Expand Down

0 comments on commit ff3aec3

Please sign in to comment.