I've modify the patch to address most of your comments.
> I have a thought about other possible improvements fitting to this patch.
> I think pg_stat_session view is able to add one more dimension of monitoring - a dimension of sessions
I would like to remind here about the initial scope of this patch. The main goal of it was to ease tracking "idle in transactions" connections, a feature that would really help in my work. The "pg_stat_session" came into play only because the "pg_stat_activity" was seen as an unsuitable place for the relevant counters. With that I still would like to maintaint the focus on committing the "idle in transactions" part of pg_stat_session first.