Skip to content

Commit 961df40

Browse files
authored
YQ-3893 Remove query_id metrics on terminate (#12397)
1 parent 0888f85 commit 961df40

File tree

5 files changed

+16
-10
lines changed

5 files changed

+16
-10
lines changed

ydb/core/fq/libs/row_dispatcher/row_dispatcher.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -586,6 +586,7 @@ void TRowDispatcher::UpdateMetrics() {
586586
}
587587
for (const auto& key : toDelete) {
588588
SetQueryMetrics(key, 0, 0, 0);
589+
Metrics.Counters->RemoveSubgroup("query_id", key.QueryId);
589590
AggrStats.LastQueryStats.erase(key);
590591
}
591592
PrintStateToLog();

ydb/core/fq/libs/row_dispatcher/topic_session.cpp

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -93,20 +93,27 @@ class TTopicSession : public TActorBootstrapped<TTopicSession> {
9393
struct TClientsInfo : public IClientDataConsumer {
9494
using TPtr = TIntrusivePtr<TClientsInfo>;
9595

96-
TClientsInfo(TTopicSession& self, const TString& logPrefix, const ITopicFormatHandler::TSettings& handlerSettings, const NFq::TEvRowDispatcher::TEvStartSession::TPtr& ev, NMonitoring::TDynamicCounterPtr& counters)
96+
TClientsInfo(TTopicSession& self, const TString& logPrefix, const ITopicFormatHandler::TSettings& handlerSettings, const NFq::TEvRowDispatcher::TEvStartSession::TPtr& ev, const NMonitoring::TDynamicCounterPtr& counters, const TString& readGroup)
9797
: Self(self)
9898
, LogPrefix(logPrefix)
9999
, HandlerSettings(handlerSettings)
100100
, Settings(ev->Get()->Record)
101101
, ReadActorId(ev->Sender)
102-
, FilteredDataRate(counters->GetCounter("FilteredDataRate", true))
103-
, RestartSessionByOffsetsByQuery(counters->GetCounter("RestartSessionByOffsetsByQuery", true))
102+
, Counters(counters)
104103
{
105104
if (Settings.HasOffset()) {
106105
NextMessageOffset = Settings.GetOffset();
107106
InitialOffset = Settings.GetOffset();
108107
}
109108
Y_UNUSED(TDuration::TryParse(Settings.GetSource().GetReconnectPeriod(), ReconnectPeriod));
109+
auto queryGroup = Counters->GetSubgroup("query_id", ev->Get()->Record.GetQueryId());
110+
auto topicGroup = queryGroup->GetSubgroup("read_group", CleanupCounterValueString(readGroup));
111+
FilteredDataRate = topicGroup->GetCounter("FilteredDataRate", true);
112+
RestartSessionByOffsetsByQuery = counters->GetCounter("RestartSessionByOffsetsByQuery", true);
113+
}
114+
115+
~TClientsInfo() {
116+
Counters->RemoveSubgroup("query_id", Settings.GetQueryId());
110117
}
111118

112119
TActorId GetClientId() const override {
@@ -188,6 +195,7 @@ class TTopicSession : public TActorBootstrapped<TTopicSession> {
188195
// Metrics
189196
ui64 InitialOffset = 0;
190197
TStats Stat; // Send (filtered) to read_actor
198+
const ::NMonitoring::TDynamicCounterPtr Counters;
191199
NMonitoring::TDynamicCounters::TCounterPtr FilteredDataRate; // filtered
192200
NMonitoring::TDynamicCounters::TCounterPtr RestartSessionByOffsetsByQuery;
193201
};
@@ -707,10 +715,7 @@ void TTopicSession::Handle(NFq::TEvRowDispatcher::TEvStartSession::TPtr& ev) {
707715
const TString& format = source.GetFormat();
708716
ITopicFormatHandler::TSettings handlerSettings = {.ParsingFormat = format ? format : "raw"};
709717

710-
auto queryGroup = Counters->GetSubgroup("query_id", ev->Get()->Record.GetQueryId());
711-
auto readGroup = queryGroup->GetSubgroup("read_group", CleanupCounterValueString(ReadGroup));
712-
auto clientInfo = Clients.insert({ev->Sender, MakeIntrusive<TClientsInfo>(*this, LogPrefix, handlerSettings, ev, readGroup)}).first->second;
713-
718+
auto clientInfo = Clients.insert({ev->Sender, MakeIntrusive<TClientsInfo>(*this, LogPrefix, handlerSettings, ev, Counters, ReadGroup)}).first->second;
714719
auto formatIt = FormatHandlers.find(handlerSettings);
715720
if (formatIt == FormatHandlers.end()) {
716721
formatIt = FormatHandlers.insert({handlerSettings, CreateTopicFormatHandler(ActorContext(), FormatHandlerConfig, handlerSettings, Metrics.PartitionGroup)}).first;

ydb/library/yql/providers/pq/async_io/dq_pq_rd_read_actor.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ struct TRowDispatcherReadActorMetrics {
8686
}
8787

8888
~TRowDispatcherReadActorMetrics() {
89-
SubGroup->RemoveSubgroup("id", TxId);
89+
SubGroup->RemoveSubgroup("tx_id", TxId);
9090
}
9191

9292
TString TxId;

ydb/library/yql/providers/pq/async_io/dq_pq_read_actor.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ class TDqPqReadActor : public NActors::TActor<TDqPqReadActor>, public NYql::NDq:
106106
}
107107

108108
~TMetrics() {
109-
SubGroup->RemoveSubgroup("id", TxId);
109+
SubGroup->RemoveSubgroup("tx_id", TxId);
110110
}
111111

112112
TString TxId;

ydb/library/yql/providers/pq/async_io/dq_pq_write_actor.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ class TDqPqWriteActor : public NActors::TActor<TDqPqWriteActor>, public IDqCompu
106106
}
107107

108108
~TMetrics() {
109-
SubGroup->RemoveSubgroup("id", TxId);
109+
SubGroup->RemoveSubgroup("tx_id", TxId);
110110
}
111111

112112
TString TxId;

0 commit comments

Comments
 (0)