metrics.go 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  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. handlingDuration = prometheus.NewHistogramVec(
  32. prometheus.HistogramOpts{
  33. Namespace: "etcd",
  34. Subsystem: "grpc",
  35. Name: "unary_requests_duration_seconds",
  36. Help: "Bucketed histogram of processing time (s) of handled unary (non-stream) requests.",
  37. Buckets: prometheus.ExponentialBuckets(0.0005, 2, 13),
  38. }, []string{"grpc_service", "grpc_method"})
  39. sentBytes = prometheus.NewCounter(prometheus.CounterOpts{
  40. Namespace: "etcd",
  41. Subsystem: "network",
  42. Name: "client_grpc_sent_bytes_total",
  43. Help: "The total number of bytes sent to grpc clients.",
  44. })
  45. receivedBytes = prometheus.NewCounter(prometheus.CounterOpts{
  46. Namespace: "etcd",
  47. Subsystem: "network",
  48. Name: "client_grpc_received_bytes_total",
  49. Help: "The total number of bytes received from grpc clients.",
  50. })
  51. )
  52. func init() {
  53. prometheus.MustRegister(receivedCounter)
  54. prometheus.MustRegister(failedCounter)
  55. prometheus.MustRegister(handlingDuration)
  56. prometheus.MustRegister(sentBytes)
  57. prometheus.MustRegister(receivedBytes)
  58. }