[
https://issues.apache.org/jira/browse/SLING-4849?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Ian Boston updated SLING-4849:
------------------------------
Attachment: Screen Shot 2015-07-02 at 12.24.01.png
Screen Shot 2015-07-02 at 12.24.18.png
Screen Shot 2015-07-02 at 12.24.27.png
Screenshots of a console reporter and JMX exposed in VisualVM with the
org.apache.sling.resourceresolver.impl.ResourceResolverFactoryImpl.getResourceResolver
instrumented with a Timer.
The config file to achieve this was
{code}
_reporter_jmx: true
_reporter_console: 20
org.apache.sling.resourceresolver.impl.ResourceResolverFactoryImpl: true
org.apache.sling.resourceresolver.impl.ResourceResolverFactoryImpl.getResourceResolver:
timer
{code}
No code changes required. Timers require an additional 5 byte code instructions
added to the method. counters and meters require 2 byte code instruction to the
start of the method.
Format of the config file is
{code}
# enable instrumentation on the class
<classname> : true
# enable a timer on the method
<classname>.<methodname> : timer
# or enable a counter method
<classname>.<methodname> : count
# or enable a marker on the method (count + rates)
<classname>.<methodname> : mark
{code}
lines starting _ are special.
Have not measured the overhead of the timer, but it goes direct to the
DropWizards metrics library so should be ok for full production. (based on
reports from Yammer and others).
> Create Metrics instumentation bundle using ASM.
> -----------------------------------------------
>
> Key: SLING-4849
> URL: https://issues.apache.org/jira/browse/SLING-4849
> Project: Sling
> Issue Type: Improvement
> Components: Extensions
> Reporter: Ian Boston
> Assignee: Ian Boston
> Attachments: Screen Shot 2015-07-02 at 12.24.01.png, Screen Shot
> 2015-07-02 at 12.24.18.png, Screen Shot 2015-07-02 at 12.24.27.png
>
>
> Aim: To enable metrics for any method call in a Sling JVM without requiring
> any code changes to existing bundles.
> Method: OSGi 4.3 has a WeavingHook which is allows a byte code generator to
> get in between the classloader and classloading. Using ASM it should be
> possible to write code that enhances the byte code of any class to wrap
> method calls in calls to the Dropwizard Metrics library. This should work
> without any changes to the startup. The only requirement is the bundle is
> loaded before the classloader loads the classes that need to be instrumented.
> Quick tests indicate the method works and adds no more than 10 byte code
> instructions to a method. It may be possible to reduce that further.
> Instrumentation will be controlled by configuration, so classes that are not
> instrumented are not modified at all when loading.
> The metrics once available can be pushed into Graphite, Kibana or some other
> collection service. Dumped to a file periodically or exposed in JMX as
> counters.
> Will work in a branch on github initially.
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)