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

HdrSummary based on Summary and HdrHistogram #484

Closed
wants to merge 13 commits into from
Closed
Original file line number Diff line number Diff line change
@@ -1,20 +1,14 @@
package io.prometheus.benchmark;

import com.codahale.metrics.MetricRegistry;

import java.util.concurrent.TimeUnit;
import org.openjdk.jmh.annotations.BenchmarkMode;
import org.openjdk.jmh.annotations.Mode;
import org.openjdk.jmh.annotations.Benchmark;
import org.openjdk.jmh.annotations.OutputTimeUnit;
import org.openjdk.jmh.annotations.Scope;
import org.openjdk.jmh.annotations.Setup;
import org.openjdk.jmh.annotations.State;
import org.openjdk.jmh.annotations.*;
import org.openjdk.jmh.runner.Runner;
import org.openjdk.jmh.runner.RunnerException;
import org.openjdk.jmh.runner.options.Options;
import org.openjdk.jmh.runner.options.OptionsBuilder;

import java.util.concurrent.TimeUnit;

@State(Scope.Benchmark)
public class SummaryBenchmark {

Expand All @@ -23,45 +17,53 @@ public class SummaryBenchmark {

io.prometheus.client.metrics.Summary prometheusSummary;
io.prometheus.client.metrics.Summary.Child prometheusSummaryChild;

io.prometheus.client.Summary prometheusSimpleSummary;
io.prometheus.client.Summary.Child prometheusSimpleSummaryChild;
io.prometheus.client.Summary prometheusSimpleSummaryNoLabels;
io.prometheus.client.Summary prometheusSimpleSummaryQuantiles;
io.prometheus.client.Summary.Child prometheusSimpleSummaryQuantilesChild;
io.prometheus.client.Summary prometheusSimpleSummaryQuantilesNoLabels;

io.prometheus.client.Histogram prometheusSimpleHistogram;
io.prometheus.client.Histogram.Child prometheusSimpleHistogramChild;
io.prometheus.client.Histogram prometheusSimpleHistogramNoLabels;

@Setup
public void setup() {
registry = new MetricRegistry();
codahaleHistogram = registry.histogram("name");

prometheusSummary = io.prometheus.client.metrics.Summary.newBuilder()
.name("name")
.documentation("some description..")
.name("name").documentation("some description..")
.build();
prometheusSummaryChild = prometheusSummary.newPartial().apply();

prometheusSimpleSummary = io.prometheus.client.Summary.build()
.name("name")
.help("some description..")
.labelNames("some", "group").create();
prometheusSimpleSummaryChild = prometheusSimpleSummary.labels("test", "group");

prometheusSimpleSummaryNoLabels = io.prometheus.client.Summary.build()
.name("name")
.help("some description..")
.name("name").help("some description..")
.create();

prometheusSimpleSummaryQuantiles = io.prometheus.client.Summary.build()
.name("name").help("some description..")
.labelNames("some", "group")
.quantile(0.5).quantile(0.9).quantile(0.95).quantile(0.99)
.create();
prometheusSimpleSummaryQuantilesChild = prometheusSimpleSummaryQuantiles.labels("test", "group");

prometheusSimpleSummaryQuantilesNoLabels = io.prometheus.client.Summary.build()
.name("name").help("some description..")
.quantile(0.5).quantile(0.9).quantile(0.95).quantile(0.99)
.create();

prometheusSimpleHistogram = io.prometheus.client.Histogram.build()
.name("name")
.help("some description..")
.labelNames("some", "group").create();
.name("name").help("some description..")
.labelNames("some", "group")
.create();
prometheusSimpleHistogramChild = prometheusSimpleHistogram.labels("test", "group");

prometheusSimpleHistogramNoLabels = io.prometheus.client.Histogram.build()
.name("name")
.help("some description..")
.name("name").help("some description..")
.create();

registry = new MetricRegistry();
codahaleHistogram = registry.histogram("name");
}

@Benchmark
Expand All @@ -82,21 +84,42 @@ public void prometheusSummaryChildBenchmark() {
@BenchmarkMode({Mode.AverageTime})
@OutputTimeUnit(TimeUnit.NANOSECONDS)
public void prometheusSimpleSummaryBenchmark() {
prometheusSimpleSummary.labels("test", "group").observe(1) ;
prometheusSimpleSummary.labels("test", "group").observe(1);
}

@Benchmark
@BenchmarkMode({Mode.AverageTime})
@OutputTimeUnit(TimeUnit.NANOSECONDS)
public void prometheusSimpleSummaryChildBenchmark() {
prometheusSimpleSummaryChild.observe(1);
prometheusSimpleSummaryChild.observe(1);
}

@Benchmark
@BenchmarkMode({Mode.AverageTime})
@OutputTimeUnit(TimeUnit.NANOSECONDS)
public void prometheusSimpleSummaryNoLabelsBenchmark() {
prometheusSimpleSummaryNoLabels.observe(1);
prometheusSimpleSummaryNoLabels.observe(1);
}

@Benchmark
@BenchmarkMode({Mode.AverageTime})
@OutputTimeUnit(TimeUnit.NANOSECONDS)
public void prometheusSimpleSummaryQuantilesBenchmark() {
prometheusSimpleSummaryQuantiles.labels("test", "group").observe(1);
}

@Benchmark
@BenchmarkMode({Mode.AverageTime})
@OutputTimeUnit(TimeUnit.NANOSECONDS)
public void prometheusSimpleSummaryQuantilesChildBenchmark() {
prometheusSimpleSummaryQuantilesChild.observe(1);
}

@Benchmark
@BenchmarkMode({Mode.AverageTime})
@OutputTimeUnit(TimeUnit.NANOSECONDS)
public void prometheusSimpleSummaryQuantilesNoLabelsBenchmark() {
prometheusSimpleSummaryQuantilesNoLabels.observe(1);
}

@Benchmark
Expand Down Expand Up @@ -139,4 +162,5 @@ public static void main(String[] args) throws RunnerException {

new Runner(opt).run();
}

}
59 changes: 58 additions & 1 deletion simpleclient/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
<name>Prometheus Java Simpleclient</name>
<description>
Core instrumentation library for the simpleclient.
Collectors using HdrHistogram.
</description>

<licenses>
Expand All @@ -31,13 +32,69 @@
<name>Brian Brazil</name>
<email>brian.brazil@boxever.com</email>
</developer>
<developer>
<id>rrakos-evo</id>
<name>Rudolf Rakos</name>
<email>rrakos@evolutiongaming.com</email>
</developer>
</developers>

<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>3.2.1</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<artifactSet>
<includes>
<include>org.hdrhistogram:HdrHistogram</include>
</includes>
</artifactSet>
<relocations>
<relocation>
<pattern>org.HdrHistogram</pattern>
<shadedPattern>io.prometheus.shaded.hdrhistogram</shadedPattern>
</relocation>
</relocations>
<filters>
<filter>
<!--
Shading signed JARs will fail without this.
http://stackoverflow.com/questions/999489/invalid-signature-file-when-attempting-to-run-a-jar
-->
<artifact>*:*</artifact>
<excludes>
<exclude>META-INF/*.SF</exclude>
<exclude>META-INF/*.DSA</exclude>
<exclude>META-INF/*.RSA</exclude>
</excludes>
</filter>
</filters>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>

<dependencies>
<!-- The simpleclient has no dependencies by design, so that
it can be included into any other project without having
to worry about conflicts. -->
to worry about conflicts. See maven-shade-plugin above. -->
<dependency>
<groupId>org.hdrhistogram</groupId>
<artifactId>HdrHistogram</artifactId>
<version>2.1.12</version>
<type>bundle</type>
</dependency>

<!-- Test Dependencies Follow -->
<dependency>
<groupId>junit</groupId>
Expand Down