summaryrefslogtreecommitdiffstats
path: root/metrics/src/main/java/com/yahoo/metrics/MetricVisitor.java
blob: f9d3473bbf98f57ead9722ce6e417be3f09043b6 (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
// Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.metrics;

public abstract class MetricVisitor {
    /**
     * Visit a metric set.
     *
     * @param autoGenerated True for metric sets that are generated on the
     *                      fly such as in sum metrics.
     * @return True if you want to visit the content of this metric set.
     */
    public boolean visitMetricSet(MetricSet set, boolean autoGenerated) {
        return true;
    }

    /**
     * Callback visitors can use if they need to know the tree traversal of
     * metric sets. This function is not called if visitMetricSet returned
     * false.
     */
    public void doneVisitingMetricSet(MetricSet set) {
    }

    /**
     * Visit a primitive metric within an accepted metric set.
     *
     * @return True if you want to continue visiting, false to abort.
     */
    public boolean visitPrimitiveMetric(Metric m, boolean autoGenerated) {
        return true;
    }
}