Diagnostic Monitor Library

Diagnostic monitors are broadly classified as server-scoped and application-scoped monitors. The former can be used to instrument WebLogic Server classes. You use the latter to instrument application classes. Except for the DyeInjection monitor, all monitors are delegating monitors; that is, they do not have a built-in diagnostic action. Instead, they delegate to actions attached to them to perform diagnostic activity.

All monitors are preconfigured with their respective pointcuts. However, the actual locations affected by them may vary depending on the classes they instrument. For example, the Servlet_Before_Service monitor adds diagnostic code at the entry of servlet or java server page (JSP) service methods at different locations in different servlet implementations.

For any delegating monitor, only compatible actions may be attached. The compatibility is determined by the nature of the monitor.

The following table lists and describes the diagnostic monitors that can be used within server scope; that is, in WebLogic Server classes. For the diagnostic actions that are compatible with each monitor, see the Compatible Action Type column in this table.

At entry and exit of transaction register, unregister, start, rollback and commit methods.

Connector_Before_Work

Before

Stateless

At entry of methods related to scheduling, starting and executing connector work items.

Connector_After_Work

After

Stateless

At exit of methods related to scheduling, starting and executing connector work items.

Connector_Around_Work

Around

Around

At entry and exit of methods related to scheduling, starting and executing connector work items.

DyeInjection

Before

Built-in

At points where requests enter the server.

JDBC_Before_Commit_Internal

Before

Stateless

JDBC subsystem internal code

JDBC_After_Commit_Internal

After

Stateless

JDBC subsystem internal code

JDBC_Before_Connection_

Internal

Before

Stateless

Before calls to methods:

Driver.connect

DataSource.getConnection

JDBC_After_Connection_ Internal

Before

Stateless

JDBC subsystem internal code

JDBC_Before_Rollback_ Internal

Before

Stateless

JDBC subsystem internal code

JDBC_After_Rollback_Internal

After

Stateless

JDBC subsystem internal code

JDBC_Before_Start_Internal

Before

Stateless

JDBC subsystem internal code

JDBC_After_Start_Internal

After

Stateless

JDBC subsystem internal code

JDBC_Before_Statement_

Internal

Before

Stateless

JDBC subsystem internal code

JDBC_After_Statement_

Internal

After

Stateless

JDBC subsystem internal code

JDBC_After_Reserve_Connection_Internal

After

Stateless

After a JDBC connection is reserved from the connection pool.

JDBC_After_Release_Connection_Internal

After

Stateless

After a JDBC connection is released back to the connection pool.

Table B-2 lists the diagnostic monitors that can be used within application scopes; that is, in deployed applications. For the diagnostic actions that are compatible with each monitor, see the Compatible Action Type column in this table.

Table B-2 Diagnostic Monitors for Use Within Application Scopes

Monitor Name

Monitor Type

Compatible Action Type

Pointcuts

EJB_After_EntityEjbBusiness Methods

After

Stateless

At exits of all EntityBean methods, which are not standard ejb methods.

EJB_Around_EntityEjbBusinessMethods

Around

Around

At entry and exits of all EntityBean methods that are not standard ejb methods.

EJB_After_EntityEjbMethods

After

Stateless

At exits of methods:

EnitityBean.setEntityContext

EnitityBean.unsetEntityContext

EnitityBean.ejbRemove

EnitityBean.ejbActivate

EnitityBean.ejbPassivate

EnitityBean.ejbLoad

EnitityBean.ejbStore

EJB_Around_EntityEjbMethods

Around

Around

At exits of methods:

EnitityBean.setEntityContext

EnitityBean.unsetEntityContext

EnitityBean.ejbRemove

EnitityBean.ejbActivate

EnitityBean.ejbPassivate

EnitityBean.ejbLoad

EnitityBean.ejbStore

EJB_After_EntityEjbSemantic Methods

After

Stateless

At exits of methods:

