Class Metrics

  • Direct Known Subclasses:
    MetricsImpl

    public class Metrics
    extends java.lang.Object

    The metrics of events that occur while establishing Connections to the Oracle database.

    Capturing metrics can be enabled globally by calling enable(boolean). When enabled, the metrics of live connections' phases are captured, and aggregated on Connection#close().

    To print the aggregation of metrics, of all connections that were established and closed in this JVM process, to the OutputStream, call print(OutputStream, TimeUnit).

    To disable capturing of metrics, call enable(boolean).

    Metrics can also be enabled or disabled globally using the MBean operations. See DiagnosticsMXBean.enableMetrics() and DiagnosticsMXBean.disableMetrics().

    Metrics can be enabled at connection level using the property OracleConnection.CONNECTION_PROPERTY_ENABLE_METRICS.

    • Constructor Summary

      Constructors 
      Constructor Description
      Metrics()  
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      protected void add​(java.util.Map<java.lang.String,​long[]> connectionMetricsMap)
      The metrics of connection are added to the consolidated data.
      void begin​(Metrics.ConnectionEvent event)
      All begin and end calls are noop in this class because this class is instantiated when metrics capturing is disabled.
      void begin​(Metrics.ConnectionEvent event, int retryIdentifier)
      Driver retries some events like 'Generate PK', 'SSL Renegotiation Receive', 'SSL Renegotiation RunTasks'.
      static void clear()
      Clear the metrics of events captured by the JDBC driver.
      void close()  
      static void enable​(boolean isEnabled)
      Switch to turn metrics on or off programmatically.
      void end​(Metrics.ConnectionEvent event)  
      void end​(Metrics.ConnectionEvent event, int retryIdentifier)
      Driver retries some events like 'Generate PK', 'SSL Renegotiation Receive', 'SSL Renegotiation RunTasks'.
      static java.lang.String getReport​(java.util.concurrent.TimeUnit timeUnit)
      Returns the collected metrics.
      static void print​(java.io.OutputStream outputStream, java.util.concurrent.TimeUnit timeUnit)
      Prints the aggregation of metrics, of all connections that were established and closed in this JVM process, to the given OutputStream.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • Metrics

        public Metrics()
    • Method Detail

      • enable

        public static void enable​(boolean isEnabled)
        Switch to turn metrics on or off programmatically.
        Parameters:
        isEnabled -
      • begin

        public void begin​(Metrics.ConnectionEvent event)
        All begin and end calls are noop in this class because this class is instantiated when metrics capturing is disabled. The subclass of this is instantiated when metrics capturing is enabled. This is to avoid 'is capturing metrics enabled' checks in begin and end methods.
      • begin

        public void begin​(Metrics.ConnectionEvent event,
                          int retryIdentifier)
        Driver retries some events like 'Generate PK', 'SSL Renegotiation Receive', 'SSL Renegotiation RunTasks'. The begin and end calls put those retried events in the consolidated metric map with key as event name suffixed by retry identifier. E.g. 'Generate PK 1', 'SSL Renegotiation Receive 1'. For the cases where there is no retry, there won't be any suffix .
        Parameters:
        event -
        retryIdentifier -
      • end

        public void end​(Metrics.ConnectionEvent event,
                        int retryIdentifier)
        Driver retries some events like 'Generate PK', 'SSL Renegotiation Receive', 'SSL Renegotiation RunTasks'. The begin and end calls put those retried events in the consolidated metric map with key as event name suffixed by retry identifier. E.g. 'Generate PK 1', 'SSL Renegotiation Receive 1'. For the cases where there is no retry, there won't be any suffix .
        Parameters:
        event -
        retryIdentifier -
      • close

        public void close()
      • add

        protected void add​(java.util.Map<java.lang.String,​long[]> connectionMetricsMap)
        The metrics of connection are added to the consolidated data.
        Parameters:
        connectionMetricsMap -
      • clear

        public static void clear()
        Clear the metrics of events captured by the JDBC driver.
      • getReport

        public static java.lang.String getReport​(java.util.concurrent.TimeUnit timeUnit)
        Returns the collected metrics.
        Parameters:
        timeUnit -
        Returns:
        metrics
      • print

        public static void print​(java.io.OutputStream outputStream,
                                 java.util.concurrent.TimeUnit timeUnit)
                          throws java.io.IOException

        Prints the aggregation of metrics, of all connections that were established and closed in this JVM process, to the given OutputStream.

        The metrics of live connections are aggregated only on Connection#close().

        Parameters:
        outputStream -
        timeUnit -
        Throws:
        java.io.IOException