Commits

Ruwan Linton committed 5184d72

Fixing the metrics issues

Comments (0)

Files changed (4)

modules/metrics/src/main/java/org/adroitlogic/metrics/core/MetricsEngineImpl.java

             synchronized (timeSyncLock) { // to make sure the 99% of the cases are not synchronized
                 tempCurrentRecord = currentRecord;
                 if (tempCurrentRecord.isExpired()) {
-                    long previousRecordExpireTime = currentRecord.getExpireAt();// deactivate();
+                    long previousRecordExpireTime = tempCurrentRecord.getExpireAt();// deactivate();
                     // decide whether we want to shift, and how many and do the shift, if required
                     long shiftCount = (System.nanoTime() - previousRecordExpireTime) / stepTimeInNanoSec;
                     long currentRecordExpireTime = previousRecordExpireTime + (shiftCount + 1) * stepTimeInNanoSec;

modules/metrics/src/main/java/org/adroitlogic/metrics/core/MetricsWindow.java

 
     private final StepRecord[] records;
     private final int last;
-    private int pos;
+    private volatile int pos;
 
     public MetricsWindow(int capacity, MetricsEngine metricsEngine) {
         records = new StepRecord[capacity + 2];
         }
     }
 
-    public StepRecord next(long expireAt) {
+    public synchronized StepRecord next(long expireAt) {
         records[pos == 0 ? last : pos - 1].deactivate();
         StepRecord nextActive = records[pos].use(expireAt);
         if (nextActive == null) { // the next record in the pool has not yet been finalized, let it be handled
         return nextActive;
     }
 
-    public StepRecord next(int count, long expireAt) {
+    public synchronized StepRecord next(int count, long expireAt) {
         shift(count);
         return next(expireAt);
     }
         // should be less than its step records expireAt, and hence when you find the list of step records that expireAt
         // after the timestamp of the a metrics record that contains the step record having the metrics record that we
         // have previously seen too, hence remove the first element after the reverse to make that correction.
-        results.remove(0);
+        if (!results.isEmpty()) {
+            results.remove(0);
+        }
 
         return results;
     }

modules/uconsole/src/main/webapp/js/graph/line-graph-generic.js

 
 }
 
+var percentValues = [75, 95, 98, 99, 999, 9999];
 function dynamicMultiGraph(graphs, refreshInterval) {
 
     var steps = Number($.cookie("metricsSteps"));
                 if (graphs[stream].allDataTransform != null && graphs[stream].allDataTransform != undefined) {
                     graphs[stream].allDataTransform(dAll);
                 }
+
+                $('.all_avg').text(dAll.mean);
+                $('.all_count').text(dAll.count);
+                $('.all_rate').text(dAll.averageRate);
+                $('.all_min').text(dAll.min);
+                $('.all_max').text(dAll.max);
                 var average = graphs[stream].stats.average;
                 if (average != null) {
                     $('#' + average).html(formatDecimalNumberWithMinify(dAll.mean));
                 if (median != null) {
                     $('#' + median).html(formatDecimalNumber4WithMinify(dAll.median));
                 }
-                var percentValues = [75, 95, 98, 99, 999, 9999];
+
                 for (var percent in percentValues) {
                     var percentKey = "_" + percentValues[percent] + "Percentile";
+                    $('.all_' + percentValues[percent]).text(dAll[percentKey]);
                     var percentile = graphs[stream].stats[percentKey];
                     if (percentile != null) {
                         $('#' + percentile).html(formatDecimalNumber4WithMinify(dAll[percentKey]));
                 if (graphs[stream].dataTransform != null && graphs[stream].dataTransform != undefined) {
                     graphs[stream].dataTransform(d);
                 }
+                $('.current_avg').text(d.mean);
+                $('.current_count').text(d.count);
+                $('.current_rate').text(d.averageRate);
+                $('.current_min').text(d.min);
+                $('.current_max').text(d.max);
+                for (var percent in percentValues) {
+                    var percentKey = "_" + percentValues[percent] + "Percentile";
+                    $('.current_' + percentValues[percent]).text(d[percentKey]);
+                }
                 if (d.timestamp > nextCallTime) {
                     nextCallTime = d.timestamp;
                 }
                         if (graphs[stream].allDataTransform != null && graphs[stream].allDataTransform != undefined) {
                             graphs[stream].allDataTransform(dAll);
                         }
+                        $('.all_avg').text(dAll.mean);
+                        $('.all_count').text(dAll.count);
+                        $('.all_rate').text(dAll.averageRate);
+                        $('.all_min').text(dAll.min);
+                        $('.all_max').text(dAll.max);
                         var average = graphs[stream].stats.average;
                         if (average != null) {
                             $('#' + average).html(formatDecimalNumberWithMinify(dAll.mean));
                         var percentValues = [75, 95, 98, 99, 999, 9999];
                         for (var percent in percentValues) {
                             var percentKey = "_" + percentValues[percent] + "Percentile";
+                            $('.all_' + percentValues[percent]).text(dAll[percentKey]);
                             var percentile = graphs[stream].stats[percentKey];
                             if (percentile != null) {
                                 $('#' + percentile).html(formatDecimalNumber4WithMinify(dAll[percentKey]));
                             if (graphs[stream].dataTransform != null && graphs[stream].dataTransform != undefined) {
                                 graphs[stream].dataTransform(d);
                             }
+                            $('.current_avg').text(d.mean);
+                            $('.current_count').text(d.count);
+                            $('.current_rate').text(d.averageRate);
+                            $('.current_min').text(d.min);
+                            $('.current_max').text(d.max);
+                            for (var percent in percentValues) {
+                                var percentKey = "_" + percentValues[percent] + "Percentile";
+                                $('.current_' + percentValues[percent]).text(d[percentKey]);
+                            }
                             if (d.timestamp > nextCallTime) {
                                 nextCallTime = d.timestamp;
                             }

modules/uconsole/src/main/webapp/monitoring/metrics-graph.html

                 </div>
             </div>
 
+            <br/>
+            <br/>
+            <div style="margin-top: 20px;">
+                <table class="display" id="metricsdetails">
+                    <thead>
+                    <tr>
+                        <th></th>
+                        <th></th>
+                        <th></th>
+                    </tr>
+                    </thead>
+                    <tbody>
+                    <tr>
+                        <td style="font-weight: bold">Parameter</td>
+                        <td style="font-weight: bold">Current</td>
+                        <td style="font-weight: bold">All Time</td>
+                    </tr>
+                    <tr>
+                        <td style="font-weight: bold">Average</td>
+                        <td class="current_avg"></td>
+                        <td class="all_avg"></td>
+                    </tr>
+                    <tr>
+                        <td style="font-weight: bold">Count</td>
+                        <td class="current_count"></td>
+                        <td class="all_count"></td>
+                    </tr>
+                    <tr>
+                        <td style="font-weight: bold">Rate</td>
+                        <td class="current_rate"></td>
+                        <td class="all_rate"></td>
+                    </tr>
+                    <tr>
+                        <td style="font-weight: bold">Min</td>
+                        <td class="current_min"></td>
+                        <td class="all_min"></td>
+                    </tr>
+                    <tr>
+                        <td style="font-weight: bold">Max</td>
+                        <td class="current_max"></td>
+                        <td class="all_max"></td>
+                    </tr>
+                    <tr>
+                        <td style="font-weight: bold">75<sup>th</sup> Percentile</td>
+                        <td class="current_75"></td>
+                        <td class="all_75"></td>
+                    </tr>
+                    <tr>
+                        <td style="font-weight: bold">95<sup>th</sup> Percentile</td>
+                        <td class="current_95"></td>
+                        <td class="all_95"></td>
+                    </tr>
+                    <tr>
+                        <td style="font-weight: bold">98<sup>th</sup> Percentile</td>
+                        <td class="current_98"></td>
+                        <td class="all_98"></td>
+                    </tr>
+                    <tr>
+                        <td style="font-weight: bold">99<sup>th</sup> Percentile</td>
+                        <td class="current_99"></td>
+                        <td class="all_99"></td>
+                    </tr>
+                    <tr>
+                        <td style="font-weight: bold">99.9<sup>th</sup> Percentile</td>
+                        <td class="current_999"></td>
+                        <td class="all_999"></td>
+                    </tr>
+                    <tr>
+                        <td style="font-weight: bold">99.99<sup>th</sup> Percentile</td>
+                        <td class="current_9999"></td>
+                        <td class="all_9999"></td>
+                    </tr>
+                    </tbody>
+                </table>
+            </div>
+
         </fieldset>
         <!--<button id="final_action" type="button" class="clickable button" onclick="updateAlertConfig()" style="margin-left: 20px; margin-top: 20px;">Update Config</button>-->
         <!--<button type="button" class="clickable button" style="margin-top: 20px;" onclick="window.location.href = 'index.html?pageName=monitoring/alert-configurations.html&bc=3'">Cancel</button>-->