EnitityBean.set*

EnitityBean.get*

EnitityBean.ejbFind*

EnitityBean.ejbHome*

EnitityBean.ejbSelect*

EnitityBean.ejbCreate*

EnitityBean.ejbPostCreate*

EJB_Around_EntityEjbSemanticMethods

Around

Around

At entry and exits of methods:

EnitityBean.set*

EnitityBean.get*

EnitityBean.ejbFind*

EnitityBean.ejbHome*

EnitityBean.ejbSelect*

EnitityBean.ejbCreate*

EnitityBean.ejbPostCreate*

EJB_After_SessionEjbMethods

After

Stateless

At exits of methods:

SessionBean.setSessionContext

SessionBean.ejbRemove

SessionBean.ejbActivate

SessionBean.ejbPassivate

EJB_Around_SessionEjbMethods

Around

Around

At entry and exits of methods:

SessionBean.setSessionContext

SessionBean.ejbRemove

SessionBean.ejbActivate

SessionBean.ejbPassivate

EJB_After_SessionEjbBusinessMethods

After

Stateless

At exits of all SessionBean methods, which are not standard ejb methods.

EJB_Around_SessionEjb

BusinessMethods

Around

Around

At entry and exits of all SessionBean methods, which are not standard ejb methods.

EJB_After_SessionEjbSemanticMethods

After

Stateless

At exits of methods:

SessionBean.ejbCreateSessionBean.ejbPostCreate

EJB_Around_SessionEjb

SemanticMethods

Around

Around

At entry and exits of methods:

SessionBean.ejbCreate

SessionBean.ejbPostCreate

EJB_Before_EntityEjbBusinessMethods

Before

Stateless

At entry of all EntityBean methods, which are not standard ejb methods.

EJB_Before_EntityEjbMethods

Before

Stateless

At entry of methods:

EnitityBean.setEntityContext

EnitityBean.unsetEntityContext

EnitityBean.ejbRemove

EnitityBean.ejbActivate

EnitityBean.ejbPassivate

EnitityBean.ejbLoad

EnitityBean.ejbStore

EJB_Before_EntityEjbSemanticMethods

Before

Stateless

At entry of methods:

EnitityBean.set*

EnitityBean.get*

EnitityBean.ejbFind*

EnitityBean.ejbHome*

EnitityBean.ejbSelect*

EnitityBean.ejbCreate*

EnitityBean.ejbPostCreate*

EJB_Before_SessionEjb

BusinessMethods

Before

Stateless

At entry of all SessionBean methods, which are not standard ejb methods.

EJB_Before_SessionEjbMethods

Before

Stateless

At entry of methods:

SessionBean.setSessionContext

SessionBean.ejbRemove

SessionBean.ejbActivate

SessionBean.ejbPassivate

EJB_Before_SessionEjb

SemanticMethods

Before

Stateless

At entry of methods:

SessionBean.ejbCreate

SessionBean.ejbPostCreate

HttpSessionDebug

Around

Built-in

getSession - Inspects returned HTTP session

Before and after calls to methods:

getAttribute

setAttribute

removeAttribute

At inspection points, the approximate session size is computed and stored as the payload of a generated event. The size is computed by flattening the session to a byte-array. If an error is encountered while flattening the session, a negative size is reported.

These diagnostic actions can be used with the delegating monitors described in the previous tables. They can also be used with custom monitors that you can define and use within applications. Each diagnostic action can only be used with monitors with which they are compatible, as indicated by the Compatible Monitor Type column. Some actions (for example, TraceElapsedTimeAction) generate an event payload.

TraceAction

TraceAction is a stateless action that is compatible with Before and After monitor types.

TraceAction generates a trace event at the affected location in the program execution. The following information is generated:

Timestamp

Context identifier from the diagnostic context which uniquely identifies the request

Transaction identifier, if available

User identity

Action type (that is, TraceAction)

Domain

Server name

