Skip to content

Commit 6462bcd

Browse files
committed
Prepare 0.7 release.
1 parent 5f238b6 commit 6462bcd

File tree

22 files changed

+162
-248
lines changed

22 files changed

+162
-248
lines changed

CHANGES.md

+15
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,18 @@
1+
Zorka 0.7 (2013-01-06)
2+
----------------------
3+
4+
* refactor spy API to use string keys (instead of convoluted stage-slot convention);
5+
* get rid od ON_COLLECT stage, use asynchronous queue collector;
6+
* refactor logger to act as aggregator of (attachable) trappers, remove loggger <-> file trapper redundancies;
7+
* lots of redundant code eliminated (eg. threading code in trappers, rank listers, agent integrations etc.)
8+
* lots of cleanups, javadocs, bugfixes, simplify package structure and limit inter-package dependencies;
9+
* performance optimization of ZorkaStatsCollector (and removal of JmxAttrCollector);
10+
* rudimentary stress testing / microbenchmarking framework implemented;
11+
* spy now supports OSGi-based frameworks (eg. WSO2 Carbon, see sample script on how to configure it);
12+
* remove custom pool executors, use standard ThreadPoolExecutor instead;
13+
* support for matching classes and methods by annotations;
14+
15+
116
Zorka 0.6 (2012-12-22)
217
----------------------
318

configs/samples/scripts/auditcas2.bsh configs/samples/scripts/audit_cas.bsh

+6-14
Original file line numberDiff line numberDiff line change
@@ -19,24 +19,16 @@
1919

