Skip to content

Commit e2103f9

Browse files
authored
mon page has been added to row dispatcher (#11443)
1 parent a27ab2e commit e2103f9

File tree

2 files changed

+29
-4
lines changed

2 files changed

+29
-4
lines changed

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

Lines changed: 27 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,10 @@
99
#include <ydb/library/yql/providers/dq/counters/counters.h>
1010
#include <ydb/library/yql/public/purecalc/common/interface.h>
1111

12+
#include <ydb/core/base/appdata_fwd.h>
1213
#include <ydb/core/fq/libs/actors/logging/log.h>
1314
#include <ydb/core/fq/libs/events/events.h>
15+
#include <ydb/core/mon/mon.h>
1416

1517
#include <ydb/core/fq/libs/row_dispatcher/actors_factory.h>
1618
#include <ydb/core/fq/libs/row_dispatcher/events/data_plane.h>
@@ -223,11 +225,12 @@ class TRowDispatcher : public TActorBootstrapped<TRowDispatcher> {
223225
void Handle(const NYql::NDq::TEvRetryQueuePrivate::TEvSessionClosed::TPtr&);
224226
void Handle(NFq::TEvPrivate::TEvUpdateMetrics::TPtr&);
225227
void Handle(NFq::TEvPrivate::TEvPrintStateToLog::TPtr&);
228+
void Handle(const NMon::TEvHttpInfo::TPtr&);
226229

227230
void DeleteConsumer(const ConsumerSessionKey& key);
228231
void UpdateInterconnectSessions(const NActors::TActorId& interconnectSession);
229232
void UpdateMetrics();
230-
void PrintInternalState();
233+
TString GetInternalState();
231234

232235
STRICT_STFUNC(
233236
StateFunc, {
@@ -252,6 +255,7 @@ class TRowDispatcher : public TActorBootstrapped<TRowDispatcher> {
252255
hFunc(NFq::TEvRowDispatcher::TEvNewDataArrived, Handle);
253256
hFunc(NFq::TEvPrivate::TEvUpdateMetrics, Handle);
254257
hFunc(NFq::TEvPrivate::TEvPrintStateToLog, Handle);
258+
hFunc(NMon::TEvHttpInfo, Handle);
255259
})
256260
};
257261

@@ -287,6 +291,13 @@ void TRowDispatcher::Bootstrap() {
287291
Schedule(TDuration::Seconds(CoordinatorPingPeriodSec), new TEvPrivate::TEvCoordinatorPing());
288292
Schedule(TDuration::Seconds(UpdateMetricsPeriodSec), new NFq::TEvPrivate::TEvUpdateMetrics());
289293
Schedule(TDuration::Seconds(PrintStateToLogPeriodSec), new NFq::TEvPrivate::TEvPrintStateToLog());
294+
295+
NActors::TMon* mon = NKikimr::AppData()->Mon;
296+
if (mon) {
297+
::NMonitoring::TIndexMonPage* actorsMonPage = mon->RegisterIndexPage("actors", "Actors");
298+
mon->RegisterActorPage(actorsMonPage, "row_dispatcher", "Row Dispatcher", false,
299+
TlsActivationContext->ExecutorThread.ActorSystem, SelfId());
300+
}
290301
}
291302

292303
void TRowDispatcher::Handle(NFq::TEvRowDispatcher::TEvCoordinatorChanged::TPtr& ev) {
@@ -372,7 +383,7 @@ void TRowDispatcher::UpdateMetrics() {
372383
}
373384
}
374385

375-
void TRowDispatcher::PrintInternalState() {
386+
TString TRowDispatcher::GetInternalState() {
376387
TStringStream str;
377388
str << "Statistics:\n";
378389
for (auto& [key, sessionsInfo] : TopicSessions) {
@@ -390,7 +401,7 @@ void TRowDispatcher::PrintInternalState() {
390401
}
391402
}
392403
}
393-
LOG_ROW_DISPATCHER_DEBUG(str.Str());
404+
return str.Str();
394405
}
395406

396407
void TRowDispatcher::Handle(NFq::TEvRowDispatcher::TEvStartSession::TPtr& ev) {
@@ -632,10 +643,22 @@ void TRowDispatcher::Handle(NFq::TEvPrivate::TEvUpdateMetrics::TPtr&) {
632643
}
633644

634645
void TRowDispatcher::Handle(NFq::TEvPrivate::TEvPrintStateToLog::TPtr&) {
635-
PrintInternalState();
646+
LOG_ROW_DISPATCHER_DEBUG(GetInternalState());
636647
Schedule(TDuration::Seconds(PrintStateToLogPeriodSec), new NFq::TEvPrivate::TEvPrintStateToLog());
637648
}
638649

650+
void TRowDispatcher::Handle(const NMon::TEvHttpInfo::TPtr& ev) {
651+
TStringStream str;
652+
HTML(str) {
653+
PRE() {
654+
str << "Current state:" << Endl;
655+
str << GetInternalState() << Endl;
656+
str << Endl;
657+
}
658+
}
659+
Send(ev->Sender, new NMon::TEvHttpInfoRes(str.Str()));
660+
}
661+
639662
void TRowDispatcher::Handle(NFq::TEvRowDispatcher::TEvSessionStatistic::TPtr& ev) {
640663
LOG_ROW_DISPATCHER_TRACE("TEvSessionStatistic from " << ev->Sender);
641664
const auto& key = ev->Get()->Stat.SessionKey;

ydb/core/fq/libs/row_dispatcher/ya.make

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,13 @@ SRCS(
1414
PEERDIR(
1515
contrib/libs/fmt
1616
contrib/libs/simdjson
17+
ydb/core/base
1718
ydb/core/fq/libs/actors/logging
1819
ydb/core/fq/libs/config/protos
1920
ydb/core/fq/libs/row_dispatcher/events
2021
ydb/core/fq/libs/shared_resources
2122
ydb/core/fq/libs/ydb
23+
ydb/core/mon
2224
ydb/library/actors/core
2325
ydb/library/security
2426
ydb/library/yql/dq/actors/common

0 commit comments

Comments
 (0)