From 9aa1697d55737776bede492f9fbb8d9632a37e2e Mon Sep 17 00:00:00 2001 From: Scott Jungling Date: Mon, 6 Feb 2023 09:10:49 -0800 Subject: [PATCH] chore: prometheus scrape format changes (#5) clean-up unused dependencies --- build.gradle.kts | 4 +--- .../organizations/OrganizationController.java | 4 ++++ .../OrganizationMetricController.java | 16 ++++++++++++++++ 3 files changed, 21 insertions(+), 3 deletions(-) create mode 100644 src/main/java/io/moderne/organizations/OrganizationController.java create mode 100644 src/main/java/io/moderne/organizations/OrganizationMetricController.java diff --git a/build.gradle.kts b/build.gradle.kts index 5084eaf..4cfbcf9 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -62,7 +62,6 @@ dependencies { implementation("com.graphql-java:graphql-java-extended-scalars:18+") implementation("org.springframework.boot:spring-boot-starter-actuator") - implementation("org.springframework.boot:spring-boot-starter-rsocket") implementation("com.netflix.graphql.dgs:graphql-dgs-webflux-starter:5+") { exclude(module = "snakeyaml") @@ -71,8 +70,7 @@ dependencies { exclude(module = "snakeyaml") } - implementation("io.micrometer:micrometer-core:1.+") - implementation("io.micrometer:micrometer-registry-prometheus:1.+") + implementation("io.micrometer:micrometer-registry-prometheus:latest.release") testImplementation("org.springframework.boot:spring-boot-starter-test") testImplementation(platform("org.junit:junit-bom:latest.release")) diff --git a/src/main/java/io/moderne/organizations/OrganizationController.java b/src/main/java/io/moderne/organizations/OrganizationController.java new file mode 100644 index 0000000..0fd0daa --- /dev/null +++ b/src/main/java/io/moderne/organizations/OrganizationController.java @@ -0,0 +1,4 @@ +package io.moderne.organizations; + +public interface OrganizationController { +} diff --git a/src/main/java/io/moderne/organizations/OrganizationMetricController.java b/src/main/java/io/moderne/organizations/OrganizationMetricController.java new file mode 100644 index 0000000..3b4cea8 --- /dev/null +++ b/src/main/java/io/moderne/organizations/OrganizationMetricController.java @@ -0,0 +1,16 @@ +package io.moderne.organizations; + +import io.micrometer.prometheus.PrometheusMeterRegistry; +import io.prometheus.client.exporter.common.TextFormat; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RestController; +import reactor.core.publisher.Mono; + +@RestController +public record OrganizationMetricController(PrometheusMeterRegistry meterRegistry){ + @GetMapping("/metrics/prometheus") + Mono scrape() { + return Mono.just(meterRegistry.scrape(TextFormat.CONTENT_TYPE_OPENMETRICS_100)); + } +} +