service_counters.cpp 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. #include "service_counters.h"
  2. namespace NYql {
  3. namespace NCommon {
  4. TServiceCounters::TServiceCounters(
  5. const ::NMonitoring::TDynamicCounterPtr& rootCounters,
  6. const ::NMonitoring::TDynamicCounterPtr& publicCounters,
  7. const TString& subsystemName)
  8. : RootCounters(rootCounters)
  9. , PublicCounters(publicCounters)
  10. , Counters(subsystemName ? RootCounters->GetSubgroup("subsystem", subsystemName) : RootCounters)
  11. {
  12. }
  13. TServiceCounters::TServiceCounters(
  14. const ::NMonitoring::TDynamicCounterPtr& baseCounters,
  15. const TString& subsystemName)
  16. : RootCounters(baseCounters->GetSubgroup("counters", "yq"))
  17. , PublicCounters(baseCounters->GetSubgroup("counters", "yq_public"))
  18. , Counters(subsystemName ? RootCounters->GetSubgroup("subsystem", subsystemName) : RootCounters)
  19. {
  20. }
  21. TServiceCounters::TServiceCounters(
  22. const TServiceCounters& serviceCounters,
  23. const TString& subsystemName)
  24. : RootCounters(serviceCounters.RootCounters)
  25. , PublicCounters(serviceCounters.PublicCounters)
  26. , Counters(subsystemName ? RootCounters->GetSubgroup("subsystem", subsystemName) : serviceCounters.Counters)
  27. , UptimeRootCounter(serviceCounters.UptimeRootCounter)
  28. , UptimePublicCounter(serviceCounters.UptimePublicCounter)
  29. {
  30. }
  31. void TServiceCounters::InitUptimeCounter() {
  32. UptimePublicCounter = PublicCounters->GetNamedCounter("name", "query.uptime_seconds", false);
  33. UptimeRootCounter = RootCounters->GetNamedCounter("sensor", "UptimeSeconds", false);
  34. }
  35. void TServiceCounters::SetUptimePublicAndServiceCounter(i64 val) const {
  36. Y_ABORT_UNLESS(UptimePublicCounter && UptimeRootCounter);
  37. UptimePublicCounter->Set(val);
  38. UptimeRootCounter->Set(val);
  39. }
  40. } // namespace NCommon
  41. } // namespace NYql