metrics.go 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  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. )
  40. func init() {
  41. prometheus.MustRegister(receivedCounter)
  42. prometheus.MustRegister(failedCounter)
  43. prometheus.MustRegister(handlingDuration)
  44. }