Skip to content

less query id labels #12427

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 10 commits into from
Dec 17, 2024
Merged
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
36 changes: 31 additions & 5 deletions ydb/core/fq/libs/actors/pending_fetcher.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -358,25 +358,51 @@ class TPendingFetcher : public NActors::TActorBootstrapped<TPendingFetcher> {
const TString folderId = NYdb::NFq::TScope(task.scope()).ParseFolder();
const TString cloudId = task.sensor_labels().at("cloud_id");
const TString queryId = task.query_id().value();
const bool isStreaming = task.query_type() == FederatedQuery::QueryContent::STREAMING;
TString queryIdLabel;
// todo: sanitize query name
TString queryNameLabel = task.query_name();
if (task.automatic()) {
queryIdLabel = isStreaming ? "streaming" : "analytics";
} else if (isStreaming) {
queryIdLabel = queryId;
} else {
queryIdLabel = "manual";
}

::NYql::NCommon::TServiceCounters queryCounters(ServiceCounters);
auto publicCountersParent = ServiceCounters.PublicCounters;

if (cloudId && folderId) {
publicCountersParent = publicCountersParent->GetSubgroup("cloud_id", cloudId)->GetSubgroup("folder_id", folderId);
}
queryCounters.PublicCounters = publicCountersParent->GetSubgroup("query_id",
task.automatic() ? (task.query_name() ? task.query_name() : "automatic") : queryId);

::NMonitoring::TDynamicCounterPtr queryPublicCounters = publicCountersParent;
// use original query id here
queryPublicCounters = queryPublicCounters->GetSubgroup("query_id", queryId);

if (queryNameLabel) {
queryPublicCounters = queryPublicCounters->GetSubgroup("query_name", queryNameLabel);
}
queryCounters.PublicCounters = queryPublicCounters;

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

queryCounters.RootCounters = rootCountersParent->GetSubgroup("query_id",
task.automatic() ? (folderId ? "automatic_" + folderId : "automatic") : queryId);
queryCounters.Counters = queryCounters.RootCounters;
::NMonitoring::TDynamicCounterPtr queryRootCounters = rootCountersParent;
if (queryIdLabel) {
queryRootCounters = queryRootCounters->GetSubgroup("query_id", queryIdLabel);
}

if (!task.automatic() && isStreaming && queryNameLabel) {
queryRootCounters = queryRootCounters->GetSubgroup("query_name", queryNameLabel);
}

queryCounters.RootCounters = queryRootCounters;
queryCounters.Counters = queryRootCounters;

queryCounters.InitUptimeCounter();
const auto createdAt = TInstant::Now();
Expand Down
Loading