metrics.go 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. // Copyright 2016 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 v3rpc
  15. import "github.com/prometheus/client_golang/prometheus"
  16. var (
  17. receivedCounter = prometheus.NewCounterVec(
  18. prometheus.CounterOpts{
  19. Namespace: "etcd",
  20. Subsystem: "grpc",
  21. Name: "requests_total",
  22. Help: "Counter of received requests.",
  23. }, []string{"grpc_service", "grpc_method"})
  24. failedCounter = prometheus.NewCounterVec(
  25. prometheus.CounterOpts{
  26. Namespace: "etcd",
  27. Subsystem: "grpc",
  28. Name: "requests_failed_total",
  29. Help: "Counter of failed requests.",
  30. }, []string{"grpc_service", "grpc_method", "grpc_code"})
  31. streamsGauage = prometheus.NewGaugeVec(
  32. prometheus.GaugeOpts{
  33. Namespace: "etcd",
  34. Subsystem: "grpc",
  35. Name: "active_streams",
  36. Help: "Number of active streams.",
  37. }, []string{"grpc_service", "grpc_method"})
  38. handlingDuration = prometheus.NewHistogramVec(
  39. prometheus.HistogramOpts{
  40. Namespace: "etcd",
  41. Subsystem: "grpc",
  42. Name: "unary_requests_duration_seconds",
  43. Help: "Bucketed histogram of processing time (s) of handled unary (non-stream) requests.",
  44. Buckets: prometheus.ExponentialBuckets(0.0005, 2, 13),
  45. }, []string{"grpc_service", "grpc_method"})
  46. sentBytes = prometheus.NewCounter(prometheus.CounterOpts{
  47. Namespace: "etcd",
  48. Subsystem: "network",
  49. Name: "client_grpc_sent_bytes_total",
  50. Help: "The total number of bytes sent to grpc clients.",
  51. })
  52. receivedBytes = prometheus.NewCounter(prometheus.CounterOpts{
  53. Namespace: "etcd",
  54. Subsystem: "network",
  55. Name: "client_grpc_received_bytes_total",
  56. Help: "The total number of bytes received from grpc clients.",
  57. })
  58. )
  59. func init() {
  60. prometheus.MustRegister(receivedCounter)
  61. prometheus.MustRegister(failedCounter)
  62. prometheus.MustRegister(streamsGauage)
  63. prometheus.MustRegister(handlingDuration)
  64. prometheus.MustRegister(sentBytes)
  65. prometheus.MustRegister(receivedBytes)
  66. }