Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgraded prometheus to newest version #122

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<url>https://github.com/johrstrom/jmeter-prometheus-plugin</url>

<properties>
<prometheus.version>0.6.0</prometheus.version>
<prometheus.version>0.16.0</prometheus.version>
<jmeter.version>5.5</jmeter.version>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public void testSuccess() {
foundFailure = true;

break;
case "something_ratio_total":
case "something_ratio":
assertOnSingleFamily(family, 1);
foundTotal = true;

Expand Down Expand Up @@ -92,7 +92,7 @@ public void testFailure() {
foundFailure = true;

break;
case "otherthing_ratio_total":
case "otherthing_ratio":
assertOnSingleFamily(family, 1);
foundTotal = true;

Expand All @@ -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());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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;

Expand All @@ -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<MetricFamilySamples> 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<String> values = sample.labelValues;
Expand All @@ -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);
Expand All @@ -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<MetricFamilySamples> 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<String> values = sample.labelValues;
Expand All @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,15 +62,15 @@ public void testHistogramResponseTime() {
List<MetricFamilySamples> 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<String> values = sample.labelValues;
List<String> 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]) &&
Expand All @@ -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);
}

Expand Down Expand Up @@ -143,8 +145,8 @@ public void testSummaryResponseTime() {
List<MetricFamilySamples> 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<String> values = sample.labelValues;
Expand All @@ -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);
}

Expand Down Expand Up @@ -212,22 +216,24 @@ public void testHistogramResponseSize() {
List<MetricFamilySamples> 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<String> values = sample.labelValues;
List<String> names = sample.labelNames;

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);
}

Expand Down Expand Up @@ -283,22 +289,24 @@ public void testSummaryResponseSize() {
List<MetricFamilySamples> 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<String> values = sample.labelValues;
List<String> names = sample.labelNames;

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);
}

Expand Down