Skip to content

Commit c536ea2

Browse files
committed
rework query id
1 parent 93ca57c commit c536ea2

File tree

2 files changed

+27
-9
lines changed

2 files changed

+27
-9
lines changed

ydb/core/fq/libs/actors/pending_fetcher.cpp

Lines changed: 26 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -359,15 +359,17 @@ class TPendingFetcher : public NActors::TActorBootstrapped<TPendingFetcher> {
359359
const TString cloudId = task.sensor_labels().at("cloud_id");
360360
const TString queryId = task.query_id().value();
361361
const bool isStreaming = task.query_type() == FederatedQuery::QueryContent::STREAMING;
362-
TString queryIdLabel = queryId;
362+
TString queryIdLabel;
363+
TString queryNameLabel;
363364
if (task.automatic()) {
364-
queryIdLabel = isStreaming ? "streaming" : "automatic";
365+
queryIdLabel = isStreaming ? "streaming" : "analytics";
365366
} else {
366-
if (!isStreaming) {
367-
queryIdLabel = "analytics";
368-
} else if (task.query_name()) {
367+
if (isStreaming) {
369368
// todo: sanitize query name
370-
queryIdLabel = task.query_name();
369+
queryNameLabel = task.query_name();
370+
queryIdLabel = queryId;
371+
} else {
372+
queryIdLabel = "manual";
371373
}
372374
}
373375

@@ -377,15 +379,31 @@ class TPendingFetcher : public NActors::TActorBootstrapped<TPendingFetcher> {
377379
if (cloudId && folderId) {
378380
publicCountersParent = publicCountersParent->GetSubgroup("cloud_id", cloudId)->GetSubgroup("folder_id", folderId);
379381
}
380-
queryCounters.PublicCounters = publicCountersParent->GetSubgroup("query_id", queryIdLabel);
382+
383+
if (queryIdLabel) {
384+
publicCountersParent = publicCountersParent->GetSubgroup("query_id", queryIdLabel);
385+
}
386+
387+
if (queryNameLabel) {
388+
publicCountersParent = publicCountersParent->GetSubgroup("query_name", queryNameLabel);
389+
}
390+
queryCounters.PublicCounters = publicCountersParent;
381391

382392
auto rootCountersParent = ServiceCounters.RootCounters;
383393
std::set<std::pair<TString, TString>> sensorLabels(task.sensor_labels().begin(), task.sensor_labels().end());
384394
for (const auto& [label, item]: sensorLabels) {
385395
rootCountersParent = rootCountersParent->GetSubgroup(label, item);
386396
}
387397

388-
queryCounters.RootCounters = rootCountersParent->GetSubgroup("query_id", queryIdLabel);
398+
if (queryIdLabel) {
399+
rootCountersParent = rootCountersParent->GetSubgroup("query_id", queryIdLabel);
400+
}
401+
402+
if (queryNameLabel) {
403+
rootCountersParent = rootCountersParent->GetSubgroup("query_name", queryNameLabel);
404+
}
405+
406+
queryCounters.RootCounters = rootCountersParent;
389407
queryCounters.Counters = queryCounters.RootCounters;
390408

391409
queryCounters.InitUptimeCounter();

ydb/tests/fq/s3/test_public_metrics.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ def test_public_metrics(self, kikimr, s3, client, yq_version, unique_prefix):
5656
)
5757
logging.debug(str(metrics))
5858

59-
query_id_label = "analytics"
59+
query_id_label = "manual"
6060
assert (
6161
metrics.find_sensor(
6262
{"cloud_id": cloud_id, "folder_id": folder_id, "query_id": query_id_label, "name": "query.running_tasks"}

0 commit comments

Comments
 (0)