diff --git a/pom.xml b/pom.xml
index 837750b..4e2f77b 100644
--- a/pom.xml
+++ b/pom.xml
@@ -8,7 +8,7 @@
https://github.com/johrstrom/jmeter-prometheus-plugin
- 0.6.0
+ 0.16.0
5.5
1.8
1.8
diff --git a/src/test/java/com/github/johrstrom/collector/SuccessRatioCollectorTest.java b/src/test/java/com/github/johrstrom/collector/SuccessRatioCollectorTest.java
index 580819a..d323b33 100644
--- a/src/test/java/com/github/johrstrom/collector/SuccessRatioCollectorTest.java
+++ b/src/test/java/com/github/johrstrom/collector/SuccessRatioCollectorTest.java
@@ -47,7 +47,7 @@ public void testSuccess() {
foundFailure = true;
break;
- case "something_ratio_total":
+ case "something_ratio":
assertOnSingleFamily(family, 1);
foundTotal = true;
@@ -92,7 +92,7 @@ public void testFailure() {
foundFailure = true;
break;
- case "otherthing_ratio_total":
+ case "otherthing_ratio":
assertOnSingleFamily(family, 1);
foundTotal = true;
@@ -107,7 +107,7 @@ public void testFailure() {
}
private void assertOnSingleFamily(MetricFamilySamples family, double expectedValue) {
- Assert.assertEquals(1, family.samples.size());
+ Assert.assertEquals(2, family.samples.size());
Sample sample = family.samples.get(0);
Assert.assertArrayEquals(labelValues, sample.labelValues.toArray());
diff --git a/src/test/java/com/github/johrstrom/listener/PrometheusListenerTest.java b/src/test/java/com/github/johrstrom/listener/PrometheusListenerTest.java
index 16079fa..f1e8920 100644
--- a/src/test/java/com/github/johrstrom/listener/PrometheusListenerTest.java
+++ b/src/test/java/com/github/johrstrom/listener/PrometheusListenerTest.java
@@ -113,6 +113,7 @@ public void updateAllTypes() {
long latency = 1532;
int responseSize = 1342;
int samplesOccurred = 0;
+ double expectedCreated = System.currentTimeMillis() / 1000.0;
ResultAndVariables res = TestUtilities.resultWithLabels();
res.result.setConnectTime(connectTime);
@@ -155,42 +156,42 @@ public void updateAllTypes() {
// histograms
case "test_hist_rtime":
- assertOnHistogram(reg.getOrCreateAndRegister(cfg), elapsedTime * samplesOccurred, samplesOccurred,
+ assertOnHistogram(reg.getOrCreateAndRegister(cfg), elapsedTime * samplesOccurred, samplesOccurred, expectedCreated,
elapsedTime);
break;
case "test_hist_rsize":
- assertOnHistogram(reg.getOrCreateAndRegister(cfg), responseSize * samplesOccurred, samplesOccurred,
+ assertOnHistogram(reg.getOrCreateAndRegister(cfg), responseSize * samplesOccurred, samplesOccurred, expectedCreated,
responseSize);
break;
case "test_hist_latency":
- assertOnHistogram(reg.getOrCreateAndRegister(cfg), latency * samplesOccurred, samplesOccurred, latency);
+ assertOnHistogram(reg.getOrCreateAndRegister(cfg), latency * samplesOccurred, samplesOccurred, expectedCreated, latency);
break;
case "test_hist_idle_time":
- assertOnHistogram(reg.getOrCreateAndRegister(cfg), idleTime * samplesOccurred, samplesOccurred,
+ assertOnHistogram(reg.getOrCreateAndRegister(cfg), idleTime * samplesOccurred, samplesOccurred, expectedCreated,
idleTime);
break;
case "test_hist_connect_time":
- assertOnHistogram(reg.getOrCreateAndRegister(cfg), connectTime * samplesOccurred, samplesOccurred,
+ assertOnHistogram(reg.getOrCreateAndRegister(cfg), connectTime * samplesOccurred, samplesOccurred, expectedCreated,
connectTime);
break;
// summaries
case "test_summary_rtime":
- assertOnSummary(reg.getOrCreateAndRegister(cfg), elapsedTime * samplesOccurred, samplesOccurred,
+ assertOnSummary(reg.getOrCreateAndRegister(cfg), elapsedTime * samplesOccurred, samplesOccurred, expectedCreated,
elapsedTime);
break;
case "test_summary_rsize":
- assertOnSummary(reg.getOrCreateAndRegister(cfg), responseSize * samplesOccurred, samplesOccurred,
+ assertOnSummary(reg.getOrCreateAndRegister(cfg), responseSize * samplesOccurred, samplesOccurred, expectedCreated,
responseSize);
break;
case "test_summary_latency":
- assertOnSummary(reg.getOrCreateAndRegister(cfg), latency * samplesOccurred, samplesOccurred, latency);
+ assertOnSummary(reg.getOrCreateAndRegister(cfg), latency * samplesOccurred, samplesOccurred, expectedCreated, latency);
break;
case "test_summary_idle_time":
- assertOnSummary(reg.getOrCreateAndRegister(cfg), idleTime * samplesOccurred, samplesOccurred, idleTime);
+ assertOnSummary(reg.getOrCreateAndRegister(cfg), idleTime * samplesOccurred, samplesOccurred, expectedCreated, idleTime);
break;
case "test_summary_connect_time":
- assertOnSummary(reg.getOrCreateAndRegister(cfg), connectTime * samplesOccurred, samplesOccurred,
+ assertOnSummary(reg.getOrCreateAndRegister(cfg), connectTime * samplesOccurred, samplesOccurred, expectedCreated,
connectTime);
break;
@@ -215,14 +216,14 @@ private void assertOnRatio(ListenerCollectorConfig cfg) {
Assert.assertEquals(2.0, shouldBeTwo, 0.1);
}
- protected static void assertOnHistogram(Collector collector, double expectedSum, double expectedCount,
+ protected static void assertOnHistogram(Collector collector, double expectedSum, double expectedCount, double expectedCreated,
double boundary) {
List metrics = collector.collect();
Assert.assertEquals(1, metrics.size());
MetricFamilySamples family = metrics.get(0);
// labels + Inf + count + sum
- Assert.assertEquals(TestUtilities.EXPECTED_LABELS.length + 4, family.samples.size());
+ Assert.assertEquals(TestUtilities.EXPECTED_LABELS.length + 5, family.samples.size());
for (Sample sample : family.samples) {
List values = sample.labelValues;
@@ -245,6 +246,10 @@ protected static void assertOnHistogram(Collector collector, double expectedSum,
Assert.assertTrue(values.size() == labelSize && names.size() == labelSize);
Assert.assertEquals(expectedSum, sample.value, 0.1);
+ } else if (sample.name.endsWith("created")) {
+ Assert.assertTrue(values.size() == labelSize && names.size() == labelSize);
+ Assert.assertEquals(expectedCreated, sample.value, 0.1);
+
} else {
Assert.assertEquals(values.size(), labelSize + 1);
Assert.assertEquals(names.size(), labelSize + 1);
@@ -265,13 +270,13 @@ protected static void assertOnHistogram(Collector collector, double expectedSum,
}
}
- protected void assertOnSummary(Collector collector, double expectedSum, double expectedCount,
+ protected void assertOnSummary(Collector collector, double expectedSum, double expectedCount, double expectedCreated,
double expectedValue) {
List metrics = collector.collect();
Assert.assertEquals(1, metrics.size());
MetricFamilySamples family = metrics.get(0);
- Assert.assertEquals(5, family.samples.size()); // 3 quantiles + count + sum
+ Assert.assertEquals(6, family.samples.size()); // 3 quantiles + count + sum
for (Sample sample : family.samples) {
List values = sample.labelValues;
@@ -291,6 +296,8 @@ protected void assertOnSummary(Collector collector, double expectedSum, double e
} else if (sample.name.endsWith("sum")) {
Assert.assertEquals(expectedSum, sample.value, 0.1);
+ } else if (sample.name.endsWith("created")) {
+ Assert.assertEquals(expectedCreated, sample.value, 0.1);
} else {
Assert.assertEquals(values.size(), TestUtilities.EXPECTED_LABELS.length + 1);
Assert.assertEquals(values.size(), TestUtilities.EXPECTED_LABELS.length + 1);
diff --git a/src/test/java/com/github/johrstrom/listener/updater/AggregatedTypeUpdaterTest.java b/src/test/java/com/github/johrstrom/listener/updater/AggregatedTypeUpdaterTest.java
index 7157821..86f143c 100644
--- a/src/test/java/com/github/johrstrom/listener/updater/AggregatedTypeUpdaterTest.java
+++ b/src/test/java/com/github/johrstrom/listener/updater/AggregatedTypeUpdaterTest.java
@@ -62,15 +62,15 @@ public void testHistogramResponseTime() {
List metrics = collector.collect();
assertEquals(1, metrics.size());
MetricFamilySamples family = metrics.get(0);
- assertEquals(7, family.samples.size()); // 4 buckets + Inf + count + sum
-
-
+ assertEquals(8, family.samples.size()); // 4 buckets + Inf + count + sum
+
+
for(Sample sample : family.samples) {
List values = sample.labelValues;
List names = sample.labelNames;
//correct labels without 'le' (bin size)
- boolean correctLabels = names.get(0).equals(labels[0]) &&
+ boolean correctLabels = names.get(0).equals(labels[0]) &&
names.get(1).equals(labels[1]) &&
names.get(2).equals(labels[2]) &&
values.get(0).equals(expectedLabels[0]) &&
@@ -80,12 +80,14 @@ public void testHistogramResponseTime() {
assertTrue(correctLabels);
// _sum and _count don't have an 'le' label
- if(sample.name.endsWith("count") || sample.name.endsWith("sum")) {
+ if(sample.name.endsWith("count") || sample.name.endsWith("sum") || sample.name.endsWith("created")) {
assertTrue(values.size() == 3 && names.size() == 3);
if(sample.name.endsWith("count")) {
Assert.assertEquals(1, sample.value, 0.1);
- }else {
+ } else if (sample.name.endsWith("created")) {
+ Assert.assertEquals(System.currentTimeMillis() / 1000.0, sample.value, 0.1);
+ } else {
Assert.assertEquals(responseTime, sample.value, 0.1);
}
@@ -143,8 +145,8 @@ public void testSummaryResponseTime() {
List metrics = collector.collect();
assertEquals(1, metrics.size());
MetricFamilySamples family = metrics.get(0);
- assertEquals(5, family.samples.size()); // 3 quantiles + count + sum
-
+ assertEquals(6, family.samples.size()); // 3 quantiles + count + sum
+
for(Sample sample : family.samples) {
List values = sample.labelValues;
@@ -161,12 +163,14 @@ public void testSummaryResponseTime() {
assertTrue(correctLabels);
// _sum and _count don't have an 'le' label
- if(sample.name.endsWith("count") || sample.name.endsWith("sum")) {
+ if(sample.name.endsWith("count") || sample.name.endsWith("sum") || sample.name.endsWith("created")) {
assertTrue(values.size() == 3 && names.size() == 3);
if(sample.name.endsWith("count")) {
Assert.assertEquals(1, sample.value, 0.1);
- }else {
+ }else if (sample.name.endsWith("created")) {
+ Assert.assertEquals(System.currentTimeMillis() / 1000.0, sample.value, 0.1);
+ } else {
Assert.assertEquals(responseTime, sample.value, 0.1);
}
@@ -212,9 +216,9 @@ public void testHistogramResponseSize() {
List metrics = collector.collect();
Assert.assertEquals(1, metrics.size());
MetricFamilySamples family = metrics.get(0);
- Assert.assertEquals(7, family.samples.size()); // 4 buckets + Inf + count + sum
-
-
+ Assert.assertEquals(8, family.samples.size()); // 4 buckets + Inf + count + sum
+
+
for(Sample sample : family.samples) {
List values = sample.labelValues;
List names = sample.labelNames;
@@ -222,12 +226,14 @@ public void testHistogramResponseSize() {
this.correctLabels(names, values);
// _sum and _count don't have an 'le' label
- if(sample.name.endsWith("count") || sample.name.endsWith("sum")) {
+ if(sample.name.endsWith("count") || sample.name.endsWith("sum") || sample.name.endsWith("created")) {
assertTrue(values.size() == 3 && names.size() == 3);
if(sample.name.endsWith("count")) {
Assert.assertEquals(1, sample.value, 0.1);
- }else {
+ } else if (sample.name.endsWith("created")) {
+ Assert.assertEquals(System.currentTimeMillis() / 1000.0, sample.value, 0.1);
+ } else {
Assert.assertEquals(responseSize, sample.value, 0.1);
}
@@ -283,9 +289,9 @@ public void testSummaryResponseSize() {
List metrics = collector.collect();
Assert.assertEquals(1, metrics.size());
MetricFamilySamples family = metrics.get(0);
- Assert.assertEquals(5, family.samples.size()); // 3 quantiles + count + sum
-
-
+ Assert.assertEquals(6, family.samples.size()); // 3 quantiles + count + sum
+
+
for(Sample sample : family.samples) {
List values = sample.labelValues;
List names = sample.labelNames;
@@ -293,12 +299,14 @@ public void testSummaryResponseSize() {
this.correctLabels(names, values);
// _sum and _count don't have an 'le' label
- if(sample.name.endsWith("count") || sample.name.endsWith("sum")) {
+ if(sample.name.endsWith("count") || sample.name.endsWith("sum") || sample.name.endsWith("created")) {
assertTrue(values.size() == 3 && names.size() == 3);
if(sample.name.endsWith("count")) {
Assert.assertEquals(1, sample.value, 0.1);
- }else {
+ } else if (sample.name.endsWith("created")) {
+ Assert.assertEquals(System.currentTimeMillis() / 1000.0, sample.value, 0.1);
+ } else {
Assert.assertEquals(responseSize, sample.value, 0.1);
}