javalin / website

Javalin website source code
https://javalin.io
36 stars 87 forks source link

[PLUGIN REPORTS] - Micrometer Plugin #268

Open songxychn opened 2 months ago

songxychn commented 2 months ago

the document of Micrometer Plugin is outdated. i'm configuring prometheus for my javalin app. the versions are below:

<dependency>
    <groupId>io.javalin</groupId>
    <artifactId>javalin</artifactId>
    <version>6.1.4</version>
</dependency>
<dependency>
    <groupId>io.javalin</groupId>
    <artifactId>javalin-micrometer</artifactId>
    <version>6.1.3</version>
</dependency>
<dependency>
    <groupId>io.micrometer</groupId>
    <artifactId>micrometer-registry-prometheus</artifactId>
    <version>1.12.5</version>
</dependency>

the code in document can't be compiled correctly. the code below works:

PrometheusMeterRegistry registry = new PrometheusMeterRegistry(PrometheusConfig.DEFAULT);
Javalin.create(config -> {
            config.registerPlugin(new MicrometerPlugin(micrometerPluginConfig -> {
                micrometerPluginConfig.registry = registry;
            }));
        })
        .get("/prometheus", context -> context.contentType(TextFormat.CONTENT_TYPE_004).result(registry.scrape()))
        .start(7000);