aboutsummaryrefslogtreecommitdiffstats
path: root/metrics-proxy/src/main/java/ai/vespa/metricsproxy/metric/model/processing/MetricsProcessor.java
blob: d613bc054512dff76b1c5071bedb3284db83336e (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 Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package ai.vespa.metricsproxy.metric.model.processing;

import ai.vespa.metricsproxy.metric.model.MetricsPacket;

import java.util.Arrays;

/**
 * Interface for classes that make amendments to a metrics packet builder.
 * Includes a utility method to apply a list of processors to a metrics packet.
 *
 * @author gjoranv
 */
public interface MetricsProcessor {

    /**
     * Processes the metrics packet builder in-place.
     */
    void process(MetricsPacket.Builder builder);


    /**
     * Helper method to apply a list of processors to a metrics packet builder.
     * Returns the metrics packet builder (which has been processed in-place) for
     * convenient use in stream processing.
     */
    static MetricsPacket.Builder applyProcessors(MetricsPacket.Builder builder, MetricsProcessor... processors) {
        Arrays.stream(processors).forEach(processor -> processor.process(builder));
        return builder;
    }

}