[ 
https://issues.apache.org/jira/browse/OAK-3654?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15013403#comment-15013403
 ] 

Chetan Mehrotra commented on OAK-3654:
--------------------------------------

Attached is [initial implementation|^OAK-3654-v1.patch] to seek feedback on the 
approach. (No test case yet)

Approach taken here is a pluggable one - It allows Oak to run without having a 
required dependency on metrics library and any stats collection can be 
completely switched off. It introduces a new {{StatisticsProvider}} interface 
which allow access to various types of Meters (Counter, Timer, Meter). These 
meters mimic the Metrics API. The default implementation is provided based on 
AtomicLong which is based on counter managed in {{TimeSeriesRecorder}}. 

At runtime one can deploy the Metrics bundle and then configure the 
{{MetricStatisticsProvider}} OSGi components [1]. This would then be used by 
{{StatisticsManager}} and thus via other Oak susbsystems like QueryEngine and 
Observation and stats would be routed to it. Other part of Oak have *no 
dependency* on Metrics API. Thats it! All the stats are now published on JMX

!query-stats.png!

Above image show the JMX stats for Query duration. 

*Usage*

Using this API in other places of Oak is also pretty easy. Just obtain a 
reference to {{StatisticsProvider}} and obtain the correct type of Meter and 
use it

{code:java}
    @Reference
    private StatisticsProvider provider;
    
    public void readFromMongo(){
        //Better to keep a instance variable reference and avoid lookup
        MeterStats readCounter = provider.getMeter("mongo-reads");
        
        readCounter.mark();
    }
{code}

No other work required. The stats would be published to JMX with no extra effort

[~ianeboston] [~mduerig] Can you review the approach

[1] It has to be ensured that it gets activated before repository is created 
(can be done by adding a dep on OSGi component which registers the Repository 
say RepositoryManager)



> Integrate with Metrics for various stats collection 
> ----------------------------------------------------
>
>                 Key: OAK-3654
>                 URL: https://issues.apache.org/jira/browse/OAK-3654
>             Project: Jackrabbit Oak
>          Issue Type: New Feature
>          Components: core
>            Reporter: Chetan Mehrotra
>            Assignee: Chetan Mehrotra
>             Fix For: 1.4
>
>         Attachments: OAK-3654-v1.patch, query-stats.png
>
>
> As suggested by [~ianeboston] in OAK-3478 current approach of collecting 
> TimeSeries data is not easily consumable by other monitoring systems. Also 
> just extracting the last moment data and exposing it in simple form would not 
> be useful. 
> Instead of that we should look into using Metrics library [1] for collecting 
> metrics. To avoid having dependency on Metrics API all over in Oak we can 
> come up with minimal interfaces which can be used in Oak and then provide an 
> implementation backed by Metric.
> This task is meant to explore that aspect and come up with proposed changes 
> to see if its feasible to make this change
> * metrics-core ~100KB in size with no dependency
> * ASL Licensee
> [1] http://metrics.dropwizard.io



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to