@Override public boolean equals(Object other) { if (!(other instanceof ErrorMetric)) { return false; } ErrorMetric otherError = (ErrorMetric) other; return getResponseCode().equalsIgnoreCase(otherError.getResponseCode()) && getResponseMessage().equalsIgnoreCase(otherError.getResponseMessage()); }
/** * Add a {@link SampleResult} to be used in the statistics * @param result {@link SampleResult} to be used */ public synchronized void add(SampleResult result) { if(result.isSuccessful()) { successes+=result.getSampleCount()-result.getErrorCount(); } else { failures+=result.getErrorCount(); ErrorMetric error = new ErrorMetric(result); errors.put(error, errors.getOrDefault(error, 0) + result.getErrorCount() ); } long time = result.getTime(); allResponsesStats.addValue(time); pctResponseStats.addValue(time); if(result.isSuccessful()) { // Should we also compute KO , all response time ? // only take successful requests for time computing okResponsesStats.addValue(time); }else { koResponsesStats.addValue(time); } addHits(result); addNetworkData(result); }
@Override public int hashCode() { return getResponseCode().toLowerCase().hashCode() + getResponseMessage().toLowerCase().hashCode(); }
/** * Add request metrics to metrics manager. * * @param metric * {@link SamplerMetric} */ private void addMetrics(String transaction, SamplerMetric metric) { // FOR ALL STATUS addMetric(transaction, metric.getTotal(), metric.getSentBytes(), metric.getReceivedBytes(), TAG_ALL, metric.getAllMean(), metric.getAllMinTime(), metric.getAllMaxTime(), allPercentiles.values(), metric::getAllPercentile); // FOR OK STATUS addMetric(transaction, metric.getSuccesses(), null, null, TAG_OK, metric.getOkMean(), metric.getOkMinTime(), metric.getOkMaxTime(), okPercentiles.values(), metric::getOkPercentile); // FOR KO STATUS addMetric(transaction, metric.getFailures(), null, null, TAG_KO, metric.getKoMean(), metric.getKoMinTime(), metric.getKoMaxTime(), koPercentiles.values(), metric::getKoPercentile); metric.getErrors().forEach((error, count) -> addErrorMetric(transaction, error.getResponseCode(), error.getResponseMessage(), count)); }