Bug 1091072 - Group metrics with no metrics in Cassandra can result in averages that are NaN or contain partial results
Summary: Group metrics with no metrics in Cassandra can result in averages that are Na...
Keywords:
Status: NEW
Alias: None
Product: RHQ Project
Classification: Other
Component: Monitoring
Version: 4.9
Hardware: Unspecified
OS: Unspecified
unspecified
unspecified vote
Target Milestone: ---
: ---
Assignee: Nobody
QA Contact: Mike Foley
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2014-04-24 19:18 UTC by Elias Ross
Modified: 2020-04-27 01:28 UTC (History)
1 user (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed:


Attachments (Terms of Use)

Description Elias Ross 2014-04-24 19:18:15 UTC
Description of problem:

If a group only has some resources reporting values, the result is NaN for the entire group.

The use case is: I have a number of servers calculating a count of bad requests. about 80% return results, the remaining 20% do not have this calculation feature yet. The average should not 'count' 20% of those servers, since they have nothing to report. So I would expect the average to 'skip' NaN values.

This happens for the following methods:

MetricsServer {
   public AggregateNumericMetric getSummaryAggregate(List<Integer> scheduleIds, long beginTime, long endTime) {

This is one possible solution, although it may make sense to 'fix' ArithmeticMeanCalculator to ignore NaN entirely.

diff --git a/modules/enterprise/server/server-metrics/src/main/java/org/rhq/server/metrics/MetricsServer.java b/modules/enterprise/server/server-metrics/src/m
index e9f774f..813f451 100644
--- a/modules/enterprise/server/server-metrics/src/main/java/org/rhq/server/metrics/MetricsServer.java
+++ b/modules/enterprise/server/server-metrics/src/main/java/org/rhq/server/metrics/MetricsServer.java
@@ -607,6 +607,10 @@ private AggregateNumericMetric calculateAggregatedRaw(Iterable<RawNumericMetric>
 
         for (RawNumericMetric metric : rawMetrics) {
             value = metric.getValue();
+            if (value == Double.NaN) {
+                // count these values?
+                continue;
+            }
             if (count == 0) {
                 min = value;
                 max = min;

It is used in these classes:

MetricsBaselineCalculator -- If some NaN values exist, the baseline should probably just be from the extant values.
MetricsServer.calculateAggregate -- ???
Compute1HourData -- etc. ???


Version-Release number of selected component (if applicable): 4.9


How reproducible: Always


Steps to Reproduce:
1. Create a group of resources
2. Some resources return values
3. Others do not

Actual results: NaN reported for entire group


Expected results: Average


Additional info:

Comment 1 Elias Ross 2014-04-24 19:19:40 UTC
The other question is if NaN should be excluded from baselines and aggregation calculation might be settled in a separate bug.

Comment 2 Elias Ross 2014-04-24 21:05:41 UTC
The real issue seems to come from pagination not working correctly.

(Still I wonder if NaN handling is correct...)

diff --git a/modules/enterprise/server/server-metrics/src/main/java/org/rhq/server/metrics/domain/ListPagedResult.java b/modules/enterprise/server/server-metrics/src/main/java/org/rhq/server/metrics/domai
index f3abd20..2e929c5 100644
--- a/modules/enterprise/server/server-metrics/src/main/java/org/rhq/server/metrics/domain/ListPagedResult.java
+++ b/modules/enterprise/server/server-metrics/src/main/java/org/rhq/server/metrics/domain/ListPagedResult.java
@@ -74,7 +74,7 @@ private ResultSet retrieveNextResultSet(ResultSet existingResultSet, List<Intege
             while ((existingResultSet == null || existingResultSet.isExhausted()) && ids.size() != 0) {
                 BoundStatement boundStatement = this.preparedStatement.bind(ids.remove(0), new Date(startTime),
                     new Date(endTime));
-                return session.execute(boundStatement);
+                existingResultSet = session.execute(boundStatement);
             }
         } catch (NoHostAvailableException e) {
             throw new CQLException(e);


Note You need to log in before you can comment on or make changes to this bug.