Collectors are final objects receiving (fully processed) and presenting them in some way or performing real actions. There is a generic method toCollector()
that allows attaching custom collectors (including beanshell scripts). There is also a set of convenience methods useful to configure collector quickly:
Collecting to Zorka Stats
spy.zorkaStats(mbsName, beanName, attrName, keyExpr)
spy.zorkaStats(mbsName, beanName, attrName, keyExpr, actions)
spy.zorkaStats(mbsName, beanName, attrName, keyExpr, timeField)
spy.zorkaStats(mbsName, beanName, attrName, keyExpr, timeField, actions)
This is collect method call statistics in ZorkaStats
object visible via JMX as an attribute of some MBean
. Method arguments:
mbsName
- mbean server name (typicallyjava
but you can use other mbean servers if accessible, for examplejboss
);beanName
- mbean name (in standard JMX form:domain:attr1=val1,attr2=val2,...
);attrName
- attribute name as whichZorkaStats
object will be visible;keyExpr
- value used as key inZorkaStats
(which is a kind of dictionary object containing statistics for manyother methods);timeField
- indicates field that stores method execution time; if not passed, default nameT
fill be used;actions
- determines what should be done when aggregating data:spy.ACTION_STATS
will cause standard call statisticsto be updated (number of calls, errors, execution time) this should be used in.onSubmit()
processing chain;spy.ACTION_ENTER
andspy.ACTION_EXIT
is used for contention monitoring (i.e. number of threads concurrently callinggiven method) -spy.ACTION_ENTER
action should be used in.onEnter()
chain andspy.ACTION_EXIT
should be used at.onSubmit()
processing chain;
It is possible to use substitution variables in beanName
, attrName
and keyExpr
:
${className}
- will be substituted with fully qualified class name;${shortClassName}
- will be substituted with short class name (without package);${packageName}
- package name of instrumented class;${methodName}
- will be substituted with method name;
In addition keyExpr
can contain expressions fetching record arguments ${FUEKD.attr1.attr2...}
the same form as in spy.format()
function.
It is also possible to attach single-method call statistic directly as mbean attribute:
Intercepting and presenting objects via Zorka Getter
Presenting intercepted values as mbean attributes is possible with toGetter()
method:
spy.toGetter(mbsName, beanName, attrName, attr1, attr2, ...)
This will present intercepted object as ValGetter attribute. Each time attribute is accessed (eg. via jconsole), Zorka will fetch value using attribute chain (attr1, attr2, ...)
as in zorka.jmx()
call.