Class Metrics
- java.lang.Object
-
- oracle.jdbc.diagnostics.Metrics
-
- Direct Known Subclasses:
MetricsImpl
public class Metrics extends java.lang.ObjectThe 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 onConnection#close().To print the aggregation of metrics, of all connections that were established and closed in this JVM process, to the
OutputStream, callprint(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()andDiagnosticsMXBean.disableMetrics().Metrics can be enabled at connection level using the property
OracleConnection.CONNECTION_PROPERTY_ENABLE_METRICS.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classMetrics.ConnectionEventstatic classMetrics.MetricReportPOJO used to expose metrics basic details
-
Constructor Summary
Constructors Constructor Description Metrics()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description protected voidadd(java.util.Map<java.lang.String,long[]> connectionMetricsMap)The metrics of connection are added to the consolidated data.voidbegin(Metrics.ConnectionEvent event)All begin and end calls are noop in this class because this class is instantiated when metrics capturing is disabled.static voidclear()Clear the metrics of events captured by the JDBC driver.voidclose()static voidenable(boolean isEnabled)Switch to turn metrics on or off programmatically.voidend(Metrics.ConnectionEvent event)static java.lang.StringgetReport(java.util.concurrent.TimeUnit timeUnit)Returns the collected metrics.static Metrics.MetricReportgetReport(Metrics.ConnectionEvent event)Gets metric report.static voidprint(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 givenOutputStream.
-
-
-
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.
-
end
public void end(Metrics.ConnectionEvent event)
-
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 Metrics.MetricReport getReport(Metrics.ConnectionEvent event)
Gets metric report.- Parameters:
event- the metric to get report of.- Returns:
MetricReportthe report of that metric. Can be null.
-
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.IOExceptionPrints 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
-
-