Skip to content

Instantly share code, notes, and snippets.

@johann8384
Last active June 9, 2017 02:05
Show Gist options
  • Save johann8384/9934eee058610ec7dc6b282d76cee5dc to your computer and use it in GitHub Desktop.
Save johann8384/9934eee058610ec7dc6b282d76cee5dc to your computer and use it in GitHub Desktop.
/*
* Set Meters for Important Events
*/
Metrics.markMeter(Metrics.name("requests", "ended"));
/*
* Counters are simple, you can inc/dec them.
*/
Metrics.incCounter(Metrics.name("metricstats", tenantId, "valid"));
/*
* Creates the timer context and starts it, then call stop to stop it.
*/
Metrics.getTimerContext(Metric.name("discoverobjects", "total"));
Metrics.getTimerContext(Metric.name("discoverobjects", "total")).stop();
/*
* Register a gauge by passing an atomiclong/integer which will be reported
*/
AtomicLong numberOfItems = new AtomicLong();
numberOfItems.incrementAndGet();
Metrics.registerGauge(Metric.name("numberofitems", "total"), numberOfItems);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment