metrics.go 821 B

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. package datagramsession
  2. import (
  3. "github.com/prometheus/client_golang/prometheus"
  4. )
  5. const (
  6. namespace = "cloudflared"
  7. )
  8. var (
  9. activeUDPSessions = prometheus.NewGauge(prometheus.GaugeOpts{
  10. Namespace: namespace,
  11. Subsystem: "udp",
  12. Name: "active_sessions",
  13. Help: "Concurrent count of UDP sessions that are being proxied to any origin",
  14. })
  15. totalUDPSessions = prometheus.NewCounter(prometheus.CounterOpts{
  16. Namespace: namespace,
  17. Subsystem: "udp",
  18. Name: "total_sessions",
  19. Help: "Total count of UDP sessions that have been proxied to any origin",
  20. })
  21. )
  22. func init() {
  23. prometheus.MustRegister(
  24. activeUDPSessions,
  25. totalUDPSessions,
  26. )
  27. }
  28. func incrementUDPSessions() {
  29. totalUDPSessions.Inc()
  30. activeUDPSessions.Inc()
  31. }
  32. func decrementUDPActiveSessions() {
  33. activeUDPSessions.Dec()
  34. }