JBoss Community Archive (Read Only)

RHQ 4.9

Hibernate - Statistics Service

Hibernate - Statistics Service

Overview

Internal Name:

Hibernate Statistics

Description:

Statistics for Hibernate

Singleton:

no

Plugin:

Hibernate

Managed Resource Configuration

In order to monitor Hibernate statistics via JON, the Hibernate Session Manager MBean
must be deployed to an object name of the format
"Hibernate:application=%application%,type=statistics", and statistics must be enabled.

Some example code is provided below to register the Hibernate Session MBean within an EJB3 application.

public static void enableHibernateStatistics(EntityManager entityManager)
{
try
{
StatisticsService mBean = new StatisticsService();
SessionFactory sessionFactory = getHibernateSession(entityManager).getSessionFactory();
mBean.setSessionFactory(sessionFactory);
ObjectName objectName = new ObjectName(HIBERNATE_STATISTICS_MBEAN_OBJECTNAME);
MBeanServer jbossMBeanServer = getJBossMBeanServer();
jbossMBeanServer.registerMBean(mBean, objectName);
sessionFactory.getStatistics().setStatisticsEnabled(true);
}
catch (InstanceAlreadyExistsException iaee)
{
LOG.info("Duplicate MBean registration ignored: " + HIBERNATE_STATISTICS_MBEAN_OBJECTNAME);
}
catch (Exception e)
{
LOG.warn("Couldn't register Hibernate statistics MBean.", e);
}
}

private static Session getHibernateSession(EntityManager entityManager) {
Session session;
if (entityManager.getDelegate() instanceof EntityManagerImpl) {
EntityManagerImpl entityManagerImpl = (EntityManagerImpl) entityManager.getDelegate();
session = entityManagerImpl.getSession();
} else {
session = (Session) entityManager.getDelegate();
}
return session;
}

private static MBeanServer getJBossMBeanServer() {
List<MBeanServer> servers = MBeanServerFactory.findMBeanServer(null);
MBeanServer jbossServer = null;
for (MBeanServer server : servers) {
if ("jboss".equals(server.getDefaultDomain())) {
jbossServer = server;
}
}
if (jbossServer == null) {
jbossServer = ManagementFactory.getPlatformMBeanServer();
}
return jbossServer;
}

See also Publishing statistics through JMX and
Enabling Hibernate statistics

Child Resource Types

Connection Settings

Name

Description

Required

Internal Name

Object Name

 

yes

objectName

Name Template

 

yes

nameTemplate

Description Template

 

yes

descriptionTemplate

Application

the Hibernate application name

yes

application

You must use the internal name to reference properties in Dynamic Group Definition expressions.

Metrics

Name

Type

Description

Internal Name

Entity Insert Count

measurement

The global number of entity inserts since the statistics were reset

EntityInsertCount

Entity Insert Count per Minute

measurement

The global number of entity inserts since the statistics were reset

EntityInsertCount

Query Execution Max Time

measurement

The amount of time taken by the slowest recorded query since the statistics were reset

QueryExecutionMaxTime

Entity Update Count

measurement

The global number of entity updates since the statistics were reset

EntityUpdateCount

Entity Update Count per Minute

measurement

The global number of entity updates since the statistics were reset

EntityUpdateCount

Collection Update Count

measurement

The global number of collections updated since the statistics were reset

CollectionUpdateCount

Collection Update Count per Minute

measurement

The global number of collections updated since the statistics were reset

CollectionUpdateCount

Entity Load Count

measurement

The global number of entity loads since the statistics were reset

EntityLoadCount

Entity Load Count per Minute

measurement

The global number of entity loads since the statistics were reset

EntityLoadCount

Entity Fetch Count

measurement

The global number of entity fetches since the statistics were reset

EntityFetchCount

Entity Fetch Count per Minute

measurement

The global number of entity fetches since the statistics were reset

EntityFetchCount

Entity Delete Count

measurement

The global number of entity deletes since the statistics were reset

EntityDeleteCount

Entity Delete Count per Minute

measurement

The global number of entity deletes since the statistics were reset

EntityDeleteCount

Collection Recreate Count

measurement

The global number of collections recreated since the statistics were reset

CollectionRecreateCount

Collection Recreate Count per Minute

measurement

