metrics.go 882 B

12345678910111213141516171819202122232425
  1. // Copyright (C) 2024 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 connections
  7. import (
  8. "github.com/prometheus/client_golang/prometheus"
  9. "github.com/prometheus/client_golang/prometheus/promauto"
  10. )
  11. var metricDeviceActiveConnections = promauto.NewGaugeVec(prometheus.GaugeOpts{
  12. Namespace: "syncthing",
  13. Subsystem: "connections",
  14. Name: "active",
  15. Help: "Number of currently active connections, per device. If value is 0, the device is disconnected.",
  16. }, []string{"device"})
  17. func registerDeviceMetrics(deviceID string) {
  18. // Register metrics for this device, so that counters & gauges are present even
  19. // when zero.
  20. metricDeviceActiveConnections.WithLabelValues(deviceID)
  21. }