2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright © 2017 AT&T Intellectual Property. All rights reserved.
6 * Copyright © 2017 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 * ECOMP is a trademark and service mark of AT&T Intellectual Property.
23 package org.onap.aai.sparky.synchronizer;
25 import org.onap.aai.sparky.analytics.AbstractStatistics;
26 import org.onap.aai.sparky.synchronizer.config.TaskProcessorConfig;
29 * The Class TaskProcessingStats.
31 public class TaskProcessingStats extends AbstractStatistics {
33 private static String TASK_AGE_STATS = "taskAgeStats";
34 private static String TASK_RESPONSE_STATS = "taskResponseStats";
35 private static String RESPONSE_SIZE_IN_BYTES = "taskResponseSizeInBytes";
36 // private static String QUEUE_ITEM_LENGTH = "queueItemLength";
37 private static String TPS = "transactionsPerSecond";
40 * Instantiates a new task processing stats.
42 * @param config the config
44 public TaskProcessingStats(TaskProcessorConfig config) {
46 addHistogram(TASK_AGE_STATS, config.getTaskAgeHistogramLabel(),
47 config.getTaskAgeHistogramMaxYAxis(), config.getTaskAgeHistogramNumBins(),
48 config.getTaskAgeHistogramNumDecimalPoints());
50 addHistogram(TASK_RESPONSE_STATS, config.getResponseTimeHistogramLabel(),
51 config.getResponseTimeHistogramMaxYAxis(), config.getResponseTimeHistogramNumBins(),
52 config.getResponseTimeHistogramNumDecimalPoints());
54 addHistogram(RESPONSE_SIZE_IN_BYTES, config.getBytesHistogramLabel(),
55 config.getBytesHistogramMaxYAxis(), config.getBytesHistogramNumBins(),
56 config.getBytesHistogramNumDecimalPoints());
59 * addHistogram(QUEUE_ITEM_LENGTH, config.getQueueLengthHistogramLabel(),
60 * config.getQueueLengthHistogramMaxYAxis(), config.getQueueLengthHistogramNumBins(),
61 * config.getQueueLengthHistogramNumDecimalPoints());
64 addHistogram(TPS, config.getTpsHistogramLabel(), config.getTpsHistogramMaxYAxis(),
65 config.getTpsHistogramNumBins(), config.getTpsHistogramNumDecimalPoints());
70 * public void updateQueueItemLengthHistogram(long value) { updateHistogram(QUEUE_ITEM_LENGTH,
75 * Update task age stats histogram.
77 * @param value the value
79 public void updateTaskAgeStatsHistogram(long value) {
80 updateHistogram(TASK_AGE_STATS, value);
84 * Update task response stats histogram.
86 * @param value the value
88 public void updateTaskResponseStatsHistogram(long value) {
89 updateHistogram(TASK_RESPONSE_STATS, value);
93 * Update response size in bytes histogram.
95 * @param value the value
97 public void updateResponseSizeInBytesHistogram(long value) {
98 updateHistogram(RESPONSE_SIZE_IN_BYTES, value);
102 * Update transactions per second histogram.
104 * @param value the value
106 public void updateTransactionsPerSecondHistogram(long value) {
107 updateHistogram(TPS, value);
111 * Gets the statistics report.
113 * @param verboseEnabled the verbose enabled
114 * @param indentPadding the indent padding
115 * @return the statistics report
117 public String getStatisticsReport(boolean verboseEnabled, String indentPadding) {
119 StringBuilder sb = new StringBuilder();
121 sb.append("\n").append(getHistogramStats(TASK_AGE_STATS, verboseEnabled, indentPadding));
122 // sb.append("\n").append(getHistogramStats(QUEUE_ITEM_LENGTH, verboseEnabled, indentPadding));
123 sb.append("\n").append(getHistogramStats(TASK_RESPONSE_STATS, verboseEnabled, indentPadding));
125 .append(getHistogramStats(RESPONSE_SIZE_IN_BYTES, verboseEnabled, indentPadding));
126 sb.append("\n").append(getHistogramStats(TPS, verboseEnabled, indentPadding));
128 return sb.toString();