Interface ConnectionPoolMetrics


@Experimental public interface ConnectionPoolMetrics
Provides connection pool metrics such as connection created, current in use etc. The pool metrics is uniquely identified using id().
  • Method Summary

    Modifier and Type
    Method
    Description
    long
    A counter to record how many connections have been acquired from the pool since the pool is created.
    int
    The number of connection acquisition requests that are currently in progress.
    long
    A counter to record how many connections have been closed by this pool.
    long
    A counter to record how many connections have been successfully created with this pool since the pool was created.
    int
    The amount of connections that are currently in the process of being created.
    long
    A counter to record how many connections that have failed to be created.
    id()
    A unique id that identifies this pool metrics.
    int
    The amount of connections that are currently idle (buffered inside the pool).
    int
    The amount of connections that are currently in-use (borrowed out of the pool).
    long
    A counter to record how many times that we've failed to acquire a connection from the pool within configured maximum acquisition timeout set by Config.ConfigBuilder.withConnectionAcquisitionTimeout(long, TimeUnit).
    long
    A counter to record the total acquisition time in milliseconds of all connection acquisition requests since the pool is created.
    long
    A counter to record the total time in milliseconds spent to establishing new socket connections since the pool is created.
    long
    The total amount of connections that are borrowed outside the pool since the pool is created.
    long
    A counter to record the total time in milliseconds connections are borrowed out of the pool, such as the time spent in user's application code to run cypher queries.
  • Method Details

    • id

      String id()
      A unique id that identifies this pool metrics.
      Returns:
      A unique name
    • inUse

      int inUse()
      The amount of connections that are currently in-use (borrowed out of the pool). The amount can increase or decrease over time.
      Returns:
      The amount of connections that are currently in-use
    • idle

      int idle()
      The amount of connections that are currently idle (buffered inside the pool). The amount can increase or decrease over time.
      Returns:
      The amount of connections that are currently idle.
    • creating

      int creating()
      The amount of connections that are currently in the process of being created. The amount is increased by one when the pool noticed a request to create a new connection. The amount is decreased by one when the pool noticed a new connection is created successfully or failed to create. The amount can increase or decrease over time.
      Returns:
      The amount of connections that are waiting to be created.
    • created

      long created()
      A counter to record how many connections have been successfully created with this pool since the pool was created. This number increases every time when a connection is successfully created.
      Returns:
      The amount of connections that have ever been created by this pool.
    • failedToCreate

      long failedToCreate()
      A counter to record how many connections that have failed to be created. This number increases every time when a connection failed to be created.
      Returns:
      The amount of connections have failed to be created by this pool.
    • closed

      long closed()
      A counter to record how many connections have been closed by this pool. This number increases every time when a connection is closed.
      Returns:
      The amount of connections have been closed by this pool.
    • acquiring

      int acquiring()
      The number of connection acquisition requests that are currently in progress. These requests can be waiting or blocked if there are no connections immediately available in the pool. A request will wait for a new connection to be created, or it will be blocked if the pool is at its maximum size but all connections are already in use. The amount can increase or decrease over time.
      Returns:
      The number of connection acquisition requests that are currently in progress.
    • acquired

      long acquired()
      A counter to record how many connections have been acquired from the pool since the pool is created. This number increases every time when a connection is acquired.
      Returns:
      The amount of connections that have been acquired from the pool.
    • timedOutToAcquire

      long timedOutToAcquire()
      A counter to record how many times that we've failed to acquire a connection from the pool within configured maximum acquisition timeout set by Config.ConfigBuilder.withConnectionAcquisitionTimeout(long, TimeUnit). This number increases every time when a connection is timed out when acquiring.
      Returns:
      The amount of failures to acquire a connection from the pool within maximum connection acquisition timeout.
    • totalAcquisitionTime

      long totalAcquisitionTime()
      A counter to record the total acquisition time in milliseconds of all connection acquisition requests since the pool is created. This number increases every time when a connection is acquired. See acquired() for the total amount of connection acquired since the driver is created. The average acquisition time can be calculated using the code below:

      Example

       
       ConnectionPoolMetrics previous, current;
       ...
       double average = computeAverage(current.totalAcquisitionTime(), previous.totalAcquisitionTime(), current.acquired(), previous.acquired());
       previous = current;
       ...
      
       private static double computeAverage(double currentSum, double previousSum, double currentCount, double previousCount)
       {
           return (currentSum-previousSum)/(currentCount-previousCount);
       }
       
       
      Returns:
      The total acquisition time since the driver is created.
    • totalConnectionTime

      long totalConnectionTime()
      A counter to record the total time in milliseconds spent to establishing new socket connections since the pool is created. This number increases every time when a connection is established. See created() for the total amount of connections established since the pool is created. The average connection time can be calculated using the code below:

      Example

       
       ConnectionPoolMetrics previous, current;
       ...
       double average = computeAverage(current.totalConnectionTime(), previous.totalConnectionTime(), current.created(), previous.created());
       previous = current;
       ...
      
       private static double computeAverage(double currentSum, double previousSum, double currentCount, double previousCount)
       {
           return (currentSum-previousSum)/(currentCount-previousCount);
       }
       
       
      Returns:
      The total connection time since the driver is created.
    • totalInUseTime

      long totalInUseTime()
      A counter to record the total time in milliseconds connections are borrowed out of the pool, such as the time spent in user's application code to run cypher queries. This number increases every time when a connection is returned back to the pool. See totalInUseCount() for the total amount of connections that are borrowed out of the pool. The average in-use time can be calculated using the code below:

      Example

       
       ConnectionPoolMetrics previous, current;
       ...
       double average = computeAverage(current.totalInUseTime(), previous.totalInUseTime(), current.totalInUseCount(), previous.totalInUseCount());
       previous = current;
       ...
      
       private static double computeAverage(double currentSum, double previousSum, double currentCount, double previousCount)
       {
           return (currentSum-previousSum)/(currentCount-previousCount);
       }
       
       
      Returns:
      the total time connections are used outside the pool.
    • totalInUseCount

      long totalInUseCount()
      The total amount of connections that are borrowed outside the pool since the pool is created. This number increases every time when a connection is returned back to the pool.
      Returns:
      the total amount of connection that are borrowed outside the pool.