From d76fd7bab9f2449cd3148ee414b5525bfae1f7d6 Mon Sep 17 00:00:00 2001 From: Aleksandr Turchenko Date: Wed, 20 Mar 2024 15:09:33 +0400 Subject: [PATCH 1/3] Update prometheus to 1.1 --- build.gradle.kts | 2 +- .../clickhouse/metrics/PrometheusMetrics.kt | 19 +++++++++---------- 2 files changed, 10 insertions(+), 11 deletions(-) diff --git a/build.gradle.kts b/build.gradle.kts index 7435ab5..f66087f 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -24,7 +24,7 @@ dependencies { implementation("org.apache.httpcomponents:httpcore:4.4.15") implementation("org.apache.httpcomponents:httpclient:4.5.13") - compileOnly("io.prometheus:simpleclient:0.16.0") + compileOnly("io.prometheus:prometheus-metrics-core:1.2.0") testImplementation("org.junit.jupiter:junit-jupiter-api:5.8.2") testRuntimeOnly("org.junit.jupiter:junit-jupiter-engine:5.8.2") diff --git a/src/main/kotlin/com/ecwid/clickhouse/metrics/PrometheusMetrics.kt b/src/main/kotlin/com/ecwid/clickhouse/metrics/PrometheusMetrics.kt index 5a39ba5..75df277 100644 --- a/src/main/kotlin/com/ecwid/clickhouse/metrics/PrometheusMetrics.kt +++ b/src/main/kotlin/com/ecwid/clickhouse/metrics/PrometheusMetrics.kt @@ -1,24 +1,24 @@ package com.ecwid.clickhouse.metrics -import io.prometheus.client.Counter -import io.prometheus.client.Summary +import io.prometheus.metrics.core.metrics.Counter +import io.prometheus.metrics.core.metrics.Summary + /** * Metrics will be collected to prometheus lib */ class PrometheusMetrics : Metrics { override fun startRequestTimer(host: String): AutoCloseable { - return requestsLatencySummary.labels(host).startTimer() + return requestsLatencySummary.labelValues(host).startTimer() } override fun measureRequest(host: String, statusCode: Int) { - requestsCounter.labels(host, statusCode.toString()).inc() + requestsCounter.labelValues(host, statusCode.toString()).inc() } companion object { - private val requestsLatencySummary = Summary.Builder() - .subsystem("clickhouse_client") - .name("requests_latency_seconds") + private val requestsLatencySummary = Summary.builder() + .name("clickhouse_client_requests_latency_seconds") .help("Latency of requests in seconds") .labelNames("host") .quantile(0.5, 0.01) @@ -26,9 +26,8 @@ class PrometheusMetrics : Metrics { .quantile(0.99, 0.01) .register() - private val requestsCounter = Counter.Builder() - .subsystem("clickhouse_client") - .name("requests_total") + private val requestsCounter = Counter.builder() + .name("clickhouse_client_requests_total") .help("Total number of requests") .labelNames("host", "http_code") .register() From c1c2509681ccc83661f0f885250ceef7e8091e3b Mon Sep 17 00:00:00 2001 From: Aleksandr Turchenko Date: Wed, 20 Mar 2024 15:09:56 +0400 Subject: [PATCH 2/3] Update kotlin and other dependencies --- build.gradle.kts | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/build.gradle.kts b/build.gradle.kts index f66087f..e9afc99 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -4,7 +4,7 @@ import org.jetbrains.kotlin.gradle.tasks.KotlinCompile plugins { java - kotlin("jvm") version "1.6.10" + kotlin("jvm") version "1.9.23" signing `maven-publish` id("com.netflix.nebula.release") version "17.2.2" @@ -19,17 +19,15 @@ dependencies { implementation(kotlin("stdlib-jdk8")) implementation(kotlin("reflect")) - implementation("com.google.code.gson:gson:2.9.0") + implementation("com.google.code.gson:gson:2.10.1") - implementation("org.apache.httpcomponents:httpcore:4.4.15") - implementation("org.apache.httpcomponents:httpclient:4.5.13") + implementation("org.apache.httpcomponents:httpcore:4.4.16") + implementation("org.apache.httpcomponents:httpclient:4.5.14") compileOnly("io.prometheus:prometheus-metrics-core:1.2.0") - testImplementation("org.junit.jupiter:junit-jupiter-api:5.8.2") - testRuntimeOnly("org.junit.jupiter:junit-jupiter-engine:5.8.2") - testImplementation("org.mockito:mockito-core:2.15.0") - testImplementation("org.hamcrest:hamcrest-library:1.3") + testImplementation("org.junit.jupiter:junit-jupiter-api:5.10.2") + testRuntimeOnly("org.junit.jupiter:junit-jupiter-engine:5.10.2") testImplementation("org.slf4j:slf4j-simple:1.7.36") } From eab334c570e0cdde50769ccdebe26647322e39ab Mon Sep 17 00:00:00 2001 From: Aleksandr Turchenko Date: Wed, 20 Mar 2024 15:34:05 +0400 Subject: [PATCH 3/3] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 318275c..8408385 100644 --- a/README.md +++ b/README.md @@ -89,7 +89,7 @@ Add prometheus metric dependency to your project gradle ``` -compile "io.prometheus:simpleclient:0.16.0" +compile "io.prometheus:prometheus-metrics-core:1.2.0" ``` Inject metrics collector on instantiate client