Instrumentation scope name (for example, application name)

Diagnostic monitor name

Module name

Location in code from where the action was called. The location consists of:

Class name

Method name

Method signature

Line number

Thread name

Payload carried by the diagnostic context, if any

DisplayArgumentsAction

DisplayArgumentsAction is a stateless action that is compatible with Before and After monitor types.

DisplayArgumentsAction generates an instrumentation event at the affected location in the program execution to capture method arguments or a return value.

When executed, this action causes an instrumentation event that is dispatched to the events archive. When attached to Before monitors, the instrumentation event captures input arguments to the joinpoint (for example, method arguments). When attached to After monitors, the instrumentation event captures the return value from the joinpoint. The event carries the following information:

Timestamp

Context identifier from the diagnostic context that uniquely identifies the request

Transaction identifier, if available

User identity

Action type (that is, DisplayArgumentsAction)

Domain

Server name

Instrumentation scope name (for example, application name)

Diagnostic monitor name

Module name

Location in code from where the action was called. The location consists of:

Class name

Method name

Method signature

Line number

Thread name

Payload carried by the diagnostic context, if any

Input arguments, if any, when attached to Before monitors

Return value, if any, when attached to After monitors

TraceElapsedTimeAction

TraceElapsedTimeAction is an Around action that is compatible with Around monitor types.

TraceElapsedTimeAction generates two events: one before and one after the location in the program execution.

When executed, this action captures the timestamps before and after the execution of an associated joinpoint. It then computes the elapsed time by computing the difference. It generates an instrumentation event which is dispatched to the events archive. The elapsed time is stored as event payload. The event carries the following information:

Timestamp

Context identifier from the diagnostic context that uniquely identifies the request

Transaction identifier, if available

User identity

Action type (that is, TraceElapsedTimeAction)

Domain

Server name

Instrumentation scope name (for example, application name)

Diagnostic monitor name

Module name

Location in code from where the action was called, which consists of:

Class name

Method name

Method signature

Line number

Thread name

Payload carried by the diagnostic context, if any

Elapsed time processing the joinpoint, as event payload, in nanoseconds

TraceMemoryAllocationAction

TraceMemoryAllocationAction uses the JRockit API to trace the number of bytes allocated by a thread during a method call. This action is very similar to TraceElapsedTimeAction, with the exception that the memory allocated within a method call is traced.

The TraceMemoryAllocationAction action:

Creates an instrumentation event that is persisted.

Can be used from delegating and custom monitors.

StackDumpAction

StackDumpAction is a stateless action that is compatible with Before and After monitor types.

StackDumpAction generates an instrumentation event at the affected location in the program execution to capture a stack dump.

When executed, this action generates an instrumentation event which is dispatched to the events archive. It captures the stack trace as an event payload. The event carries following information:

Timestamp

Context identifier from the diagnostic context that uniquely identifies the request

Transaction identifier, if available

User identity

Action type (that is, StackDumpAction)

Domain

Server name

Instrumentation scope name (for example, application name)

Diagnostic monitor name

Module name

Location in code from where the action was called. The location consists of:

Class name

Method name

Method signature

Line number

Thread name

Payload carried by the diagnostic context, if any

Stack trace as an event payload

ThreadDumpAction

ThreadDumpAction is a stateless action that is compatible with Before and After monitor types.

ThreadDumpAction generates an instrumentation event at the affected location in the program execution to capture a thread dump, if the underlying VM supports it. JDK 1.5 (Oracle JRockit and Sun) supports this action.

This action generates an instrumentation event which is dispatched to the events archive. This action may be used only with the JRockit JVM. It is ignored when used with other JVMs. It captures the thread dump as event payload. The event carries the following information:

Timestamp

Context identifier from the diagnostic context that uniquely identifies the request

Transaction identifier, if available

User identity

Action type (that is, ThreadDumpAction)

Domain

Server name

Instrumentation scope name (for example, application name)

