Search in sources :

Example 1 with MetricSnapshot

use of com.yahoo.metrics.MetricSnapshot in project vespa by vespa-engine.

the class StatusResponse method render.

@Override
public void render(OutputStream stream) throws IOException {
    XMLWriter writer = new XMLWriter(new OutputStreamWriter(stream));
    writer.openTag("status");
    if (verbosity >= 2) {
        writer.attribute(new Utf8String("description"), "Metrics since start");
    }
    if (snapshotTime == 0) {
        MetricSnapshot snapshot = (new MetricSnapshot("Total metrics from start until current time", 0, manager.getActiveMetrics().getMetrics(), false));
        manager.getTotalMetricSnapshot().addToSnapshot(snapshot, (int) (System.currentTimeMillis() / 1000), false);
        snapshot.printXml(manager, "", verbosity, writer);
    } else {
        try {
            manager.getMetricSnapshotSet(snapshotTime).getSnapshot().printXml(manager, "", verbosity, writer);
        } catch (Exception e) {
            writer.openTag("error");
            writer.attribute(new Utf8String("details"), "No metric snapshot with period " + snapshotTime + " was found. Legal snapshot periods are: " + manager.getSnapshotPeriods());
            writer.closeTag();
        }
    }
    writer.closeTag();
    writer.flush();
}
Also used : Utf8String(com.yahoo.text.Utf8String) OutputStreamWriter(java.io.OutputStreamWriter) XMLWriter(com.yahoo.text.XMLWriter) MetricSnapshot(com.yahoo.metrics.MetricSnapshot) IOException(java.io.IOException)

Aggregations

MetricSnapshot (com.yahoo.metrics.MetricSnapshot)1 Utf8String (com.yahoo.text.Utf8String)1 XMLWriter (com.yahoo.text.XMLWriter)1 IOException (java.io.IOException)1 OutputStreamWriter (java.io.OutputStreamWriter)1