Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 11 additions & 4 deletions ydb/core/graph/shard/backends.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,7 @@ bool TLocalBackend::StoreMetrics(NTabletFlatExecutor::TTransactionContext& txc,
if (itId == MetricsIndex.end()) {
itId = MetricsIndex.emplace(name, MetricsIndex.size()).first;
db.Table<Schema::MetricsIndex>().Key(name).Update<Schema::MetricsIndex::Id>(itId->second);
BLOG_TRACE("Metric " << name << " has id " << itId->second);
}
ui64 id = itId->second;
db.Table<Schema::MetricsValues>().Key(data.Timestamp.Seconds(), id).Update<Schema::MetricsValues::Value>(value);
Expand Down Expand Up @@ -367,8 +368,11 @@ bool TLocalBackend::DownsampleData(NTabletFlatExecutor::TTransactionContext& txc
}
if (!values.Timestamps.empty()) {
BLOG_TRACE("Result time is " << values.Timestamps.front().Seconds());
for (ui64 id = 0; id < values.Values.size(); ++id) {
db.Table<Schema::MetricsValues>().Key(values.Timestamps.front().Seconds(), id).Update<Schema::MetricsValues::Value>(values.Values.front()[id]);
for (ui64 id : ids) {
if (!values.Values[id].empty()) {
BLOG_TRACE("Updating values with id " << id);
db.Table<Schema::MetricsValues>().Key(values.Timestamps.front().Seconds(), id).Update<Schema::MetricsValues::Value>(values.Values[id].front());
}
}
}
ids.clear();
Expand Down Expand Up @@ -400,8 +404,11 @@ bool TLocalBackend::DownsampleData(NTabletFlatExecutor::TTransactionContext& txc
}
if (!values.Timestamps.empty()) {
BLOG_TRACE("Result time is " << values.Timestamps.front().Seconds());
for (ui64 id = 0; id < values.Values.size(); ++id) {
db.Table<Schema::MetricsValues>().Key(values.Timestamps.front().Seconds(), id).Update<Schema::MetricsValues::Value>(values.Values.front()[id]);
for (ui64 id : ids) {
if (!values.Values[id].empty()) {
BLOG_TRACE("Updating values with id " << id);
db.Table<Schema::MetricsValues>().Key(values.Timestamps.front().Seconds(), id).Update<Schema::MetricsValues::Value>(values.Values[id].front());
}
}
}

Expand Down
28 changes: 23 additions & 5 deletions ydb/core/graph/ut/graph_ut.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -341,13 +341,31 @@ Y_UNIT_TEST_SUITE(Graph) {
// this call is needed to wait for establishing of pipe connection
{
NGraph::TEvGraph::TEvGetMetrics* event = new NGraph::TEvGraph::TEvGetMetrics();
event->Record.AddMetrics("test.metric1");
event->Record.AddMetrics("test.metric9");
runtime.Send(NGraph::MakeGraphServiceId(), sender, event);
TAutoPtr<IEventHandle> handle;
NGraph::TEvGraph::TEvMetricsResult* response = runtime.GrabEdgeEventRethrow<NGraph::TEvGraph::TEvMetricsResult>(handle);
Ctest << "Received result: " << response->Record.ShortDebugString() << Endl;
}

Ctest << "Send old metrics..." << Endl;

{
NGraph::TEvGraph::TEvSendMetrics* event = new NGraph::TEvGraph::TEvSendMetrics();
{
NKikimrGraph::TMetric* metric = event->Record.AddMetrics();
metric->SetName("test.metric0");
metric->SetValue(13);
}
{
NKikimrGraph::TMetric* metric = event->Record.AddMetrics();
metric->SetName("test.metric1");
metric->SetValue(14);
}
event->Record.SetTime(0);
runtime.Send(NGraph::MakeGraphServiceId(), sender, event);
}

runtime.SimulateSleep(TDuration::Seconds(1));

Ctest << "Filling..." << Endl;
Expand All @@ -356,7 +374,7 @@ Y_UNIT_TEST_SUITE(Graph) {
{
NGraph::TEvGraph::TEvSendMetrics* event = new NGraph::TEvGraph::TEvSendMetrics();
NKikimrGraph::TMetric* metric = event->Record.AddMetrics();
metric->SetName("test.metric1");
metric->SetName("test.metric9");
metric->SetValue(seconds);
event->Record.SetTime(60 * minutes + seconds);
runtime.Send(NGraph::MakeGraphServiceId(), sender, event);
Expand All @@ -367,7 +385,7 @@ Y_UNIT_TEST_SUITE(Graph) {
Ctest << "Checking..." << Endl;
{
NGraph::TEvGraph::TEvGetMetrics* event = new NGraph::TEvGraph::TEvGetMetrics();
event->Record.AddMetrics("test.metric1");
event->Record.AddMetrics("test.metric9");
runtime.Send(NGraph::MakeGraphServiceId(), sender, event);
TAutoPtr<IEventHandle> handle;
NGraph::TEvGraph::TEvMetricsResult* response = runtime.GrabEdgeEventRethrow<NGraph::TEvGraph::TEvMetricsResult>(handle);
Expand All @@ -380,7 +398,7 @@ Y_UNIT_TEST_SUITE(Graph) {
{
NGraph::TEvGraph::TEvSendMetrics* event = new NGraph::TEvGraph::TEvSendMetrics();
NKikimrGraph::TMetric* metric = event->Record.AddMetrics();
metric->SetName("test.metric1");
metric->SetName("test.metric9");
metric->SetValue(seconds);
runtime.Send(NGraph::MakeGraphServiceId(), sender, event);
}
Expand All @@ -390,7 +408,7 @@ Y_UNIT_TEST_SUITE(Graph) {
Ctest << "Checking..." << Endl;
{
NGraph::TEvGraph::TEvGetMetrics* event = new NGraph::TEvGraph::TEvGetMetrics();
event->Record.AddMetrics("test.metric1");
event->Record.AddMetrics("test.metric9");
runtime.Send(NGraph::MakeGraphServiceId(), sender, event);
TAutoPtr<IEventHandle> handle;
NGraph::TEvGraph::TEvMetricsResult* response = runtime.GrabEdgeEventRethrow<NGraph::TEvGraph::TEvMetricsResult>(handle);
Expand Down