Skip to content

Commit

Permalink
chore: Update jicoco to 1.1-142-gfed0320. (#547)
Browse files Browse the repository at this point in the history
* chore: Update jicoco to 1.1-143.
* ref: Use getMetrics().
  • Loading branch information
bgrozev authored Oct 22, 2024
1 parent 744975d commit 12358ba
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 23 deletions.
4 changes: 2 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
<mockk.version>1.13.8</mockk.version>
<ktor.version>2.3.4</ktor.version>
<jwt.version>0.11.5</jwt.version>
<jicoco.version>1.1-127-gf49982f</jicoco.version>
<jicoco.version>1.1-143-g175c44b</jicoco.version>
<jitsi.utils.version>1.0-127-g6c65524</jitsi.utils.version>
</properties>

Expand Down Expand Up @@ -273,7 +273,7 @@
<dependency>
<groupId>org.jitsi</groupId>
<artifactId>jicoco-metrics</artifactId>
<version>1.1-133-g768ef2e</version>
<version>${jicoco.version}</version>
<scope>compile</scope>
</dependency>
</dependencies>
Expand Down
26 changes: 5 additions & 21 deletions src/main/kotlin/org/jitsi/jibri/api/http/HttpApi.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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))
}
}
}
Expand Down

0 comments on commit 12358ba

Please sign in to comment.