Instrumentation for ConnectionPool

Connection Pool , including JDBC and redis, i think it's necessary to record that how long it takes to get a connection from connection pool. What's more, metrics about connection pool, for example active connection num, idle connection num, max total num , they are useful to anaylize the performnce of the application.

The question is that how can i acheive the goals above by the current java agent?

Hi @CoderLan,

Does the connection pool you are currently using provides monitoring metrics through JMX ?
If yes (and most of them do), that means that you should be able to track those metrics through capture_jmx_metrics configuration option.

APM agent does not collect the time to get a connection from pool, this metric is often used as a proxy to know if the pool (or the backend server) is under pressure or not. However, with proper monitoring of the pool state itself, it should not be required.

@Sylvain_Juge

As the pool is under pressure, the request will takes a long time, if the span of getting connection from pool is miss, the timeline of this transaction will confuse the developers, they don't know what's the performance problem, util they analyze the metrics of the pool.

So, is it helpful?

I see, so if I understand correctly:

  • there is no dedicated span for the "get connection from pool" in transaction timeline
  • unless watching pool metrics, it's not really obvious that the issue is around DB pool (and/or DB server)

Thus in other words, providing a way to capture "how much time is spent waiting for connection" maybe as a span in transaction timeline would make it easier, right ?

Yes, that's it.

Ok, so we already have an issue (#941) to implement this, so it's not covered yet.

However, agent now includes a sampling profiler that allows to create inferred spans automatically for slow methods. Here are a few links to know more and to how to use it:

@Sylvain_Juge

I'm sure that the jmx metrics has been reported to the apm server, but i can not find any charts of these jmx metrics in kibana, where can i get it?

There is no pre-defined chart for JMX metrics, mostly because that requires some knowledge about what is measured.

The easiest way is to use Lens or TSVB (Time Series Visualization Builder) in Kibana to create those.

One thing to know is that those metrics aren't included in KQL auto-completion by default. You have to use "refresh field list" icon in top right of "Index Patterns" section (between star and delete icon), here is a screenshot with version 7.8:

This topic was automatically closed 20 days after the last reply. New replies are no longer allowed.