You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sirona.apache.org by rm...@apache.org on 2013/11/25 17:08:27 UTC

svn commit: r1545332 - /incubator/sirona/site-content/trunk/src/site/markdown/instrumentation.md

Author: rmannibucau
Date: Mon Nov 25 16:08:27 2013
New Revision: 1545332

URL: http://svn.apache.org/r1545332
Log:
adding InvocationListener doc

Modified:
    incubator/sirona/site-content/trunk/src/site/markdown/instrumentation.md

Modified: incubator/sirona/site-content/trunk/src/site/markdown/instrumentation.md
URL: http://svn.apache.org/viewvc/incubator/sirona/site-content/trunk/src/site/markdown/instrumentation.md?rev=1545332&r1=1545331&r2=1545332&view=diff
==============================================================================
--- incubator/sirona/site-content/trunk/src/site/markdown/instrumentation.md (original)
+++ incubator/sirona/site-content/trunk/src/site/markdown/instrumentation.md Mon Nov 25 16:08:27 2013
@@ -273,4 +273,25 @@ public class Foo {
         // if other static blocks it will be added here as _$_$irona_static_merge1(), _$_$irona_static_merge2()...
     }
 }
-]]></pre>
\ No newline at end of file
+]]></pre>
+
+## Go further with sirona javaagent
+
+Javaagent is extensible using `InvocationListener` API:
+
+<pre class="prettyprint linenums"><![CDATA[
+public interface InvocationListener {
+    void before(AgentContext context);
+    void after(AgentContext context, Throwable error);
+    boolean accept(Counter.Key key, Object instance);
+}
+]]></pre>
+
+* `accept` method allows to filter by key/instance what is intercepted.
+* `before` and `after` allows to put code around method executions. `AgentContext` supports contextual data through `put`/`get` methods.
+
+Note on contextual data: key is an int for performances reasons, ensure you don't conflict with another listener. Prefer to use negative int if possible.
+
+`InvocationListeners` can be sorted using `@Order` annotation.
+
+They are picked using a plain old service provider interface (`META-INF/services/org.apache.sirona.javaagent.spi.InvocationListener`).