aboutsummaryrefslogtreecommitdiffstats
path: root/metrics/src/main/java/ai/vespa/metrics/VespaMetrics.java
blob: b3777e72e82d04229a819bad05b35e92c95d3d9a (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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
// Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package ai.vespa.metrics;

/**
 * @author gjoranv
 */
public interface VespaMetrics {

    String baseName();
    Unit unit();
    String description();

    default String descriptionWitUnit() {
        return description() + " (unit: " + unit().shortName() + ")";
    }

    private String withSuffix(Suffix suffix) {
        return baseName() + "." + suffix.suffix();
    }

    // TODO: make the below methods return Metric objects instead of Strings.

    default String ninety_five_percentile() {
        return withSuffix(Suffix.ninety_five_percentile);
    }

    default String ninety_nine_percentile() {
        return withSuffix(Suffix.ninety_nine_percentile);
    }

    default String average() {
        return withSuffix(Suffix.average);
    }

    default String count() {
        return withSuffix(Suffix.count);
    }

    default String last() {
        return withSuffix(Suffix.last);
    }

    default String max() {
        return withSuffix(Suffix.max);
    }

    default String min() {
        return withSuffix(Suffix.min);
    }

    default String rate() {
        return withSuffix(Suffix.rate);
    }

    default String sum() {
        return withSuffix(Suffix.sum);
    }

}