Need to track how long Java request thread holds Maria DB connection thread?

We have a java application based on Spring MVC framework. We are using MariaDB as our datastore. We are using one db connection per thread. We want to have metrics when a request thread actually acquires a db connection & when it goes back to db connection pool. Please let us know if you know way to do that.

Not sure if you are using Hibernate as ORM. If yes, then take a look at this page. In case you are using simple JDBC, I am not sure about the pattern. But I guess JDBC driver would have some kind of pattern that gets printed at least in debug level.

1 Like

This helps. We do use Hibernate except a few cases. Let us see how we can use this pattern & incorporate it in our ELK stack. Thank you.

1 Like