github.com/treeverse/lakefs@v1.24.1-0.20240520134607-95648127bfb0/pkg/block/s3/stats.go (about) 1 package s3 2 3 import ( 4 "strconv" 5 "time" 6 7 "github.com/prometheus/client_golang/prometheus" 8 "github.com/prometheus/client_golang/prometheus/promauto" 9 ) 10 11 var durationHistograms = promauto.NewHistogramVec( 12 prometheus.HistogramOpts{ 13 Name: "s3_operation_duration_seconds", 14 Help: "durations of outgoing s3 operations", 15 }, 16 []string{"operation", "error"}) 17 18 var requestSizeHistograms = promauto.NewHistogramVec( 19 prometheus.HistogramOpts{ 20 Name: "s3_operation_size_bytes", 21 Help: "handled sizes of outgoing s3 operations", 22 Buckets: prometheus.ExponentialBuckets(1, 10, 10), //nolint: mnd 23 }, []string{"operation", "error"}) 24 25 func reportMetrics(operation string, start time.Time, sizeBytes *int64, err *error) { 26 isErrStr := strconv.FormatBool(*err != nil) 27 durationHistograms.WithLabelValues(operation, isErrStr).Observe(time.Since(start).Seconds()) 28 if sizeBytes != nil { 29 requestSizeHistograms.WithLabelValues(operation, isErrStr).Observe(float64(*sizeBytes)) 30 } 31 }