metrics.go 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. // Copyright 2018 The etcd Authors
  2. //
  3. // Licensed under the Apache License, Version 2.0 (the "License");
  4. // you may not use this file except in compliance with the License.
  5. // You may obtain a copy of the License at
  6. //
  7. // http://www.apache.org/licenses/LICENSE-2.0
  8. //
  9. // Unless required by applicable law or agreed to in writing, software
  10. // distributed under the License is distributed on an "AS IS" BASIS,
  11. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. // See the License for the specific language governing permissions and
  13. // limitations under the License.
  14. package lease
  15. import (
  16. "github.com/prometheus/client_golang/prometheus"
  17. )
  18. var (
  19. leaseGranted = prometheus.NewCounter(prometheus.CounterOpts{
  20. Namespace: "etcd_debugging",
  21. Subsystem: "lease",
  22. Name: "granted_total",
  23. Help: "The total number of granted leases.",
  24. })
  25. leaseRevoked = prometheus.NewCounter(prometheus.CounterOpts{
  26. Namespace: "etcd_debugging",
  27. Subsystem: "lease",
  28. Name: "revoked_total",
  29. Help: "The total number of revoked leases.",
  30. })
  31. leaseRenewed = prometheus.NewCounter(prometheus.CounterOpts{
  32. Namespace: "etcd_debugging",
  33. Subsystem: "lease",
  34. Name: "renewed_total",
  35. Help: "The number of renewed leases seen by the leader.",
  36. })
  37. leaseTotalTTLs = prometheus.NewHistogram(
  38. prometheus.HistogramOpts{
  39. Namespace: "etcd_debugging",
  40. Subsystem: "lease",
  41. Name: "ttl_total",
  42. Help: "Bucketed histogram of lease TTLs.",
  43. // 1 second -> 3 months
  44. Buckets: prometheus.ExponentialBuckets(1, 2, 24),
  45. })
  46. )
  47. func init() {
  48. prometheus.MustRegister(leaseGranted)
  49. prometheus.MustRegister(leaseRevoked)
  50. prometheus.MustRegister(leaseRenewed)
  51. prometheus.MustRegister(leaseTotalTTLs)
  52. }