public class Metrics
extends java.lang.Object
The metrics of events that occur while establishing Connection
s
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
.
Modifier and Type | Class and Description |
---|---|
static class |
Metrics.ConnectionEvent |
static class |
Metrics.MetricReport
POJO used to expose metrics basic details
|
Constructor and Description |
---|
Metrics() |
Modifier and Type | Method and 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.
|
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) |
static Metrics.MetricReport |
getReport(Metrics.ConnectionEvent event)
Gets metric report.
|
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 . |
public static void enable(boolean isEnabled)
isEnabled
- public void begin(Metrics.ConnectionEvent event)
public void end(Metrics.ConnectionEvent event)
public void close()
protected void add(java.util.Map<java.lang.String,long[]> connectionMetricsMap)
connectionMetricsMap
- public static void clear()
public static Metrics.MetricReport getReport(Metrics.ConnectionEvent event)
event
- the metric to get report of.MetricReport
the report of that metric. Can be null.public static java.lang.String getReport(java.util.concurrent.TimeUnit timeUnit)
timeUnit
- 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()
.
outputStream
- timeUnit
- java.io.IOException