metrics_registry.h 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. #pragma once
  2. #include "sensors_group.h"
  3. #include <util/generic/yexception.h>
  4. namespace NYql {
  5. namespace NProto {
  6. class TMetricsRegistrySnapshot;
  7. }
  8. struct IMetricsRegistry;
  9. using IMetricsRegistryPtr = TIntrusivePtr<IMetricsRegistry>;
  10. using TMetricsDecorator = std::function<IMetricsRegistryPtr(
  11. const IMetricsRegistryPtr& old, const TString& username)>;
  12. //////////////////////////////////////////////////////////////////////////////
  13. // IYqlMetricsRegistry
  14. //////////////////////////////////////////////////////////////////////////////
  15. struct IMetricsRegistry: public TThrRefBase {
  16. virtual void SetCounter(
  17. const TString& labelName,
  18. const TString& labelValue,
  19. i64 value,
  20. bool derivative = false) = 0;
  21. virtual void IncCounter(
  22. const TString& labelName,
  23. const TString& labelValue,
  24. bool derivative = true) = 0;
  25. virtual void AddCounter(
  26. const TString& labelName,
  27. const TString& labelValue,
  28. i64 value,
  29. bool derivative = true) = 0;
  30. // will invalidate all counters
  31. virtual bool TakeSnapshot(
  32. NProto::TMetricsRegistrySnapshot* snapshot) const = 0;
  33. virtual void MergeSnapshot(
  34. const NProto::TMetricsRegistrySnapshot& snapshot) = 0;
  35. virtual IMetricsRegistryPtr Personalized(
  36. const TString& userName) const = 0;
  37. virtual void Flush() = 0;
  38. virtual TSensorsGroupPtr GetSensors() {
  39. ythrow yexception() << "Not implemented";
  40. }
  41. };
  42. IMetricsRegistryPtr CreateMetricsRegistry(TSensorsGroupPtr sensors);
  43. } // namespace NYql