Commit efeaa868 authored by Tigran Mkrtchyan's avatar Tigran Mkrtchyan
Browse files

docs: describe how to use custom statistics module

parent dbf89f36
......@@ -16,3 +16,38 @@
- io_info4 modified to use primitive longs as member fields
- LayoutDriver#acceptLayoutReturnData accepts CompoundContext as argument
- Introduced `ExportTable` interface to allow alternative ways for file system export management.
- removed NFSServerV1#getStatistics and OperationFactoryMXBeanImpl. The same functionality can be achieved by decorating OperationExecutor.
The following example uses io.dropwizard.metrics to collect and publish statistics:
```java
public class MetricAwareOperationExecutor implements OperationExecutor {
private final OperationExecutor inner;
private final MetricRegistry metrics;
private final JmxReporter reporter;
public MetricAwareOperationExecutor(OperationExecutor inner) {
this.inner = inner;
this.metrics = new MetricRegistry();
this.reporter = JmxReporter
.forRegistry(metrics)
.convertDurationsTo(TimeUnit.MICROSECONDS)
.convertRatesTo(TimeUnit.SECONDS)
.inDomain(OperationExecutor.class.getPackageName())
.build();
}
@Override
public nfs_resop4 execute(CompoundContext context, nfs_argop4 arg) throws IOException, OncRpcException {
final Timer requests = metrics.timer(nfs_opnum4.toString(arg.argop));
final Timer.Context time = requests.time();
try {
return inner.execute(context, arg);
} finally {
time.stop();
}
}
}
```
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment