From 88dbc103073487aa35a0ebecf6a1564bf6235d2d Mon Sep 17 00:00:00 2001 From: Boris Grozev Date: Thu, 10 Oct 2024 15:51:46 -0500 Subject: [PATCH 1/2] chore: Update jicoco to 1.1-142-gfed0320. --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 790ed65a..fe44aaea 100644 --- a/pom.xml +++ b/pom.xml @@ -21,7 +21,7 @@ 1.13.8 2.3.4 0.11.5 - 1.1-127-gf49982f + 1.1-142-gfed0320 1.0-127-g6c65524 From 864bc2dfd6f00665d7c4974aff40ae3ab88606a8 Mon Sep 17 00:00:00 2001 From: Boris Grozev Date: Mon, 14 Oct 2024 13:53:37 -0500 Subject: [PATCH 2/2] ref: Use getMetrics(). --- pom.xml | 2 +- .../org/jitsi/jibri/api/http/HttpApi.kt | 26 ++++--------------- 2 files changed, 6 insertions(+), 22 deletions(-) diff --git a/pom.xml b/pom.xml index fe44aaea..bffb6b3b 100644 --- a/pom.xml +++ b/pom.xml @@ -273,7 +273,7 @@ org.jitsi jicoco-metrics - 1.1-133-g768ef2e + ${jicoco.version} compile diff --git a/src/main/kotlin/org/jitsi/jibri/api/http/HttpApi.kt b/src/main/kotlin/org/jitsi/jibri/api/http/HttpApi.kt index ab6f1483..8974a888 100644 --- a/src/main/kotlin/org/jitsi/jibri/api/http/HttpApi.kt +++ b/src/main/kotlin/org/jitsi/jibri/api/http/HttpApi.kt @@ -18,6 +18,7 @@ package org.jitsi.jibri.api.http import io.ktor.http.ContentType import io.ktor.http.HttpStatusCode +import io.ktor.http.parseHeaderValue import io.ktor.serialization.jackson.jackson import io.ktor.server.application.Application import io.ktor.server.application.call @@ -30,7 +31,6 @@ import io.ktor.server.routing.get import io.ktor.server.routing.post import io.ktor.server.routing.route import io.ktor.server.routing.routing -import io.prometheus.client.exporter.common.TextFormat import jakarta.ws.rs.core.Response import org.jitsi.jibri.FileRecordingRequestParams import org.jitsi.jibri.JibriBusyException @@ -138,26 +138,10 @@ class HttpApi( if (StatsConfig.enablePrometheus) { logger.info("Enabling prometheus interface at :$port/metrics") get("/metrics") { - val accept = call.request.headers["Accept"] - when { - accept?.startsWith("application/openmetrics-text") == true -> - call.respondText( - JibriMetricsContainer.getPrometheusMetrics(TextFormat.CONTENT_TYPE_OPENMETRICS_100), - contentType = ContentType.parse(TextFormat.CONTENT_TYPE_OPENMETRICS_100) - ) - - accept?.startsWith("text/plain") == true -> - call.respondText( - JibriMetricsContainer.getPrometheusMetrics(TextFormat.CONTENT_TYPE_004), - contentType = ContentType.parse(TextFormat.CONTENT_TYPE_004) - ) - - else -> - call.respondText( - JibriMetricsContainer.jsonString, - contentType = ContentType.parse("application/json") - ) - } + val accepts = + parseHeaderValue(call.request.headers["Accept"]).sortedBy { it.quality }.map { it.value } + val (metrics, contentType) = JibriMetricsContainer.getMetrics(accepts) + call.respondText(metrics, contentType = ContentType.parse(contentType)) } } }