The global number of collections recreated since the statistics were reset

CollectionRecreateCount

Query Execution Count

measurement

The global number of queries executed since the statistics were reset

QueryExecutionCount

Query Execution Count per Minute

measurement

The global number of queries executed since the statistics were reset

QueryExecutionCount

Flush Count

measurement

The global number of flushes executed by sessions (either implicit or explicit) since the statistics were reset

FlushCount

Flush Count per Minute

measurement

The global number of flushes executed by sessions (either implicit or explicit) since the statistics were reset

FlushCount

Collection Load Count

measurement

The global number of collections loaded since the statistics were reset

CollectionLoadCount

Collection Load Count per Minute

measurement

The global number of collections loaded since the statistics were reset

CollectionLoadCount

Successful Transaction Count

measurement

The global number of transactions known to have been successful since the statistics were reset

SuccessfulTransactionCount

Successful Transaction Count per Minute

measurement

The global number of transactions known to have been successful since the statistics were reset

SuccessfulTransactionCount

Query Cache Hit Count

measurement

The global number of cached queries successfully retrieved from cache since the statistics were reset

QueryCacheHitCount

Query Cache Hit Count per Minute

measurement

The global number of cached queries successfully retrieved from cache since the statistics were reset

QueryCacheHitCount

Collection Remove Count

measurement

The global number of collections removed since the statistics were reset

CollectionRemoveCount

Collection Remove Count per Minute

measurement

The global number of collections removed since the statistics were reset

CollectionRemoveCount

Connect Count

measurement

The global number of connections asked by the sessions (the actual number of connections used may be much smaller depending whether you use a connection pool or not) since the statistics were reset

ConnectCount

Connect Count per Minute

measurement

The global number of connections asked by the sessions (the actual number of connections used may be much smaller depending whether you use a connection pool or not) since the statistics were reset

ConnectCount

Start Time

trait

The time when the statistics collection started or were last reset

StartTime

Second Level Cache Put Count

measurement

The global number of cacheable entities/collections put in the cache since the statistics were reset

SecondLevelCachePutCount

Second Level Cache Put Count per Minute

measurement

The global number of cacheable entities/collections put in the cache since the statistics were reset

SecondLevelCachePutCount

Query Cache Put Count

measurement

The global number of cacheable queries put in cache since the statistics were reset

QueryCachePutCount

Query Cache Put Count per Minute

measurement

The global number of cacheable queries put in cache since the statistics were reset

QueryCachePutCount

Session Open Count

measurement

The global number of sessions closed since the statistics were reset

SessionOpenCount

Session Open Count per Minute

measurement

The global number of sessions closed since the statistics were reset

SessionOpenCount

Transaction Count

measurement

The global number of transactions known to have completed since the statistics were reset

TransactionCount

Transaction Count per Minute

measurement

The global number of transactions known to have completed since the statistics were reset

TransactionCount

Collection Fetch Count

measurement

The global number of collections fetched since the statistics were reset

CollectionFetchCount

Collection Fetch Count per Minute

measurement

The global number of collections fetched since the statistics were reset

CollectionFetchCount

Session Close Count

measurement

The global number of sessions closed since the statistics were reset

SessionCloseCount

Session Close Count per Minute

measurement

The global number of sessions closed since the statistics were reset

SessionCloseCount

Query Cache Miss Count

measurement

The global number of cached queries *not* found in cache since the statistics were reset

QueryCacheMissCount

Query Cache Miss Count per Minute

measurement

The global number of cached queries *not* found in cache since the statistics were reset

QueryCacheMissCount

Second Level Cache Miss Count

measurement

The global number of cacheable entities/collections not found in the cache and loaded from the database since the statistics were reset

SecondLevelCacheMissCount

Second Level Cache Miss Count per Minute

measurement

The global number of cacheable entities/collections not found in the cache and loaded from the database since the statistics were reset

SecondLevelCacheMissCount

You must use the internal name to reference traits in Dynamic Group Definition expressions.

Operations

Name

Description

Clear Statistics

Clear the collected statistics and begin collecting again

View Queries

View statistical information about queries executed by Hibernate

JBoss.org Content Archive (Read Only), exported from JBoss Community Documentation Editor at 2020-03-13 08:22:56 UTC, last content change 2013-09-18 19:43:19 UTC.