Three of the Metric in the yammer library are based on data that is pushed to them: Counter, Histogram and Meter. This patch modify the specific functionality by inherit the original Meter, keeping its functionality and API, and modify the way the data is collected. For Counter: A call to count will be implementing by calling the API to retreive a value. For Meter: A call to count will be implementing by calling the API to retreive a value, similiar to count, but the timer aspect of the Meter remains the same. For histogram: Histogram uses an internal sample container. To mimic the behaviour, a call to any of the historgram get functionality will update the sample container first. A timestamp of the last update limits the number of updates that will be done by the histogram. Signed-off-by: Amnon Heiman <amnon@cloudius-systems.com>
30 lines
562 B
Java
30 lines
562 B
Java
package com.yammer.metrics.core;
|
|
/*
|
|
* Copyright 2015 Cloudius Systems
|
|
*
|
|
* Modified by Cloudius Systems
|
|
*/
|
|
|
|
import com.cloudius.urchin.api.APIClient;
|
|
import com.yammer.metrics.core.Counter;
|
|
|
|
public class APICounter extends Counter {
|
|
String url;
|
|
private APIClient c = new APIClient();
|
|
|
|
public APICounter(String _url) {
|
|
super();
|
|
url = _url;
|
|
}
|
|
/**
|
|
* Returns the counter's current value.
|
|
*
|
|
* @return the counter's current value
|
|
*/
|
|
public long count() {
|
|
return c.getLongValue(url);
|
|
}
|
|
|
|
|
|
}
|