Skip to content

Collect idle_in_transaction_time from PG >= 15 #1075

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

ajmaidak
Copy link

idle_in_transaction_time was added to pg_stat_database in pg 15

https://www.postgresql.org/docs/15/monitoring-stats.html#MONITORING-PG-STAT-DATABASE-VIEW

idle_in_transaction_time was added to pg_stat_database in pg 15

Signed-off-by: Alexander J. Maidak <amaidak@equinix.com>
@ajmaidak ajmaidak force-pushed the add-idle-trx-time-metric branch from b262eec to 69c4119 Compare October 17, 2024 18:15
@@ -375,6 +393,11 @@ func (c *PGStatDatabaseCollector) Update(ctx context.Context, instance *instance
continue
}

if idleInTransactionTimeAvail && !idleInTransactionTime.Valid {
level.Debug(c.log).Log("msg", "Skipping collecting metric because it has no idle_in_transaction_time")
continue
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think this needs to skip the whole row in this case. I think this logic can be to skip sending the metric to the channel down on line 540 instead. I know the logic above is this way, but I think technically this addition could break things for other users if this field is NULL, so I want to avoid that.

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants