Skip to content

Commit

Permalink
ref: Move Prometheus from jicoco. (#2235)
Browse files Browse the repository at this point in the history
* ref: Move Prometheus from jicoco.

* chore: Update jicoco to 1.1-143.
  • Loading branch information
bgrozev authored Oct 22, 2024
1 parent 4e95a31 commit 9925c61
Show file tree
Hide file tree
Showing 4 changed files with 69 additions and 12 deletions.
4 changes: 0 additions & 4 deletions jvb/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -143,10 +143,6 @@
<groupId>${project.groupId}</groupId>
<artifactId>jicoco-metrics</artifactId>
</dependency>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>jicoco-metrics-jetty</artifactId>
</dependency>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>jitsi-xmpp-extensions</artifactId>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
/*
* Copyright @ 2022 - present 8x8, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package org.jitsi.videobridge.rest.prometheus;

import io.prometheus.client.exporter.common.*;
import jakarta.ws.rs.*;
import jakarta.ws.rs.core.*;
import org.jetbrains.annotations.NotNull;
import org.jitsi.metrics.*;

/**
* A REST endpoint exposing JVB stats for Prometheus.
* Any scraper supporting Prometheus' text-based formats ({@code text/plain; version=0.0.4} or OpenMetrics)
* is compatible with this {@code /metrics} endpoint.<br>
* JSON is provided when the client performs a request with the 'Accept' header set to {@code application/json}.<br>
* The response defaults to {@code text/plain; version=0.0.4} formatted output.
*
* @see <a href="https://github.com/prometheus/docs/blob/main/content/docs/instrumenting/exposition_formats.md">
* Prometheus' exposition formats</a>
*/
@Path("/metrics")
public class Prometheus
{
@NotNull
private final MetricsContainer metricsContainer;

public Prometheus(@NotNull MetricsContainer metricsContainer)
{
this.metricsContainer = metricsContainer;
}

@GET
@Produces(TextFormat.CONTENT_TYPE_004)
public String getPrometheusPlainText()
{
return metricsContainer.getPrometheusMetrics(TextFormat.CONTENT_TYPE_004);
}

@GET
@Produces(TextFormat.CONTENT_TYPE_OPENMETRICS_100)
public String getPrometheusOpenMetrics()
{
return metricsContainer.getPrometheusMetrics(TextFormat.CONTENT_TYPE_OPENMETRICS_100);
}

@GET
@Produces(MediaType.APPLICATION_JSON)
public String getJsonString()
{
return metricsContainer.getJsonString();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
import org.jitsi.videobridge.rest.*;
import org.jitsi.videobridge.rest.binders.*;
import org.jitsi.videobridge.rest.filters.*;
import org.jitsi.videobridge.stats.*;
import org.jitsi.videobridge.rest.prometheus.*;
import org.jitsi.videobridge.xmpp.*;

import static org.jitsi.videobridge.rest.RestConfig.config;
Expand Down Expand Up @@ -61,7 +61,7 @@ public Application(
}
if (config.isEnabled(RestApis.PROMETHEUS))
{
register(new org.jitsi.rest.prometheus.Prometheus(VideobridgeMetricsContainer.getInstance()));
register(new Prometheus(VideobridgeMetricsContainer.getInstance()));
}
}
}
7 changes: 1 addition & 6 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
<kotest.version>5.9.1</kotest.version>
<junit.version>5.10.2</junit.version>
<jitsi.utils.version>1.0-133-g6af1020</jitsi.utils.version>
<jicoco.version>1.1-142-gfed0320</jicoco.version>
<jicoco.version>1.1-143-g175c44b</jicoco.version>
<mockk.version>1.13.11</mockk.version>
<ktlint-maven-plugin.version>3.2.0</ktlint-maven-plugin.version>
<maven-shade-plugin.version>3.6.0</maven-shade-plugin.version>
Expand Down Expand Up @@ -93,11 +93,6 @@
<artifactId>jicoco-metrics</artifactId>
<version>${jicoco.version}</version>
</dependency>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>jicoco-metrics-jetty</artifactId>
<version>${jicoco.version}</version>
</dependency>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>jitsi-utils</artifactId>
Expand Down

0 comments on commit 9925c61

Please sign in to comment.