cayenne-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Andrus Adamchik <>
Subject Re: Stat gathering
Date Mon, 14 May 2012 07:56:48 GMT

On May 9, 2012, at 8:28 PM, Ramiro Aparicio wrote:

> Hi,
> I am trying to figure some way to get the number or queries and time elapsed in a DataContext,
or something similar, I want to get agregate data about DB performance and be able to find
where we should try to reduce the number of DB queries.
> I thought I could use some kind of ServletFilter to get the data and post back as headers
or something like that, but I don't se anywhere how I can get this information, the best I
can see is that all that information is logged but not agregated, so maybe I could create
a custom QueryLogger, but I can not see any way to inject a custom QueryLogger either so I
am lost.
> Maybe this is a marginal use case but I think this is a interesting feature for everyone
using Cayenne in production enviroments to gather information without having to parse the
> Ramiro Aparicio


I wanted to create some JMX hooks to Cayenne for a long time. Unfortunately never got around
to actually doing it. For now, as Mike have mentioned you can plug custom appenders to Log4J.
If you are on Cayenne 3.1, you also have a few more good extension points to monitor Cayenne

1. QueryLogger is called JdbcEventLogger in 3.1. It is defined in ServerModule:


A custom implementation class can be defined in your own module.

2. There's also DataChannelFilter which is a concept very close to ServletFilter, except that
it filters all traffic between a DataContext and its parent DataDomain. So you can analyze
every select and commit. Registering a custom filter is done either via DI, or directly in
the code:

DataChannelFilter filter = new MyDataChannelFilter();
ServerRuntime runtime = ...
DataDomain domain = runtime.getDataDomain();


View raw message