aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authoreshcherbin <eshcherbin@yandex-team.com>2024-10-17 17:08:17 +0300
committereshcherbin <eshcherbin@yandex-team.com>2024-10-17 17:23:49 +0300
commit2d4605d627b27be5dcb71d0e649959a5fa020524 (patch)
tree65dd2cc7642292cf42981872c9e45aa2b0406c6e
parent9b4d079ea101e7a8cf48c35f307330457712c52a (diff)
downloadydb-2d4605d627b27be5dcb71d0e649959a5fa020524.tar.gz
YT-23134: Fix sensor service paths
commit_hash:6c52404e8c00e60be2ab7545af30a4232874971a
-rw-r--r--yt/yt/core/ytree/ypath_client.cpp11
-rw-r--r--yt/yt/core/ytree/ypath_client.h6
-rw-r--r--yt/yt/library/profiling/solomon/sensor_service.cpp6
-rw-r--r--yt/yt/library/profiling/unittests/exporter_ut.cpp2
-rw-r--r--yt/yt/library/profiling/unittests/sensor_service_ut.cpp64
-rw-r--r--yt/yt/library/profiling/unittests/ya.make1
6 files changed, 80 insertions, 10 deletions
diff --git a/yt/yt/core/ytree/ypath_client.cpp b/yt/yt/core/ytree/ypath_client.cpp
index a07176978b..05086a2486 100644
--- a/yt/yt/core/ytree/ypath_client.cpp
+++ b/yt/yt/core/ytree/ypath_client.cpp
@@ -399,12 +399,16 @@ void ExecuteVerb(
TFuture<TYsonString> AsyncYPathGet(
const IYPathServicePtr& service,
const TYPath& path,
- const TAttributeFilter& attributeFilter)
+ const TAttributeFilter& attributeFilter,
+ const IAttributeDictionaryPtr& options)
{
auto request = TYPathProxy::Get(path);
if (attributeFilter) {
ToProto(request->mutable_attributes(), attributeFilter);
}
+ if (options) {
+ ToProto(request->mutable_options(), *options);
+ }
return ExecuteVerb(service, request)
.Apply(BIND([] (TYPathProxy::TRspGetPtr response) {
return TYsonString(response->value());
@@ -423,9 +427,10 @@ TString SyncYPathGetKey(const IYPathServicePtr& service, const TYPath& path)
TYsonString SyncYPathGet(
const IYPathServicePtr& service,
const TYPath& path,
- const TAttributeFilter& attributeFilter)
+ const TAttributeFilter& attributeFilter,
+ const IAttributeDictionaryPtr& options)
{
- auto future = AsyncYPathGet(service, path, attributeFilter);
+ auto future = AsyncYPathGet(service, path, attributeFilter, options);
auto optionalResult = future.TryGetUnique();
YT_VERIFY(optionalResult);
return optionalResult->ValueOrThrow();
diff --git a/yt/yt/core/ytree/ypath_client.h b/yt/yt/core/ytree/ypath_client.h
index 2f9fc916e4..d4889b7fe3 100644
--- a/yt/yt/core/ytree/ypath_client.h
+++ b/yt/yt/core/ytree/ypath_client.h
@@ -258,13 +258,15 @@ TString SyncYPathGetKey(
TFuture<NYson::TYsonString> AsyncYPathGet(
const IYPathServicePtr& service,
const TYPath& path,
- const TAttributeFilter& attributeFilter = {});
+ const TAttributeFilter& attributeFilter = {},
+ const IAttributeDictionaryPtr& options = {});
//! Executes |Get| verb assuming #service handles requests synchronously. Throws if an error has occurred.
NYson::TYsonString SyncYPathGet(
const IYPathServicePtr& service,
const TYPath& path,
- const TAttributeFilter& attributeFilter = {});
+ const TAttributeFilter& attributeFilter = {},
+ const IAttributeDictionaryPtr& options = {});
//! Asynchronously executes |Exists| verb.
TFuture<bool> AsyncYPathExists(
diff --git a/yt/yt/library/profiling/solomon/sensor_service.cpp b/yt/yt/library/profiling/solomon/sensor_service.cpp
index ce25c41673..4329d64264 100644
--- a/yt/yt/library/profiling/solomon/sensor_service.cpp
+++ b/yt/yt/library/profiling/solomon/sensor_service.cpp
@@ -4,13 +4,11 @@
#include "registry.h"
#include "private.h"
-#include <yt/yt/core/concurrency/async_rw_lock.h>
#include <yt/yt/core/concurrency/periodic_executor.h>
#include <yt/yt/core/ytree/fluent.h>
#include <yt/yt/core/ytree/virtual.h>
#include <yt/yt/core/ytree/ypath_client.h>
-#include <yt/yt/core/ytree/ypath_detail.h>
namespace NYT::NProfiling {
@@ -178,7 +176,7 @@ private:
auto node = CreateVirtualNode(std::move(sensorServiceImpl));
try {
- auto path = "/" + NYPath::ToYPathLiteral(name);
+ auto path = TYPath("/" + name);
ForceYPath(Root_, path);
SetNodeByYPath(Root_, path, node);
} catch (const std::exception& ex) {
@@ -196,7 +194,7 @@ private:
SensorTreeUpdateDuration_.Record(elapsed);
YT_LOG_DEBUG(
- "Finished updating sensor service tree"
+ "Finished updating sensor service tree "
"(TotalSensorCount: %v, AddedSensorCount: %v, MalformedSensorCount: %v, Elapsed: %v)",
sensors.size(),
addedSensorCount,
diff --git a/yt/yt/library/profiling/unittests/exporter_ut.cpp b/yt/yt/library/profiling/unittests/exporter_ut.cpp
index ef654170fb..2187b43b7d 100644
--- a/yt/yt/library/profiling/unittests/exporter_ut.cpp
+++ b/yt/yt/library/profiling/unittests/exporter_ut.cpp
@@ -1,9 +1,9 @@
-#include "yt/yt/library/profiling/solomon/registry.h"
#include <gtest/gtest.h>
#include <yt/yt/core/concurrency/action_queue.h>
#include <yt/yt/library/profiling/solomon/exporter.h>
+#include <yt/yt/library/profiling/solomon/registry.h>
namespace NYT::NProfiling {
namespace {
diff --git a/yt/yt/library/profiling/unittests/sensor_service_ut.cpp b/yt/yt/library/profiling/unittests/sensor_service_ut.cpp
new file mode 100644
index 0000000000..7571a349ee
--- /dev/null
+++ b/yt/yt/library/profiling/unittests/sensor_service_ut.cpp
@@ -0,0 +1,64 @@
+#include <gtest/gtest.h>
+
+#include <yt/yt/core/ytree/helpers.h>
+#include <yt/yt/core/ytree/ypath_client.h>
+#include <yt/yt/core/ytree/ypath_proxy.h>
+
+#include <yt/yt/library/profiling/solomon/registry.h>
+#include <yt/yt/library/profiling/solomon/exporter.h>
+#include <yt/yt/library/profiling/solomon/sensor_service.h>
+
+namespace NYT::NProfiling {
+namespace {
+
+using namespace NConcurrency;
+using namespace NYPath;
+using namespace NYTree;
+using namespace NYson;
+
+////////////////////////////////////////////////////////////////////////////////
+
+TEST(TSensorService, GetSensor)
+{
+ auto registry = New<TSolomonRegistry>();
+ auto config = New<TSolomonExporterConfig>();
+ config->GridStep = TDuration::Seconds(1);
+ config->UpdateSensorServiceTreePeriod = TDuration::MilliSeconds(100);
+ config->EnableSelfProfiling = false;
+ auto exporter = New<TSolomonExporter>(config, registry);
+
+ exporter->Start();
+
+ auto gauge = TProfiler(registry, "/foo").Gauge("/bar/baz");
+ gauge.Update(117.0);
+
+ registry->Collect();
+ auto sensorService = exporter->GetSensorService();
+
+ auto valueByName = [&] {
+ auto options = CreateEphemeralAttributes();
+ options->Set("name", "yt/foo/bar/baz");
+
+ return ConvertTo<double>(SyncYPathGet(sensorService, "", /*attributeFilter*/ {}, options));
+ }();
+
+ EXPECT_EQ(valueByName, 117.0);
+
+ TDelayedExecutor::WaitForDuration(2 * config->UpdateSensorServiceTreePeriod);
+
+ auto valueByPath = [&] {
+ auto options = CreateEphemeralAttributes();
+ options->Set("read_all_projections", false);
+
+ return ConvertTo<double>(SyncYPathGet(sensorService, "/yt/foo/bar/baz", /*attributeFilter*/ {}, options));
+ }();
+
+ EXPECT_EQ(valueByPath, 117.0);
+
+ exporter->Stop();
+}
+
+////////////////////////////////////////////////////////////////////////////////
+
+} // namespace
+} // namespace NYT::NProfiling
diff --git a/yt/yt/library/profiling/unittests/ya.make b/yt/yt/library/profiling/unittests/ya.make
index 073921728b..0fa5d9e6ee 100644
--- a/yt/yt/library/profiling/unittests/ya.make
+++ b/yt/yt/library/profiling/unittests/ya.make
@@ -8,6 +8,7 @@ ENDIF()
SRCS(
sensor_ut.cpp
+ sensor_service_ut.cpp
name_conflicts_ut.cpp
profiler_ut.cpp
solomon_ut.cpp