Diagnostic monitor name

Module name

Location in code from where the action was called. The location consists of:

Class name

Method name

Method signature

Line number

Thread name

Payload carried by the diagnostic context, if any

Thread dump as an event payload

MethodInvocationStatisticsAction

MethodInvocationStatisticsAction is an Around action that is compatible with Around monitor types.

MethodInvocationStatisticsAction captures performance metrics around a joinpoint in memory without persisting an event in the Archive for each invocation. The statistics are collected and made available through the WLDFInstrumentationRuntimeMBean. The collected statistics are also consumable by the Harvester and the Watch-Notifications components. This makes it possible to create watch rules that can combine request information from the instrumentation system and metric information from other run-time MBeans.

Some of the statistics that can be captured include the following:

Number of invocations

Average execution time (in nanoseconds)

Standard deviation in observed execution time

Minimum execution time

Maximum execution time

The WLDFInstrumentationRuntimeMBean instance for a given scope exposes the data collected from MethodInvocationStatisticsAction instances, which are attached to configured Diagnostic Around monitors, using the MethodInvocationStatistics attribute. The MethodInvocationStatistics attribute contains a hierarchy of Map objects, keyed as shown in Figure B-1:

Because the MethodInvocationStatisticsAction only captures information in memory, and does not persist that information in the Archive, this action does not incur the I/O overhead of other instrumentation actions. This makes this action a lightweight mechanism for capturing performance statistics and helping identify bottlenecks in your application. You can navigate through the map structures and identify the low performing parts of your application.

Instrumenting an Application with MethodInvocationStatisticsAction and Querying the Results

This section shows an example of instrumenting the Avitek Medical Records (MedRec) sample application with a custom monitor that uses MethodInvocationStatisticsAction. This example then shows using WLST online to query the performance statistics that have been collected, which can be done by navigating the WLDFInstrumentationRuntimeMBean instance associated with the instrumented application.

WLST online provides simplified access to MBeans. While JMX APIs require you to use JMX object names to interrogate MBeans, WLST enables you to navigate a hierarchy of MBeans in a similar fashion to navigating a hierarchy of files in a file system. For more information, see "Navigating and Interrogating MBeans" in Oracle WebLogic Scripting Tool.

Code examples demonstrating Java EE APIs and other WebLogic Server features are provided with your WebLogic Server installation. To work with these examples, select the custom installation option when installing WebLogic Server, and select to install the Server Examples. For more information, see "Sample Application and Code Examples" in Information Roadmap for Oracle WebLogic Server .

Configuring the Custom Monitor to Use MethodInvocationStatisticsAction

As of WebLogic Server 10.3, it is no longer necessary to create a weblogic-diagnostics.xml file in the application's META-INF directory to configure a custom monitor. Instead, you can complete all the required steps from the Administration Console, as described in the following steps for instrumenting the MedRec sample application:

In the Domain Structure pane of the Administration Console, select Deployments.

On the Summary of Deployments page, select Control, and click medrec in the Deployments table.

The Settings for medrec page is displayed.

Select Configuration > Instrumentation.

In the Diagnostic Monitors in this Module table, click Add Custom Monitor.

In the Add Custom Monitors page, enter MethodStatsMonitor as the monitor name. Optionally, you can enter a brief description.

In the Update Application Assistant page, select Redeploy this application using the following deployment files.

Click Next, then click Finish.

The MedRec application is now redeployed, and the custom monitor MethodStatsMonitor is active.

Note:

If Java HotSwap is not enabled, to add a new pointcut to the application's configuration, you need to redeploy the application to enable a custom monitor to be woven into the application code. (However, you can modify most of an application's monitor configuration without requiring a redeploy. This includes changes to the custom monitor's Actions, Properties, EnableDyeFiltering, and Description attributes — that is, anything that does not require bytecode weaving.

Using WLST to Query Method Performance Statistics

