metrics.go 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. // Copyright 2015 CoreOS, Inc.
  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. // TODO: record write/recv failures.
  17. var (
  18. sentBytes = prometheus.NewCounterVec(prometheus.CounterOpts{
  19. Namespace: "etcd",
  20. Subsystem: "network",
  21. Name: "sent_bytes_total",
  22. Help: "The total number of bytes sent.",
  23. },
  24. []string{"To"},
  25. )
  26. receivedBytes = prometheus.NewCounterVec(prometheus.CounterOpts{
  27. Namespace: "etcd",
  28. Subsystem: "network",
  29. Name: "received_bytes_total",
  30. Help: "The total number of bytes received.",
  31. },
  32. []string{"From"},
  33. )
  34. rtts = prometheus.NewHistogramVec(prometheus.HistogramOpts{
  35. Namespace: "etcd",
  36. Subsystem: "network",
  37. Name: "round_trip_time_seconds",
  38. Help: "Round-Trip-Time histogram between members.",
  39. Buckets: prometheus.ExponentialBuckets(0.0001, 2, 14),
  40. },
  41. []string{"To"},
  42. )
  43. )
  44. func init() {
  45. prometheus.MustRegister(sentBytes)
  46. prometheus.MustRegister(receivedBytes)
  47. prometheus.MustRegister(rtts)
  48. }