From ff3aec3ba5dd1fb6e9714af1e595ff33a1303937 Mon Sep 17 00:00:00 2001 From: Acha Bill Date: Thu, 19 Oct 2023 15:30:34 +0100 Subject: [PATCH] chore: add download size metric --- pkg/check/longavailability/longavailability.go | 3 ++- pkg/check/longavailability/metrics.go | 9 +++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/pkg/check/longavailability/longavailability.go b/pkg/check/longavailability/longavailability.go index b115ecefe..5a2936054 100644 --- a/pkg/check/longavailability/longavailability.go +++ b/pkg/check/longavailability/longavailability.go @@ -73,7 +73,7 @@ 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) @@ -81,6 +81,7 @@ func (c *Check) Run(ctx context.Context, cluster orchestration.Cluster, o interf 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) diff --git a/pkg/check/longavailability/metrics.go b/pkg/check/longavailability/metrics.go index 80bd1b57e..cae857834 100644 --- a/pkg/check/longavailability/metrics.go +++ b/pkg/check/longavailability/metrics.go @@ -9,6 +9,7 @@ type metrics struct { DownloadErrors prometheus.Counter DownloadAttempts prometheus.Counter DownloadDuration prometheus.Histogram + DownloadSize prometheus.Gauge } func newMetrics(subsystem string) metrics { @@ -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.", + }, + ), } }