1
0

metrics.go 1.1 KB

1234567891011121314151617181920212223242526272829303132333435
  1. // Copyright (C) 2023 The Syncthing Authors.
  2. //
  3. // This Source Code Form is subject to the terms of the Mozilla Public
  4. // License, v. 2.0. If a copy of the MPL was not distributed with this file,
  5. // You can obtain one at https://mozilla.org/MPL/2.0/.
  6. package scanner
  7. import (
  8. "github.com/prometheus/client_golang/prometheus"
  9. "github.com/prometheus/client_golang/prometheus/promauto"
  10. )
  11. var (
  12. metricHashedBytes = promauto.NewCounterVec(prometheus.CounterOpts{
  13. Namespace: "syncthing",
  14. Subsystem: "scanner",
  15. Name: "hashed_bytes_total",
  16. Help: "Total amount of data hashed, per folder",
  17. }, []string{"folder"})
  18. metricScannedItems = promauto.NewCounterVec(prometheus.CounterOpts{
  19. Namespace: "syncthing",
  20. Subsystem: "scanner",
  21. Name: "scanned_items_total",
  22. Help: "Total number of items (files/directories) inspected, per folder",
  23. }, []string{"folder"})
  24. )
  25. func registerFolderMetrics(folderID string) {
  26. // Register metrics for this folder, so that counters are present even
  27. // when zero.
  28. metricHashedBytes.WithLabelValues(folderID)
  29. metricScannedItems.WithLabelValues(folderID)
  30. }