2020
__cas() {
2121

22-
useSyslog = true;
23-
useZabbix = true;
24-
2522
request = new ThreadLocal();
2623

27-
syslogTrapper = useSyslog ? syslog.trapper("audit", "127.0.0.1", zorka.getHostname()) : null;
28-
zabbixTrapper = useZabbix ? zabbix.trapper("audit", "127.0.0.1", zorka.getHostname()) : null;
24+
syslogTrapper = syslog.trapper("audit", "127.0.0.1", zorka.getHostname(), syslog.F_AUDIT);
25+
zabbixTrapper = zabbix.trapper("audit", "127.0.0.1", zorka.getHostname(), "cas.audit");
2926

3027
audit(sdef, expr) {
31-
if (useSyslog)
32-
sdef = sdef.onSubmit(
33-
spy.syslogCollector(syslogTrapper, expr, syslog.S_INFO, syslog.F_LOCAL5, zorka.getHostname(), "cas.audit"));
34-
35-
if (useZabbix)
36-
sdef = sdef.onSubmit(
37-
spy.zabbixCollector(zabbixTrapper, expr, "cas.audit"));
38-
39-
spy.add(sdef);
28+
spy.add(sdef.onSubmit(
29+
spy.trapperCollector(syslogTrapper, zorka.INFO, "cas", expr),
30+
spy.trapperCollector(zabbixTrapper, zorka.INFO, "cas", expr)
31+
));
4032
}
4133

4234

File renamed without changes.

configs/samples/scripts/auditcas1.bsh

-112
This file was deleted.

configs/zabbix/scripts/jboss.bsh

+3-3
Original file line numberDiff line numberDiff line change
@@ -157,10 +157,10 @@ __jboss() {
157157

158158
jbossMbs = null;
159159

160-
process(stage,record) {
160+
process(record) {
161161
synchronized (super) {
162162
if (super.jbossMbs == null) {
163-
mbs = record.get(spy.ON_RETURN,0);
163+
mbs = record.get("MBS");
164164
zorka.registerMbs("jboss", mbs);
165165
super.jbossMbs = mbs;
166166
zorka.logInfo("Registered JBoss MBean server as 'jboss'");
@@ -172,7 +172,7 @@ __jboss() {
172172
} // __mbsRegister()
173173

174174
spy.add(spy.instance()
175-
.onReturn(0, (com.jitlogic.zorka.spy.SpyProcessor)__mbsRegister())
175+
.onReturn(spy.fetchArg("MBS", 0), (com.jitlogic.zorka.spy.SpyProcessor)__mbsRegister())
176176
.include(spy.byMethod("org.jboss.mx.server.MBeanServerImpl", "<init>")));
177177

178178
return this;

configs/zabbix/scripts/jboss7.bsh

+3-3
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ __jboss7() {
124124
__mbsRegister() {
125125
jbossMbs = null;
126126

127-
process(stage,record) {
127+
process(record) {
128128
synchronized (super) {
129129
if (super.jbossMbs == null) {
130130
mbs = java.lang.management.ManagementFactory.getPlatformMBeanServer();
@@ -140,8 +140,8 @@ __jboss7() {
140140

141141

142142
spy.add(spy.instance()
143-
.onReturn(spy.FETCH_NULL, (com.jitlogic.zorka.spy.SpyProcessor)__mbsRegister())
144-
.include(spy.byMethod("org.jboss.modules.ModuleLoader", "installMBeanServer")));
143+
.onReturn((com.jitlogic.zorka.spy.SpyProcessor)__mbsRegister())
144+
.include(spy.byMethod(spy.AC_STATIC, "org.jboss.modules.ModuleLoader", "installMBeanServer", "void")));
145145

146146

147147

configs/zabbix/scripts/wso2.bsh

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ __wso2() {
2323

2424
__carbonOSGiConfigurer() {
2525

26-
process(stage, record) {
26+
process(record) {
2727
zorka.logInfo("(Re)Configuring OSGi parameters for Zorka Spy ...");
2828

2929
p = record.get("PARAM");

docs/UserGuide/01intro.md

+2-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@ implemented at first):
1010

1111
* programmability - zorka can be extended using BeanShell scripts;
1212

13-
* bytecode instrumentation - zorka can instrument your code in several ways and present collected values via JMX Beans;
13+
* bytecode instrumentation - zorka can instrument your code in several ways and perform arbitrary actions with collected
14+
data, eg. present them as statistics via JMX, send to file, syslog, as SNMP traps or execute arbitrary beanshell script;
1415

1516
* mapped mbeans - user can map calcluated values from some mbeans into other mbeans (on attribute basis);
1617
standard JMX clients can fetch these values;

docs/UserGuide/03config.md

+8-40
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ as BeanShell scripts.
135135

136136
Spy definition example:
137137

138-
collect(record) {
138+
process(record) {
139139
mbs = record.get(4,0);
140140
zorka.registerMbs("jboss", mbs);
141141
}
@@ -163,33 +163,22 @@ to choose stage (or probe point):
163163
sdef = sdef.onReturn(args...);
164164
sdef = sdef.onError(args...);
165165
sdef = sdef.onSubmit(args...);
166-
sdef = sdef.onCollect(args...);
167166

168-
### Fetching arguments
167+
### Fetching, processing and collecting data
169168

170169
Data to be fetched by probes can be defined using `withArguments()` method:
171170

172171
sdef = sdef.onEnter(arg1, arg2, ...);
173172

174-
Arguments can passed as numbers representing argument indexes or special data. For instance methods visible arguments
175-
start with number 1 at number 0 there is reference to object itself (`this`). For static methods arguments start with
176-
number 0.
177-
178-
There are some special indexes that represent other data possible to fetch by instrumentation probes:
179-
180-
* `spy.FETCH_TIME` (-1) - fetch current time;
181-
* `spy.FETCH_RET_VAL` (-2) - fetch return value (this is valid only on return points);
182-
* `spy.FETCH_ERROR` (-3) - fetch exception object (this is valid only on error points);
183-
* `spy.FETCH_THREAD` (-4) - fetch current thread;
184-
* `spy.FETCH_NULL` (-5) - fetch null constant (useful in some cases);
185-
186-
It is also possible to fetch classes - just pass strings containing fully qualified class names instread of integers.
173+
Fetch probes, processors and collectors can be used as arguments (see spy library functions). Fetch probes produce data
174+
that are passed through processors to collectors as dictionary objects (`Map<String,Object>`). Data are accessed using
175+
string keys as in ordinary hash maps. Processors can get named values from map objects or write other values to passed
176+
maps. Processors can also filter out records. Collectors are just special kinds of processors that have some side
177+
effects. >Collector can update statistics, write to logs, send messages via syslog etc.
187178

188179
Additional notes:
189180

190-
* remember that argument fetch can be done in various points, use `sdef.onXXX()` method to select proper stage;
191-
192-
* when instrumenting constructors, be sure that this reference (if used) can be fetched only at constructor return -
181+
* when instrumenting constructors, be sure that `this` reference (if used) can be fetched only at constructor return -
193182
this is because at the beginning of a constructor this points to an uninitialized block of memory that does not
194183
represent any object, so instrumented class won't load and will crash with class verifier error;
195184

@@ -200,24 +189,3 @@ represent any object, so instrumented class won't load and will crash with class
200189
Using `include()` method administrator can add matching rules filtering which methods are to be instrumented. Methods
201190
matching any of passed matchers will be included. Matchers can be defined using `spy.byXXX()` functions.
202191

203-
### Access to data in spy records
204-
205-
Spy processors and collectors access data stored in records using references that can have two forms:
206-
207-
* simple indexes (numbers) - will always refer to slot in current processing stage (stage processor has been added to);
208-
these are simple integers; slot indexes start at 0;
209-
210-
* full references - contain both stage identifier and slot number; these are strings with first character indicating
211-
stage and followed by index, eg. `E0` means first slot in `ON_ENTER` stage;
212-
213-
The following characters are legal:
214-
215-
* `E` - `ON_ENTER`;
216-
* `R` - `ON_RETURN`;
217-
* `X` - `ON_EXCEPTION`;
218-
* `S` - `ON_SUBMIT`;
219-
* `C` - `ON_COLLECT`;
220-
221-
222-
### Formatting strings
223-

docs/UserGuide/04apiref.md

+13-23
Original file line numberDiff line numberDiff line change
@@ -514,10 +514,6 @@ In addition `keyExpr` can contain expressions fetching record arguments `${n.att
514514

515515
It is also possible to attach single-method call statistic directly as mbean attribute:
516516

517-
spy.zorkaStat(mbsName, beanName, attrName, tstampField, timeField);
518-
519-
All parameters are the same as in `toStats()` method (except for `keyExpr` which is missing).
520-
521517
#### Intercepting and presenting objects via Zorka Getter
522518

523519
Presenting intercepted values as mbean attributes is possible with `toGetter()` method:
@@ -527,14 +523,6 @@ Presenting intercepted values as mbean attributes is possible with `toGetter()`
527523
This will present intercepted object as ValGetter attribute. Each time attribute is accessed (eg. via jconsole),
528524
Zorka will fetch value using attribute chain `(attr1, attr2, ...)` as in `zorka.jmx()` call.
529525

530-
#### Logging collected events via Syslog
531-
532-
spy.syslogCollector(trapper, expr, severity, facility, hostname, tag)
533-
534-
Parameter `trapper` must be a reference to trapper object obtained using `syslog.trapper()`. Parameter `expr` is message
535-
template (analogous to `keyExpr` in other collectors). Remaining parameters - `severity`, `facility`, `hostname` and
536-
`tag` work in the same way as in `syslog.log()` method.
537-
538526
#### Sending collected events as SNMP traps
539527

540528
spy.snmpCollector(trapper, oid, spcode, bindings)
@@ -543,22 +531,24 @@ Parameter `trapper` must be a reference to trapper object obtained using `snmp.t
543531
`enterprise-oid` field set to `oid` and all variables will have their keys starting with `oid`. Traps will be of
544532
`enterpriseSpecific` (6) type and specific code will be set to `spcode`.
545533

546-
#### Sending collected events to Zabbix
534+
#### Using trappers with spy
547535

548-
spy.zabbixCollector(trapper, expr, key)
549-
spy.zabbixCollector(trapper, expr, host, key)
536+
spy.trapperCollector(trapper, logLevel, tagExpr, msgExpr, errExpr, errField)
550537

551-
Parameter `trapper` must be a reference to zabbix trapper obtained using `zabbix.get()` function. Parameter `expr` is
552-
message template (analogous to `keyExpr` in other collectors). Parametry `key' refers to zabbix item key that will be
553-
populated. Item must be of proper type (text or number depending on data that is submitted).
538+
This function creates collector that will send messages via trapper. Several trapper types are available:
554539

555-
#### Sending collected records to log file
540+
* file trappers - trappers that log messages to log file;
541+
* syslog trappers - trappers that send syslog messages;
542+
* zabbix trappers - trappers that send traps directly to zabbix;
556543

557-
spy.fileCollector(trapper, expr, logLevel)
544+
Arguments:
558545

559-
Parameter `trapper` must be a reference to file trapper obtained using `zorka.fileTrapper()`, `zorka.dailyFileTrapper()`
560-
or `zorka.rollingFileTrapper()`. Second parameter `expr` contains template string used to create log messages. Parameter
561-
`logLevel` must be one of: `zorka.TRACE`, `zorka.DEBUG`, `zorka.INFO`, `zorka.WARN`, `zorka.ERROR` and `zorka.FATAL`.
546+
* `trapper` - configured and started trapper object;
547+
* `logLevel` - log level (ZorkaLogLevel constant);
548+
* `tagExpr` - log tag;
549+
* `msgExpr` - log message (if call succeeds);
550+
* `errExpr` - log message (if error occurs);
551+
* `errField` - spy record field that contains intercepted exception object;
562552

563553
#### Passing records to another processing chain
564554

pom.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<groupId>com.jitlogic.zorka</groupId>
44
<artifactId>zorka</artifactId>
55
<packaging>pom</packaging>
6-
<version>0.6.1-SNAPSHOT</version>
6+
<version>0.7.0</version>
77
<name>zorka: parent aggregator</name>
88
<url>http://www.jitlogic.com/zorka</url>
99

zorka-agent/pom.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xs
66
<parent>
77
<groupId>com.jitlogic.zorka</groupId>
88
<artifactId>zorka</artifactId>
9-
<version>0.6.1-SNAPSHOT</version>
9+
<version>0.7.0</version>
1010
</parent>
1111
<dependencies>
1212
<dependency>

zorka-agent/src/main/java/com/jitlogic/zorka/integ/ZabbixLib.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -192,11 +192,11 @@ public ZabbixTrapper trapper(String id) {
192192
* @param defaultHost default host name
193193
* @return zabbix trapper
194194
*/
195-
public ZabbixTrapper trapper(String id, String serverAddr, String defaultHost) {
195+
public ZabbixTrapper trapper(String id, String serverAddr, String defaultHost, String defaultItem) {
196196
ZabbixTrapper trapper = trappers.get(id);
197197

198198
if (trapper == null) {
199-
trapper = new ZabbixTrapper(serverAddr, defaultHost, "traps");
199+
trapper = new ZabbixTrapper(serverAddr, defaultHost, defaultItem);
200200
trappers.put(id, trapper);
201201
trapper.start();
202202
}

0 commit comments

Comments
 (0)