pg_stat_activity
holds extremely useful information for post-mortem analysis of various issues, especially concurrency-related, and so augmenting errors or logging with this data (properly filtered and correlated) is invaluable. However querying it requires getting a database connection which might be in short supply at the very moment it's most needed.
Is there a side-channel of some sort which would allow getting that information without the additional database connection?
Not really, but the parameter
superuser_reserved_connections
will help you. It defines the number of connections that are reserved for superusers precisely so that they can still connect, even if the connection limit is exhausted.Set the value high enough and have your monitoring process connect as superuser.