use of org.platformlayer.metrics.MetricTreeObject in project platformlayer by platformlayer.
the class PlatformlayerMetricsReporter method processHistogram.
@Override
public void processHistogram(MetricName name, Histogram histogram, MetricTreeObject tree) throws IOException {
MetricTreeObject subtree = getSubtree(tree, name);
// final String sanitizedName = sanitizeName(name);
sendSummarizable(subtree, histogram);
sendSampling(subtree, histogram);
}
use of org.platformlayer.metrics.MetricTreeObject in project platformlayer by platformlayer.
the class PlatformlayerMetricsReporter method printVmMetrics.
protected void printVmMetrics(MetricTreeObject tree) {
MetricTreeObject jvmTree = tree.getSubtree("jvm");
MetricTreeObject memoryTree = jvmTree.getSubtree("memory");
memoryTree.addFloat("heap_usage", vm.heapUsage());
memoryTree.addFloat("non_heap_usage", vm.nonHeapUsage());
MetricTreeObject memoryPoolUsages = memoryTree.getSubtree("memory_pool_usages");
for (Entry<String, Double> pool : vm.memoryPoolUsage().entrySet()) {
memoryPoolUsages.addFloat(pool.getKey(), pool.getValue());
}
jvmTree.addInt("daemon_thread_count", vm.daemonThreadCount());
jvmTree.addInt("thread_count", vm.threadCount());
jvmTree.addInt("uptime", vm.uptime());
jvmTree.addFloat("fd_usage", vm.fileDescriptorUsage());
MetricTreeObject threadStates = jvmTree.getSubtree("thread-states");
for (Entry<State, Double> entry : vm.threadStatePercentages().entrySet()) {
threadStates.addFloat(entry.getKey().toString().toLowerCase(), entry.getValue());
}
MetricTreeObject gcTree = jvmTree.getSubtree("gc");
for (Entry<String, VirtualMachineMetrics.GarbageCollectorStats> entry : vm.garbageCollectors().entrySet()) {
MetricTreeObject collectorTree = gcTree.getSubtree(entry.getKey());
collectorTree.addInt("time", entry.getValue().getTime(TimeUnit.MILLISECONDS));
collectorTree.addInt("runs", entry.getValue().getRuns());
}
}
use of org.platformlayer.metrics.MetricTreeObject in project platformlayer by platformlayer.
the class MetricClientImpl method copyPropertiesToTree.
private static void copyPropertiesToTree(Map<String, String> properties, MetricTreeObject dest) {
for (Entry<String, String> entry : properties.entrySet()) {
String key = entry.getKey();
String value = entry.getValue();
List<String> tokens = Lists.newArrayList(Splitter.on('.').split(key));
MetricTreeObject subtree = dest;
for (int i = 0; i < tokens.size() - 1; i++) {
subtree = subtree.getSubtree(tokens.get(i));
}
String valueKey = tokens.get(tokens.size() - 1);
subtree.addString(valueKey, value);
}
}
use of org.platformlayer.metrics.MetricTreeObject in project platformlayer by platformlayer.
the class MetricTreeSerializer method serialize.
public void serialize(MetricTreeBase tree, OutputStream os) throws IOException {
final JsonGenerator jsonGenerator = jsonFactory.createJsonGenerator(os);
tree.accept(new MetricTreeVisitor() {
private void writeKey(MetricTreeBase o) throws JsonGenerationException, IOException {
if (o.getKey() != null) {
jsonGenerator.writeFieldName(o.getKey());
}
}
@Override
public void visit(MetricTreeObject o) {
try {
writeKey(o);
jsonGenerator.writeStartObject();
o.visitChildren(this);
jsonGenerator.writeEndObject();
} catch (IOException e) {
throw new IllegalStateException("Error serializing to JSON", e);
}
}
@Override
public void visit(MetricTreeString o) {
try {
writeKey(o);
jsonGenerator.writeString(o.getValue());
} catch (IOException e) {
throw new IllegalStateException("Error serializing to JSON", e);
}
}
@Override
public void visit(MetricTreeArray o) {
try {
writeKey(o);
jsonGenerator.writeStartArray();
o.visitItems(this);
jsonGenerator.writeEndArray();
} catch (IOException e) {
throw new IllegalStateException("Error serializing to JSON", e);
}
}
@Override
public void visit(MetricTreeInteger o) {
try {
writeKey(o);
jsonGenerator.writeNumber(o.getValue());
} catch (IOException e) {
throw new IllegalStateException("Error serializing to JSON", e);
}
}
@Override
public void visit(MetricTreeFloat o) {
try {
writeKey(o);
jsonGenerator.writeNumber(o.getValue());
} catch (IOException e) {
throw new IllegalStateException("Error serializing to JSON", e);
}
}
});
jsonGenerator.close();
}
use of org.platformlayer.metrics.MetricTreeObject in project platformlayer by platformlayer.
the class PlatformlayerMetricsReporter method processTimer.
@Override
public void processTimer(MetricName name, Timer timer, MetricTreeObject tree) throws IOException {
processMeter(name, timer, tree);
// final String sanitizedName = sanitizeName(name);
MetricTreeObject subtree = getSubtree(tree, name);
sendSummarizable(subtree, timer);
sendSampling(subtree, timer);
}
Aggregations