Last active
March 10, 2023 18:13
-
-
Save yonatang/377144253dbb5cba4f8dcbb134a31d2f to your computer and use it in GitHub Desktop.
Micrometer issue with prometheus
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import io.micrometer.core.instrument.DistributionSummary; | |
import io.micrometer.prometheus.PrometheusConfig; | |
import io.micrometer.prometheus.PrometheusMeterRegistry; | |
public class Demo { | |
public static void main(String[] args) { | |
PrometheusMeterRegistry registry = new PrometheusMeterRegistry( | |
PrometheusConfig.DEFAULT | |
); | |
DistributionSummary resolveDurationTimer = DistributionSummary.builder("latency") | |
.serviceLevelObjectives(0.08, 0.09) | |
.register(registry); | |
resolveDurationTimer.record(0.085); | |
System.out.println(registry.scrape()); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="UTF-8"?> | |
<project xmlns="http://maven.apache.org/POM/4.0.0" | |
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | |
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | |
<modelVersion>4.0.0</modelVersion> | |
<groupId>org.example</groupId> | |
<artifactId>untitled</artifactId> | |
<version>1.0-SNAPSHOT</version> | |
<properties> | |
<maven.compiler.source>11</maven.compiler.source> | |
<maven.compiler.target>11</maven.compiler.target> | |
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> | |
</properties> | |
<dependencies> | |
<dependency> | |
<groupId>io.micrometer</groupId> | |
<artifactId>micrometer-core</artifactId> | |
<version>1.10.4</version> | |
</dependency> | |
<dependency> | |
<groupId>io.micrometer</groupId> | |
<artifactId>micrometer-registry-prometheus</artifactId> | |
<version>1.10.4</version> | |
</dependency> | |
</dependencies> | |
</project> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment