0
Fork 0
mirror of https://github.com/project-zot/zot.git synced 2024-12-16 21:56:37 -05:00
zot/pkg/extensions/monitoring/common.go
Alexei Dodon 18e591f52a
fix: DATA RACE in TestNewExporter (#1766)
Signed-off-by: Alexei Dodon <adodon@cisco.com>
2023-09-08 15:00:16 +03:00

34 lines
649 B
Go

package monitoring
import (
"os"
"path/filepath"
"regexp"
)
var re = regexp.MustCompile(`\/v2\/(.*?)\/(blobs|tags|manifests)\/(.*)$`)
type MetricServer interface {
SendMetric(interface{})
// works like SendMetric, but adds the metric regardless of the value of 'enabled' field for MetricServer
ForceSendMetric(interface{})
ReceiveMetrics() interface{}
IsEnabled() bool
}
func getDirSize(path string) (int64, error) {
var size int64
err := filepath.Walk(path, func(_ string, info os.FileInfo, err error) error {
if err != nil {
return err
}
if !info.IsDir() {
size += info.Size()
}
return err
})
return size, err
}