Source:
public Collection<Diagnosis> diagnose(Collection<Symptom> symptoms) { Collection<Diagnosis> diagnoses = new ArrayList<>(); SymptomsTable symptomsTable = SymptomsTable.of(symptoms); SymptomsTable bp = symptomsTable.type(SYMPTOM_COMP_BACK_PRESSURE.text()); if (bp.size() > 1) { throw new IllegalStateException("Multiple back-pressure symptoms case"); } if (bp.size() == 0) { return diagnoses; } String bpComponent = bp.first().assignments().iterator().next(); SymptomsTable processingRateSkew = symptomsTable.type(SYMPTOM_PROCESSING_RATE_SKEW.text()); SymptomsTable waitQSkew = symptomsTable.type(SYMPTOM_WAIT_Q_SIZE_SKEW.text()); if (waitQSkew.assignment(bpComponent).size() == 0 || processingRateSkew.assignment(bpComponent).size() > 0) { return diagnoses; } Collection<String> assignments = new ArrayList<>(); Instant newest = context.checkpoint(); Instant oldest = context.previousCheckpoint(); MeasurementsTable measurements = context.measurements() .between(oldest, newest) .component(bpComponent); for (String instance : measurements.uniqueInstances()) { MeasurementsTable instanceMeasurements = measurements.instance(instance); double waitQSize = instanceMeasurements.type(METRIC_WAIT_Q_SIZE.text()).mean(); if (measurements.type(METRIC_WAIT_Q_SIZE.text()).max() < waitQSize * 2) { assignments.add(instance); LOG.info(String.format("SLOW: %s back-pressure and high buffer size: %s " + "and similar processing rates", instance, waitQSize)); } } Instant now = context.checkpoint(); if (assignments.size() > 0) { diagnoses.add(new Diagnosis(DIAGNOSIS_SLOW_INSTANCE.text(), now, assignments)); } return diagnoses; }

Target:
public Collection<Diagnosis> diagnose(Collection<Symptom> symptoms) { Collection<Diagnosis> diagnoses = new ArrayList<>(); SymptomsTable symptomsTable = SymptomsTable.of(symptoms); SymptomsTable bp = symptomsTable.type(SYMPTOM_COMP_BACK_PRESSURE.text()); if (bp.size() > 1) { throw new IllegalStateException("Multiple back-pressure symptoms case"); } if (bp.size() == 0) { return diagnoses; } String bpComponent = bp.first().assignments().iterator().next(); SymptomsTable processingRateSkew = symptomsTable.type(SYMPTOM_PROCESSING_RATE_SKEW.text()); SymptomsTable waitQSkew = symptomsTable.type(SYMPTOM_WAIT_Q_SIZE_SKEW.text()); if (waitQSkew.assignment(bpComponent).size() == 0 || processingRateSkew.assignment(bpComponent).size() > 0) { return diagnoses; } Collection<String> assignments = new ArrayList<>(); Instant newest = context.checkpoint(); Instant oldest = context.previousCheckpoint(); MeasurementsTable measurements = context.measurements() .between(oldest, newest) .component(bpComponent); for (String instance : measurements.uniqueInstances()) { MeasurementsTable instanceMeasurements = measurements.instance(instance); double waitQSize = instanceMeasurements.type(METRIC_WAIT_Q_SIZE.text()).mean(); if (measurements.type(METRIC_WAIT_Q_SIZE.text()).max() < waitQSize * 2) { assignments.add(instance); LOG.info(String.format("SLOW: %s back-pressure and high buffer size: %s " + "and similar processing rates", instance, waitQSize)); } } if (assignments.size() > 0) { Instant now = context.checkpoint(); diagnoses.add(new Diagnosis(DIAGNOSIS_SLOW_INSTANCE.text(), now, assignments)); } return diagnoses; }