metrics.go 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. // Copyright 2015 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 rafthttp
  15. import "github.com/prometheus/client_golang/prometheus"
  16. var (
  17. sentBytes = prometheus.NewCounterVec(prometheus.CounterOpts{
  18. Namespace: "etcd",
  19. Subsystem: "network",
  20. Name: "peer_sent_bytes_total",
  21. Help: "The total number of bytes sent to peers.",
  22. },
  23. []string{"To"},
  24. )
  25. receivedBytes = prometheus.NewCounterVec(prometheus.CounterOpts{
  26. Namespace: "etcd",
  27. Subsystem: "network",
  28. Name: "peer_received_bytes_total",
  29. Help: "The total number of bytes received from peers.",
  30. },
  31. []string{"From"},
  32. )
  33. sentFailures = prometheus.NewCounterVec(prometheus.CounterOpts{
  34. Namespace: "etcd",
  35. Subsystem: "network",
  36. Name: "peer_sent_failures_total",
  37. Help: "The total number of send failures from peers.",
  38. },
  39. []string{"To"},
  40. )
  41. recvFailures = prometheus.NewCounterVec(prometheus.CounterOpts{
  42. Namespace: "etcd",
  43. Subsystem: "network",
  44. Name: "peer_received_failures_total",
  45. Help: "The total number of receive failures from peers.",
  46. },
  47. []string{"From"},
  48. )
  49. rtts = prometheus.NewHistogramVec(prometheus.HistogramOpts{
  50. Namespace: "etcd",
  51. Subsystem: "network",
  52. Name: "peer_round_trip_time_seconds",
  53. Help: "Round-Trip-Time histogram between peers.",
  54. Buckets: prometheus.ExponentialBuckets(0.0001, 2, 14),
  55. },
  56. []string{"To"},
  57. )
  58. )
  59. func init() {
  60. prometheus.MustRegister(sentBytes)
  61. prometheus.MustRegister(receivedBytes)
  62. prometheus.MustRegister(sentFailures)
  63. prometheus.MustRegister(recvFailures)
  64. prometheus.MustRegister(rtts)
  65. }