|
53 | 53 | #include <ydb/core/fq/libs/control_plane_storage/control_plane_storage.h> |
54 | 54 | #include <ydb/core/fq/libs/control_plane_storage/events/events.h> |
55 | 55 | #include <ydb/core/fq/libs/events/events.h> |
| 56 | +#include <ydb/core/fq/libs/metrics/sanitize_label.h> |
56 | 57 | #include <ydb/core/fq/libs/private_client/internal_service.h> |
57 | 58 |
|
58 | 59 | #include <ydb/library/actors/core/log.h> |
@@ -358,25 +359,50 @@ class TPendingFetcher : public NActors::TActorBootstrapped<TPendingFetcher> { |
358 | 359 | const TString folderId = NYdb::NFq::TScope(task.scope()).ParseFolder(); |
359 | 360 | const TString cloudId = task.sensor_labels().at("cloud_id"); |
360 | 361 | const TString queryId = task.query_id().value(); |
| 362 | + const bool isStreaming = task.query_type() == FederatedQuery::QueryContent::STREAMING; |
| 363 | + TString queryIdLabel; |
| 364 | + TString queryNameLabel = SanitizeLabel(task.query_name()); |
| 365 | + if (task.automatic()) { |
| 366 | + queryIdLabel = isStreaming ? "streaming" : "analytics"; |
| 367 | + } else if (isStreaming) { |
| 368 | + queryIdLabel = queryId; |
| 369 | + } else { |
| 370 | + queryIdLabel = "manual"; |
| 371 | + } |
361 | 372 |
|
362 | 373 | ::NYql::NCommon::TServiceCounters queryCounters(ServiceCounters); |
363 | 374 | auto publicCountersParent = ServiceCounters.PublicCounters; |
364 | 375 |
|
365 | 376 | if (cloudId && folderId) { |
366 | 377 | publicCountersParent = publicCountersParent->GetSubgroup("cloud_id", cloudId)->GetSubgroup("folder_id", folderId); |
367 | 378 | } |
368 | | - queryCounters.PublicCounters = publicCountersParent->GetSubgroup("query_id", |
369 | | - task.automatic() ? (task.query_name() ? task.query_name() : "automatic") : queryId); |
| 379 | + |
| 380 | + ::NMonitoring::TDynamicCounterPtr queryPublicCounters = publicCountersParent; |
| 381 | + // use original query id here |
| 382 | + queryPublicCounters = queryPublicCounters->GetSubgroup("query_id", queryId); |
| 383 | + |
| 384 | + if (queryNameLabel) { |
| 385 | + queryPublicCounters = queryPublicCounters->GetSubgroup("query_name", queryNameLabel); |
| 386 | + } |
| 387 | + queryCounters.PublicCounters = queryPublicCounters; |
370 | 388 |
|
371 | 389 | auto rootCountersParent = ServiceCounters.RootCounters; |
372 | 390 | std::set<std::pair<TString, TString>> sensorLabels(task.sensor_labels().begin(), task.sensor_labels().end()); |
373 | 391 | for (const auto& [label, item]: sensorLabels) { |
374 | 392 | rootCountersParent = rootCountersParent->GetSubgroup(label, item); |
375 | 393 | } |
376 | 394 |
|
377 | | - queryCounters.RootCounters = rootCountersParent->GetSubgroup("query_id", |
378 | | - task.automatic() ? (folderId ? "automatic_" + folderId : "automatic") : queryId); |
379 | | - queryCounters.Counters = queryCounters.RootCounters; |
| 395 | + ::NMonitoring::TDynamicCounterPtr queryRootCounters = rootCountersParent; |
| 396 | + if (queryIdLabel) { |
| 397 | + queryRootCounters = queryRootCounters->GetSubgroup("query_id", queryIdLabel); |
| 398 | + } |
| 399 | + |
| 400 | + if (!task.automatic() && isStreaming && queryNameLabel) { |
| 401 | + queryRootCounters = queryRootCounters->GetSubgroup("query_name", queryNameLabel); |
| 402 | + } |
| 403 | + |
| 404 | + queryCounters.RootCounters = queryRootCounters; |
| 405 | + queryCounters.Counters = queryRootCounters; |
380 | 406 |
|
381 | 407 | queryCounters.InitUptimeCounter(); |
382 | 408 | const auto createdAt = TInstant::Now(); |
|
0 commit comments