diff options
author | robot-piglet <robot-piglet@yandex-team.com> | 2024-08-12 11:12:33 +0300 |
---|---|---|
committer | robot-piglet <robot-piglet@yandex-team.com> | 2024-08-12 11:22:03 +0300 |
commit | 67092572fe38e11cdfbe8c66fe5ab30ffe9a4264 (patch) | |
tree | 03e705edab6126f2aaba7c4e169cbe82ef41c313 | |
parent | 257897ca64dd6a9c71b917b128ec453a36d6d8a1 (diff) | |
download | ydb-67092572fe38e11cdfbe8c66fe5ab30ffe9a4264.tar.gz |
Intermediate changes
3 files changed, 22 insertions, 0 deletions
diff --git a/yt/yt/library/profiling/sensors_owner/sensors_owner.cpp b/yt/yt/library/profiling/sensors_owner/sensors_owner.cpp index 19a5c238a7..b29b612c6d 100644 --- a/yt/yt/library/profiling/sensors_owner/sensors_owner.cpp +++ b/yt/yt/library/profiling/sensors_owner/sensors_owner.cpp @@ -125,6 +125,20 @@ const TSensorsOwner& TSensorsOwner::WithPrefix(const TString& prefix) const return Get<TChild>(prefix).SensorsOwner; } +const TSensorsOwner& TSensorsOwner::WithGlobal() const +{ + struct TChild + { + TSensorsOwner SensorsOwner; + + TChild(const TProfiler& profiler) + : SensorsOwner(profiler.WithGlobal()) + { } + }; + + return Get<TChild>().SensorsOwner; +} + const TCounter& TSensorsOwner::GetCounter(TStringBuf name) const { return Get<TCounterWrapper>(name).Sensor; diff --git a/yt/yt/library/profiling/sensors_owner/sensors_owner.h b/yt/yt/library/profiling/sensors_owner/sensors_owner.h index d627d3054f..14f0dd9cfd 100644 --- a/yt/yt/library/profiling/sensors_owner/sensors_owner.h +++ b/yt/yt/library/profiling/sensors_owner/sensors_owner.h @@ -62,6 +62,8 @@ public: //! Result of WithPrefix(prefix) is always the same with fixed *this and prefix. const TSensorsOwner& WithPrefix(const TString& prefix) const; + const TSensorsOwner& WithGlobal() const; + const TProfiler& GetProfiler() const; /*! diff --git a/yt/yt/library/profiling/sensors_owner/unittests/sensors_owner_ut.cpp b/yt/yt/library/profiling/sensors_owner/unittests/sensors_owner_ut.cpp index a1f101bb84..0a8ffe4c3e 100644 --- a/yt/yt/library/profiling/sensors_owner/unittests/sensors_owner_ut.cpp +++ b/yt/yt/library/profiling/sensors_owner/unittests/sensors_owner_ut.cpp @@ -172,6 +172,12 @@ TEST(TSensorsOwnerTest, Copy) ASSERT_EQ(&owner.Get<TChild>(), &owner2.Get<TChild>()); // The same owner. } +TEST(TSensorsOwnerTest, WithGlobal) +{ + auto owner = TSensorsOwner(TProfiler("", "bigrt.test")); + owner.WithGlobal().GetCounter("counter").Increment(1); // Expect no fail here. +} + //////////////////////////////////////////////////////////////////////////////// } // namespace |