@ Override public Collection < Symptom > detect ( Collection < Measurement > measurements ) { Collection < Symptom > result = new ArrayList <> ( ) ; MeasurementsTable metrics = MeasurementsTable . of ( measurements ) . type ( metricName ) ; Instant now = context . checkpoint ( ) ; for ( String component : metrics . uniqueComponents ( ) ) { Set < String > addresses = new HashSet <> ( ) ; Set < String > positiveAddresses = new HashSet <> ( ) ; Set < String > negativeAddresses = new HashSet <> ( ) ; double componentMax = getMaxOfAverage ( metrics . component ( component ) ) ; double componentMin = getMinOfAverage ( metrics . component ( component ) ) ; if ( componentMax > skewRatio * componentMin ) { //there is skew addresses . add ( component ) ; result . add ( new Symptom ( symptomType . text ( ) , now , addresses ) ) ; for ( String instance : metrics . component ( component ) . uniqueInstances ( ) ) { if ( metrics . instance ( instance ) . mean ( ) >= 0.90 * componentMax ) { positiveAddresses . add ( instance ) ; } if ( metrics . instance ( instance ) . mean ( ) <= 1.10 * componentMin ) { negativeAddresses . add ( instance ) ; } } if ( ! positiveAddresses . isEmpty ( ) ) { result . add ( new Symptom ( "POSITIVE " + symptomType . text ( ) , now , positiveAddresses ) ) ; } if ( ! negativeAddresses . isEmpty ( ) ) { result . add ( new Symptom ( "NEGATIVE " + symptomType . text ( ) , now , negativeAddresses ) ) ; } } } return result ; }
Detects components experiencing skew on a specific metric