summaryrefslogtreecommitdiffstats
path: root/vespaclient-core/src/main/java/com/yahoo/clientmetrics/ClientMetrics.java
blob: 87c1dfc7030e7bb86781321e3c3c04af53c1650f (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
// Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.clientmetrics;

import com.yahoo.messagebus.Reply;
import com.yahoo.metrics.*;
import com.yahoo.text.XMLWriter;

import java.io.IOException;
import java.io.OutputStream;
import java.io.PrintStream;
import java.text.DecimalFormat;
import java.text.NumberFormat;
import java.util.ArrayList;
import java.util.List;

/**
 * @author thomasg
 */
public class ClientMetrics {

    MetricSet topSet;
    SumMetric sum;
    List<String> routes = new ArrayList<String>();

    public ClientMetrics() {
        topSet = new SimpleMetricSet("routes", "", "", null);
        sum = new SumMetric("total", "", "Messages sent to all routes", topSet);
    }

    public MetricSet getMetricSet() {
        return topSet;
    }

    public void addRouteMetricSet(RouteMetricSet metric) {
        topSet.registerMetric(metric);
        sum.addMetricToSum(metric);
        routes.add(metric.getRoute());
    }
}