Skip to content

Package: MetricsService

MetricsService

Coverage

1: /*******************************************************************************
2: * Copyright (c) 2016, 2022 Eurotech and/or its affiliates and others
3: *
4: * This program and the accompanying materials are made
5: * available under the terms of the Eclipse Public License 2.0
6: * which is available at https://www.eclipse.org/legal/epl-2.0/
7: *
8: * SPDX-License-Identifier: EPL-2.0
9: *
10: * Contributors:
11: * Eurotech - initial API and implementation
12: *******************************************************************************/
13: package org.eclipse.kapua.commons.metric;
14:
15: import org.eclipse.kapua.KapuaException;
16: import org.eclipse.kapua.service.KapuaService;
17:
18: import com.codahale.metrics.Counter;
19: import com.codahale.metrics.Gauge;
20: import com.codahale.metrics.Histogram;
21: import com.codahale.metrics.MetricRegistry;
22: import com.codahale.metrics.Timer;
23:
24: /**
25: * Metric service definition
26: *
27: * @since 1.0
28: *
29: */
30: public interface MetricsService extends KapuaService {
31:
32: /**
33: * Get a Counter for the specified name. If the counter doesn't exist the method should create a new one counter with the specified name.
34: *
35: * @param module
36: * @param component
37: * @param names
38: * @return
39: */
40: public Counter getCounter(String module, String component, String... names);
41:
42: /**
43: * Get a Histogram for the specified name. If the histogram doesn't exist the method should create a new one histogram with the specified name.
44: *
45: * @param module
46: * @param component
47: * @param names
48: * @return
49: */
50: public Histogram getHistogram(String module, String component, String... names);
51:
52: /**
53: * Get a Timer for the specified name. If the timer doesn't exist the method should create a new one timer with the specified name.
54: *
55: * @param module
56: * @param component
57: * @param names
58: * @return
59: */
60: public Timer getTimer(String module, String component, String... names);
61:
62: /**
63: * Register a Gauge for the specified name. If the Gauge exists the method throws exception.
64: *
65: * @param module
66: * @param component
67: * @param names
68: * @throws KapuaException
69: * if the metric is already defined
70: */
71: public void registerGauge(Gauge<?> gauge, String module, String component, String... names) throws KapuaException;
72:
73: /**
74: * Return the MetricRegistry containing all the metrics
75: *
76: * @return MetricRegistry
77: */
78: public MetricRegistry getMetricRegistry();
79:
80: }