2 * ============LICENSE_START===================================================
3 * SPARKY (AAI UI service)
4 * ============================================================================
5 * Copyright © 2017 AT&T Intellectual Property.
6 * Copyright © 2017 Amdocs
8 * ============================================================================
9 * Licensed under the Apache License, Version 2.0 (the "License");
10 * you may not use this file except in compliance with the License.
11 * You may obtain a copy of the License at
13 * http://www.apache.org/licenses/LICENSE-2.0
15 * Unless required by applicable law or agreed to in writing, software
16 * distributed under the License is distributed on an "AS IS" BASIS,
17 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18 * See the License for the specific language governing permissions and
19 * limitations under the License.
20 * ============LICENSE_END=====================================================
22 * ECOMP and OpenECOMP are trademarks
23 * and service marks of AT&T Intellectual Property.
26 package org.openecomp.sparky.synchronizer;
28 import org.openecomp.sparky.analytics.AbstractStatistics;
29 import org.openecomp.sparky.synchronizer.config.TaskProcessorConfig;
32 * The Class TaskProcessingStats.
34 public class TaskProcessingStats extends AbstractStatistics {
36 private static String TASK_AGE_STATS = "taskAgeStats";
37 private static String TASK_RESPONSE_STATS = "taskResponseStats";
38 private static String RESPONSE_SIZE_IN_BYTES = "taskResponseSizeInBytes";
39 // private static String QUEUE_ITEM_LENGTH = "queueItemLength";
40 private static String TPS = "transactionsPerSecond";
43 * Instantiates a new task processing stats.
45 * @param config the config
47 public TaskProcessingStats(TaskProcessorConfig config) {
49 addHistogram(TASK_AGE_STATS, config.getTaskAgeHistogramLabel(),
50 config.getTaskAgeHistogramMaxYAxis(), config.getTaskAgeHistogramNumBins(),
51 config.getTaskAgeHistogramNumDecimalPoints());
53 addHistogram(TASK_RESPONSE_STATS, config.getResponseTimeHistogramLabel(),
54 config.getResponseTimeHistogramMaxYAxis(), config.getResponseTimeHistogramNumBins(),
55 config.getResponseTimeHistogramNumDecimalPoints());
57 addHistogram(RESPONSE_SIZE_IN_BYTES, config.getBytesHistogramLabel(),
58 config.getBytesHistogramMaxYAxis(), config.getBytesHistogramNumBins(),
59 config.getBytesHistogramNumDecimalPoints());
62 * addHistogram(QUEUE_ITEM_LENGTH, config.getQueueLengthHistogramLabel(),
63 * config.getQueueLengthHistogramMaxYAxis(), config.getQueueLengthHistogramNumBins(),
64 * config.getQueueLengthHistogramNumDecimalPoints());
67 addHistogram(TPS, config.getTpsHistogramLabel(), config.getTpsHistogramMaxYAxis(),
68 config.getTpsHistogramNumBins(), config.getTpsHistogramNumDecimalPoints());
73 * public void updateQueueItemLengthHistogram(long value) { updateHistogram(QUEUE_ITEM_LENGTH,
78 * Update task age stats histogram.
80 * @param value the value
82 public void updateTaskAgeStatsHistogram(long value) {
83 updateHistogram(TASK_AGE_STATS, value);
87 * Update task response stats histogram.
89 * @param value the value
91 public void updateTaskResponseStatsHistogram(long value) {
92 updateHistogram(TASK_RESPONSE_STATS, value);
96 * Update response size in bytes histogram.
98 * @param value the value
100 public void updateResponseSizeInBytesHistogram(long value) {
101 updateHistogram(RESPONSE_SIZE_IN_BYTES, value);
105 * Update transactions per second histogram.
107 * @param value the value
109 public void updateTransactionsPerSecondHistogram(long value) {
110 updateHistogram(TPS, value);
114 * Gets the statistics report.
116 * @param verboseEnabled the verbose enabled
117 * @param indentPadding the indent padding
118 * @return the statistics report
120 public String getStatisticsReport(boolean verboseEnabled, String indentPadding) {
122 StringBuilder sb = new StringBuilder();
124 sb.append("\n").append(getHistogramStats(TASK_AGE_STATS, verboseEnabled, indentPadding));
125 // sb.append("\n").append(getHistogramStats(QUEUE_ITEM_LENGTH, verboseEnabled, indentPadding));
126 sb.append("\n").append(getHistogramStats(TASK_RESPONSE_STATS, verboseEnabled, indentPadding));
128 .append(getHistogramStats(RESPONSE_SIZE_IN_BYTES, verboseEnabled, indentPadding));
129 sb.append("\n").append(getHistogramStats(TPS, verboseEnabled, indentPadding));
131 return sb.toString();