Skip to content

Instantly share code, notes, and snippets.

@mykidong
Created May 24, 2018 13:42
Show Gist options
  • Save mykidong/1f64fc58f0891f0e74a14155d0673289 to your computer and use it in GitHub Desktop.
Save mykidong/1f64fc58f0891f0e74a14155d0673289 to your computer and use it in GitHub Desktop.
public class SomeServiceHandler extends SomeServiceGrpc.SomeServiceImplBase {
private static final String METRICS_PREFIX = "meter-api." + SomeServiceHandler.class.getSimpleName();
/**
* metric registry.
*/
private MetricRegistry metricRegistry;
// metricRegistry injected.
public void setMetricRegistry(MetricRegistry metricRegistry) {
this.metricRegistry = metricRegistry;
}
@Override
public void doSearch(...) {
this.metricRegistry.meter(METRICS_PREFIX + ".doSearch").mark();
...
}
@Override
public void getSomeStatus(...) {
this.metricRegistry.meter(METRICS_PREFIX + ".getSomeStatus").mark();
...
}
}
@mykidong
Copy link
Author

some service handler.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment