use of com.yahoo.metrics.simple.Point in project vespa by vespa-engine.
the class SnapshotConverter method convert.
static MetricDimensions convert(Point p) {
if (p == null) {
return StateMetricContext.newInstance(null);
}
List<String> dimensions = p.dimensions();
List<Value> location = p.location();
Map<String, Object> pointWrapper = new HashMap<>(dimensions.size());
for (int i = 0; i < dimensions.size(); ++i) {
pointWrapper.put(dimensions.get(i), valueAsString(location.get(i)));
}
return StateMetricContext.newInstance(pointWrapper);
}
use of com.yahoo.metrics.simple.Point in project vespa by vespa-engine.
the class SnapshotConverter method getIdentifierString.
private String getIdentifierString(Identifier id) {
StringBuilder buffer = new StringBuilder();
Point location = id.getLocation();
buffer.append(id.getName());
if (location != null) {
buffer.append(", dimensions: { ");
Iterator<String> dimensions = location.dimensions().iterator();
Iterator<Value> values = location.location().iterator();
boolean firstDimension = true;
while (dimensions.hasNext() && values.hasNext()) {
if (firstDimension) {
firstDimension = false;
} else {
buffer.append(", ");
}
serializeSingleDimension(buffer, dimensions.next(), values.next());
}
buffer.append(" }");
}
return buffer.toString();
}
use of com.yahoo.metrics.simple.Point in project vespa by vespa-engine.
the class SnapshotConverter method convert.
MetricSnapshot convert() {
for (Map.Entry<Identifier, UntypedMetric> entry : snapshot.entrySet()) {
Identifier ident = entry.getKey();
getMap(ident.getLocation()).put(ident.getName(), convert(entry.getValue()));
}
Map<MetricDimensions, MetricSet> data = new HashMap<>();
for (Map.Entry<Point, Map<String, MetricValue>> entry : perPointData.entrySet()) {
MetricDimensions key = convert(entry.getKey());
MetricSet newval = new MetricSet(entry.getValue());
MetricSet old = data.get(key);
if (old != null) {
// should not happen, this is bad
// TODO: consider merging the two MetricSet instances
log.warning("losing MetricSet when converting for: " + entry.getKey());
} else {
data.put(key, newval);
}
}
return new MetricSnapshot(snapshot.getFromMillis(), snapshot.getToMillis(), TimeUnit.MILLISECONDS, data);
}
use of com.yahoo.metrics.simple.Point in project vespa by vespa-engine.
the class SnapshotConverterTest method testConversion.
@Test
public void testConversion() {
MetricReceiver mock = new MetricReceiver.MockReceiver();
mock.declareCounter("foo").add(1);
mock.declareGauge("quuux").sample(42.25);
mock.declareCounter("bar", new Point(new HashMap<String, String>())).add(4);
MetricSnapshot snapshot = new SnapshotConverter(mock.getSnapshot()).convert();
for (Map.Entry<MetricDimensions, MetricSet> entry : snapshot) {
for (Map.Entry<String, String> dv : entry.getKey()) {
assertTrue(false);
}
int cnt = 0;
for (Map.Entry<String, MetricValue> mv : entry.getValue()) {
++cnt;
if ("foo".equals(mv.getKey())) {
assertTrue(mv.getValue() instanceof CountMetric);
assertEquals(1, ((CountMetric) mv.getValue()).getCount());
} else if ("bar".equals(mv.getKey())) {
assertTrue(mv.getValue() instanceof CountMetric);
assertEquals(4, ((CountMetric) mv.getValue()).getCount());
} else if ("quuux".equals(mv.getKey())) {
assertTrue(mv.getValue() instanceof GaugeMetric);
assertEquals(42.25, ((GaugeMetric) mv.getValue()).getLast(), 0.001);
assertEquals(1, ((GaugeMetric) mv.getValue()).getCount());
} else {
assertTrue(false);
}
}
assertEquals(3, cnt);
}
}
use of com.yahoo.metrics.simple.Point in project vespa by vespa-engine.
the class DocumentApiMetrics method reportFailure.
public void reportFailure(DocumentOperationType documentOperationType, DocumentOperationStatus documentOperationStatus) {
Point point = points.get(documentOperationStatus).get(documentOperationType);
feeds.add(point);
}
Aggregations