2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved.
6 * Copyright © 2017-2018 Amdocs
7 * ================================================================================
8 * Licensed under the Apache License, Version 2.0 (the "License");
9 * you may not use this file except in compliance with the License.
10 * You may obtain a copy of the License at
12 * http://www.apache.org/licenses/LICENSE-2.0
14 * Unless required by applicable law or agreed to in writing, software
15 * distributed under the License is distributed on an "AS IS" BASIS,
16 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17 * See the License for the specific language governing permissions and
18 * limitations under the License.
19 * ============LICENSE_END=========================================================
21 package org.onap.aai.sparky.sync;
23 import org.onap.aai.sparky.analytics.AbstractStatistics;
24 import org.onap.aai.sparky.sync.config.NetworkStatisticsConfig;
27 * The Class TaskProcessingStats.
29 public class TaskProcessingStats extends AbstractStatistics {
31 private static String TASK_AGE_STATS = "taskAgeStats";
32 private static String TASK_RESPONSE_STATS = "taskResponseStats";
33 private static String RESPONSE_SIZE_IN_BYTES = "taskResponseSizeInBytes";
34 // private static String QUEUE_ITEM_LENGTH = "queueItemLength";
35 private static String TPS = "transactionsPerSecond";
38 * Instantiates a new task processing stats.
40 * @param config the config
42 public TaskProcessingStats(NetworkStatisticsConfig config) {
44 addHistogram(TASK_AGE_STATS, config.getTaskAgeHistogramLabel(),
45 config.getTaskAgeHistogramMaxYAxis(), config.getTaskAgeHistogramNumBins(),
46 config.getTaskAgeHistogramNumDecimalPoints());
48 addHistogram(TASK_RESPONSE_STATS, config.getResponseTimeHistogramLabel(),
49 config.getResponseTimeHistogramMaxYAxis(), config.getResponseTimeHistogramNumBins(),
50 config.getResponseTimeHistogramNumDecimalPoints());
52 addHistogram(RESPONSE_SIZE_IN_BYTES, config.getBytesHistogramLabel(),
53 config.getBytesHistogramMaxYAxis(), config.getBytesHistogramNumBins(),
54 config.getBytesHistogramNumDecimalPoints());
57 * addHistogram(QUEUE_ITEM_LENGTH, config.getQueueLengthHistogramLabel(),
58 * config.getQueueLengthHistogramMaxYAxis(), config.getQueueLengthHistogramNumBins(),
59 * config.getQueueLengthHistogramNumDecimalPoints());
62 addHistogram(TPS, config.getTpsHistogramLabel(), config.getTpsHistogramMaxYAxis(),
63 config.getTpsHistogramNumBins(), config.getTpsHistogramNumDecimalPoints());
68 * public void updateQueueItemLengthHistogram(long value) { updateHistogram(QUEUE_ITEM_LENGTH,
73 * Update task age stats histogram.
75 * @param value the value
77 public void updateTaskAgeStatsHistogram(long value) {
78 updateHistogram(TASK_AGE_STATS, value);
82 * Update task response stats histogram.
84 * @param value the value
86 public void updateTaskResponseStatsHistogram(long value) {
87 updateHistogram(TASK_RESPONSE_STATS, value);
91 * Update response size in bytes histogram.
93 * @param value the value
95 public void updateResponseSizeInBytesHistogram(long value) {
96 updateHistogram(RESPONSE_SIZE_IN_BYTES, value);
100 * Update transactions per second histogram.
102 * @param value the value
104 public void updateTransactionsPerSecondHistogram(long value) {
105 updateHistogram(TPS, value);
109 * Gets the statistics report.
111 * @param verboseEnabled the verbose enabled
112 * @param indentPadding the indent padding
113 * @return the statistics report
115 public String getStatisticsReport(boolean verboseEnabled, String indentPadding) {
117 StringBuilder sb = new StringBuilder();
119 sb.append("\n").append(getHistogramStats(TASK_AGE_STATS, verboseEnabled, indentPadding));
120 // sb.append("\n").append(getHistogramStats(QUEUE_ITEM_LENGTH, verboseEnabled, indentPadding));
121 sb.append("\n").append(getHistogramStats(TASK_RESPONSE_STATS, verboseEnabled, indentPadding));
123 .append(getHistogramStats(RESPONSE_SIZE_IN_BYTES, verboseEnabled, indentPadding));
124 sb.append("\n").append(getHistogramStats(TPS, verboseEnabled, indentPadding));
126 return sb.toString();