@@ -281,7 +281,7 @@ millisecs_diff(TimestampTz tz1, TimestampTz tz2)
281281void
282282collector_main (Datum main_arg )
283283{
284- HTAB * profile_hash = NULL ;
284+ HTAB * profile_hash = NULL ;
285285 History observations ;
286286 MemoryContext old_context ,
287287 collector_context ;
@@ -302,6 +302,12 @@ collector_main(Datum main_arg)
302302 pqsignal (SIGTERM , handle_sigterm );
303303 BackgroundWorkerUnblockSignals ();
304304
305+ InitPostgres (NULL , InvalidOid , NULL , InvalidOid , NULL , false);
306+ SetProcessingMode (NormalProcessing );
307+
308+ /* Make pg_wait_sampling recognisable in pg_stat_activity */
309+ pgstat_report_appname ("pg_wait_sampling collector" );
310+
305311 profile_hash = make_profile_hash ();
306312 collector_hdr -> latch = & MyProc -> procLatch ;
307313
@@ -312,6 +318,8 @@ collector_main(Datum main_arg)
312318 alloc_history (& observations , collector_hdr -> historySize );
313319 MemoryContextSwitchTo (old_context );
314320
321+ ereport (LOG , (errmsg ("pg_wait_sampling collector started" )));
322+
315323 /* Start counting time for history and profile samples */
316324 profile_ts = history_ts = GetCurrentTimestamp ();
317325
@@ -430,5 +438,6 @@ collector_main(Datum main_arg)
430438 * on_dsm_detach callbacks we've registered, as well. Once that's done,
431439 * we can go ahead and exit.
432440 */
441+ ereport (LOG , (errmsg ("pg_wait_sampling collector shutting down" )));
433442 proc_exit (0 );
434443}
0 commit comments