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.ConnectionEvent
-
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.voidbegin(Metrics.ConnectionEvent event, int retryIdentifier)Driver retries some events like 'Generate PK', 'SSL Renegotiation Receive', 'SSL Renegotiation RunTasks'.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)voidend(Metrics.ConnectionEvent event, int retryIdentifier)Driver retries some events like 'Generate PK', 'SSL Renegotiation Receive', 'SSL Renegotiation RunTasks'.static java.lang.StringgetReport(java.util.concurrent.TimeUnit timeUnit)Returns the collected metrics.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.
-
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)
-
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.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
-
-