Once MedRec is redeployed, the MethodInvocationStatisticsAction begins capturing method performance statistics as the instrumented code is executed. This section shows how to generate statistics quickly and simply by navigating the MedRec patient application with the custom monitor enabled. This section then shows how to examine those statistics using WLST online.

To capture method performance statistics using the custom monitor configured for MedRec and query the results using WLST, complete the following steps:

Use the cd command to navigate to the WLDFInstrumentationRuntimeMBean instance associated with the MedRec application:

cd('serverRuntime:/WLDFRuntime/WLDFRuntime/WLDFInstrumentationRuntimes/medrec')
Location changed to serverRuntime tree. This is a read-only tree with ServerRuntimeMBean as the root.
For more help, use help(serverRuntime)

Access specific values collected by MethodInvocationStatisticsAction by invoking the following method on the WLDFInstrumentationRuntimeMBean:

Using WLST interactively, you can pass a lookup expression to this method. The lookup expression specifies the particular subset of values that you are interested in viewing. These values are obtained from the map structure created by MethodInvocationStatisticsAction. For example, the following WLST command returns the average execution time (in nanoseconds) of all methods instrumented by MethodInvocationStatisticsAction:

className represents the fully qualified Java class name. You can use the '*' wildcard character in a class name.

methodName selects a specific method from the given class. You can use the '*' wildcard character in a method name.

methodParamSignature represents a string that is a comma-separated list of a method's input argument types. Only the Java type names are included in the signature specification without the argument names. As in the Java language, the order of the parameters in the signature is significant.

This element also supports the '*' wildcard character, which can be used instead of specifying the entire list of input argument types for a given method. The '*' wildcard character matches zero or more argument types at the position following its occurrence in the methodParamSignature expression.

You can also use the '?' wildcard character to match a single argument type at any given position in the ordered list of parameter types.

Both of these wildcard characters can appear anywhere in the expression. See Table B-3 for examples.

metricName represents the statistics to be harvested. You can use the '*' wildcard character in this key to harvest all of the supported metrics.

Table B-3 shows how the MethodInvocationStatisticsAction instance can be configured to harvest statistics an object named com.Foo.Bar, which has the following overloaded methods:

The min and max execution time for the doNothing() method that has the single input parameter of type com.foo.Baz.

Note:

Using a wildcard character in the className parameter can have an adverse impact on performance.

Configuring Watch Rules Based on MethodInvocationStatistics Metrics

You can use the same syntax described in the previous sections to use MethodInvocationStatistics metrics in a watch rule. You can create meaningful watch rules that do not use a wildcard character in the MetricName element by specifying whether you want the min, max, avg, count, sum, sum_of_squares, or std_deviation variable for a given method.

Using JMX to Collect Data

When using straight JMX to collect data, you can potentially impact server performance if you invoke the getAttribute("MethodInvocationStatistics") method on the WLDFInstrumentationRuntimeMBean. This occurs because, depending on the instrumented classes, the nested map structure can contain a lot of data that involves expensive serialization.

When you use JMX to collect data, Oracle recommends using the getMethodInvocationStatisticsData(String) method.

MethodMemoryAllocationStatisticsAction

The MethodMemoryAllocationStatisticsAction uses the JRockit API to track the number of bytes allocated by a thread during a method call. Statistics are kept in-memory on the memory allocations, and no instrumentation events are created by this action.

The MethodMemoryAllocationStatisticsAction is very similar to the existing MethodInvocationStatisticsAction. However, the statistics tracked by MethodMemoryAllocationStatisticsAction are related to the memory allocated within a method call.

The MethodInvocationStatisticsAction does not create an instrumentation event. When JRockit is available, the statistics are available through the WLDFInstrumentationRuntimeMBean.

The following statistics for each method are kept:

count

min

max

avg

sum

sum_of_squares

std_deviation

Scripting on this page enhances content navigation, but does not change the content in any way.