private void addCumulatedMetrics(SamplerMetric metric) { int total = metric.getTotal(); if (total > 0) { StringBuilder tag = new StringBuilder(70); StringBuilder field = new StringBuilder(100); Collection<Float> pcts = allPercentiles.values(); tag.append(TAG_APPLICATION).append(application); tag.append(TAG_TRANSACTION).append(CUMULATED_METRICS); tag.append(TAG_STATUS).append(CUMULATED_METRICS); tag.append(userTag); field.append(METRIC_COUNT).append(total); field.append(',').append(METRIC_COUNT_ERROR).append(metric.getFailures()); if (!Double.isNaN(metric.getOkMean())) { field.append(',').append(METRIC_AVG).append(Double.toString(metric.getOkMean())); } if (!Double.isNaN(metric.getOkMinTime())) { field.append(',').append(METRIC_MIN).append(Double.toString(metric.getOkMinTime())); } if (!Double.isNaN(metric.getOkMaxTime())) { field.append(',').append(METRIC_MAX).append(Double.toString(metric.getOkMaxTime())); } field.append(',').append(METRIC_HIT).append(metric.getHits()); field.append(',').append(METRIC_SENT_BYTES).append(metric.getSentBytes()); field.append(',').append(METRIC_RECEIVED_BYTES).append(metric.getReceivedBytes()); for (Float pct : pcts) { field.append(',').append(METRIC_PCT_PREFIX).append(pct).append('=').append(Double.toString(metric.getAllPercentile(pct))); } influxdbMetricsManager.addMetric(measurement, tag.toString(), field.toString()); } }
graphiteMetricsManager.addMetric(timestampInSeconds, contextName, METRIC_OK_MIN_RESPONSE_TIME, Double.toString(metric.getOkMinTime())); graphiteMetricsManager.addMetric(timestampInSeconds, contextName, METRIC_OK_MAX_RESPONSE_TIME,
/** * 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)); }