/** * Record a sample at the given position. * * @param x * sample value * @param p * position/dimension values for the sample */ public void sample(double x, Point p) { receiver.update(new Sample(new Measurement(Double.valueOf(x)), new Identifier(name, p), AssumedType.GAUGE)); }
void put(Sample x) { UntypedMetric value = get(x); Measurement m = x.getMeasurement(); switch (x.getMetricType()) { case GAUGE: value.put(m.getMagnitude()); break; case COUNTER: value.add(m.getMagnitude()); break; default: throw new IllegalArgumentException("Unsupported metric type: " + x.getMetricType()); } }
/** * Add to this metric at the given point. * * @param n * the amount by which to increase this counter * @param p * the point in the metric space at which to add to the metric */ public void add(long n, Point p) { metricReceiver.update(new Sample(new Measurement(Long.valueOf(n)), new Identifier(name, p), AssumedType.COUNTER)); }
@Override public void set(String key, Number val, Context ctx) { receiver.update(new Sample(new Measurement(val), new Identifier(key, getSimpleCoordinate(ctx)), AssumedType.GAUGE)); }
@Override public void add(String key, Number val, Context ctx) { receiver.update(new Sample(new Measurement(val), new Identifier(key, getSimpleCoordinate(ctx)), AssumedType.COUNTER)); }