Record per-thread connection metrics in database sampler

What does this MR do and why?

Adds a thread_name label to gitlab_database_connection_pool_dead / _busy metrics, to help diagnose which threads are holding on to database connections.

References

Screenshots or screen recordings

Prometheus metrics exported from a local GDK after clicking around a few issues and opening several tabs.

You can see busy connections taken by various background threads, a blip when puma workers check out connections, and a large number of worker threads holding on to connections. As time passes, the connections from the worker threads become dead. (These threads are from an actioncable thread pool that doesn't properly check back in connections, fix in a different MR).

gitlab_database_connection_pool_busy over time

image

gitlab_database_connection_pool_dead over time

image

How to set up and validate locally

MR acceptance checklist

Evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.

Edited by Simon Tomlinson

Merge request reports

Loading