Skip to content

Package: PublishMetric

PublishMetric

nameinstructionbranchcomplexitylinemethod
PublishMetric()
M: 101 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 8 C: 0
0%
M: 1 C: 0
0%
getAllowedMessages()
M: 3 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 1 C: 0
0%
M: 1 C: 0
0%
getInstance()
M: 2 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 1 C: 0
0%
M: 1 C: 0
0%
getMessageSizeAllowed()
M: 3 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 1 C: 0
0%
M: 1 C: 0
0%
getMessageSizeNotAllowed()
M: 3 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 1 C: 0
0%
M: 1 C: 0
0%
getNotAllowedMessages()
M: 3 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 1 C: 0
0%
M: 1 C: 0
0%
getTime()
M: 3 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 1 C: 0
0%
M: 1 C: 0
0%
static {...}
M: 5 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 1 C: 0
0%
M: 1 C: 0
0%

Coverage

1: /*******************************************************************************
2: * Copyright (c) 2017, 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.broker.core.plugin.metric;
14:
15: import com.codahale.metrics.Counter;
16: import com.codahale.metrics.Histogram;
17: import com.codahale.metrics.Timer;
18: import org.eclipse.kapua.commons.metric.MetricServiceFactory;
19: import org.eclipse.kapua.commons.metric.MetricsService;
20:
21: public class PublishMetric {
22:
23: private static final PublishMetric PUBLISH_METRIC = new PublishMetric();
24:
25: private Counter allowedMessages;
26: private Counter notAllowedMessages;
27: private Timer time;
28: // message size
29: private Histogram messageSizeAllowed;
30: private Histogram messageSizeNotAllowed;
31:
32: public static PublishMetric getInstance() {
33: return PUBLISH_METRIC;
34: }
35:
36: private PublishMetric() {
37: MetricsService metricsService = MetricServiceFactory.getInstance();
38: // publish/subscribe
39: allowedMessages = metricsService.getCounter(SecurityMetrics.METRIC_MODULE_NAME, SecurityMetrics.METRIC_COMPONENT_PUBLISH, SecurityMetrics.METRIC_ALLOWED, SecurityMetrics.METRIC_COUNT);
40: notAllowedMessages = metricsService.getCounter(SecurityMetrics.METRIC_MODULE_NAME, SecurityMetrics.METRIC_COMPONENT_PUBLISH, SecurityMetrics.METRIC_NOT_ALLOWED, SecurityMetrics.METRIC_COUNT);
41: time = metricsService.getTimer(SecurityMetrics.METRIC_MODULE_NAME, SecurityMetrics.METRIC_COMPONENT_PUBLISH, SecurityMetrics.METRIC_TIME, SecurityMetrics.METRIC_S);
42: // message size
43: messageSizeAllowed = metricsService.getHistogram(SecurityMetrics.METRIC_MODULE_NAME, SecurityMetrics.METRIC_COMPONENT_PUBLISH, SecurityMetrics.METRIC_MESSAGES, SecurityMetrics.METRIC_ALLOWED, SecurityMetrics.METRIC_SIZE, SecurityMetrics.METRIC_BYTES);
44: messageSizeNotAllowed = metricsService.getHistogram(SecurityMetrics.METRIC_MODULE_NAME, SecurityMetrics.METRIC_COMPONENT_PUBLISH, SecurityMetrics.METRIC_MESSAGES, SecurityMetrics.METRIC_NOT_ALLOWED, SecurityMetrics.METRIC_SIZE, SecurityMetrics.METRIC_BYTES);
45: }
46:
47: public Counter getAllowedMessages() {
48: return allowedMessages;
49: }
50:
51: public Counter getNotAllowedMessages() {
52: return notAllowedMessages;
53: }
54:
55: public Timer getTime() {
56: return time;
57: }
58:
59: public Histogram getMessageSizeAllowed() {
60: return messageSizeAllowed;
61: }
62:
63: public Histogram getMessageSizeNotAllowed() {
64: return messageSizeNotAllowed;
65: }
66:
67: }