@@ -358,25 +358,51 @@ class TPendingFetcher : public NActors::TActorBootstrapped<TPendingFetcher> {
358
358
const TString folderId = NYdb::NFq::TScope (task.scope ()).ParseFolder ();
359
359
const TString cloudId = task.sensor_labels ().at (" cloud_id" );
360
360
const TString queryId = task.query_id ().value ();
361
+ const bool isStreaming = task.query_type () == FederatedQuery::QueryContent::STREAMING;
362
+ TString queryIdLabel;
363
+ // todo: sanitize query name
364
+ TString queryNameLabel = 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