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
292303void 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
396407void TRowDispatcher::Handle (NFq::TEvRowDispatcher::TEvStartSession::TPtr& ev) {
@@ -632,10 +643,22 @@ void TRowDispatcher::Handle(NFq::TEvPrivate::TEvUpdateMetrics::TPtr&) {
632643}
633644
634645void 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+
639662void TRowDispatcher::Handle (NFq::TEvRowDispatcher::TEvSessionStatistic::TPtr& ev) {
640663 LOG_ROW_DISPATCHER_TRACE (" TEvSessionStatistic from " << ev->Sender );
641664 const auto & key = ev->Get ()->Stat .SessionKey ;
0 commit comments