Make UMA stats creation available in the Java interface.
Only has counts stats right now but enumeration stats can easily be added in the future if needed. BUG=webrtc:6313 Review-Url: https://codereview.webrtc.org/2320473002 Cr-Commit-Position: refs/heads/master@{#14146}
This commit is contained in:
@ -30,6 +30,8 @@ import java.util.Map;
|
||||
// The metrics can for example be retrieved when a peer connection is closed.
|
||||
|
||||
public class Metrics {
|
||||
private static final String TAG = "Metrics";
|
||||
|
||||
static {
|
||||
System.loadLibrary("jingle_peerconnection_so");
|
||||
}
|
||||
@ -57,6 +59,36 @@ public class Metrics {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Class for holding the native pointer of a histogram. Since there is no way to destroy a
|
||||
* histogram, please don't create unnecessary instances of this object. This class is thread safe.
|
||||
*
|
||||
* Usage example:
|
||||
* private static final Histogram someMetricHistogram =
|
||||
* Histogram.createCounts("WebRTC.Video.SomeMetric", 1, 10000, 50);
|
||||
* someMetricHistogram.addSample(someVariable);
|
||||
*/
|
||||
static class Histogram {
|
||||
private final long handle;
|
||||
private final String name; // Only used for logging.
|
||||
|
||||
private Histogram(long handle, String name) {
|
||||
this.handle = handle;
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
static public Histogram createCounts(String name, int min, int max, int bucketCount) {
|
||||
return new Histogram(nativeCreateCounts(name, min, max, bucketCount), name);
|
||||
}
|
||||
|
||||
public void addSample(int sample) {
|
||||
nativeAddSample(handle, sample);
|
||||
}
|
||||
|
||||
private static native long nativeCreateCounts(String name, int min, int max, int bucketCount);
|
||||
private static native void nativeAddSample(long handle, int sample);
|
||||
}
|
||||
|
||||
private void add(String name, HistogramInfo info) {
|
||||
map.put(name, info);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user