-
-
Notifications
You must be signed in to change notification settings - Fork 220
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
resolves #1653 export metrics using Prometheus format
- Loading branch information
1 parent
759ca1a
commit 15c82fd
Showing
9 changed files
with
72 additions
and
45 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
36 changes: 36 additions & 0 deletions
36
server/src/main/java/io/kroki/server/service/MetricHandler.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
package io.kroki.server.service; | ||
|
||
import io.vertx.core.Handler; | ||
import io.vertx.core.buffer.Buffer; | ||
import io.vertx.core.http.HttpHeaders; | ||
import io.vertx.ext.web.RoutingContext; | ||
|
||
public class MetricHandler { | ||
|
||
private final KrokiBlockedThreadChecker blockedThreadChecker; | ||
private final String namespace; | ||
|
||
public MetricHandler(KrokiBlockedThreadChecker blockedThreadChecker) { | ||
this.blockedThreadChecker = blockedThreadChecker; | ||
this.namespace = "kroki"; | ||
} | ||
|
||
public Handler<RoutingContext> create() { | ||
String workerThreadBlockedMetricName = namespace + "_worker_thread_blocked_percentage"; | ||
String eventLoopThreadBlockedMetricName = namespace + "_event_loop_thread_blocked_percentage"; | ||
return routingContext -> { | ||
long timestamp = System.currentTimeMillis(); | ||
Buffer buffer = Buffer.buffer(); | ||
buffer.appendString("# HELP " + workerThreadBlockedMetricName + " The percentage of worker thread blocked.\n"); | ||
buffer.appendString("# TYPE " + workerThreadBlockedMetricName + " gauge\n"); | ||
buffer.appendString(String.join(" ", workerThreadBlockedMetricName, Long.toString(blockedThreadChecker.blockedWorkerThreadPercentage()), Long.toString(timestamp)) + "\n\n"); | ||
buffer.appendString("# HELP " + eventLoopThreadBlockedMetricName + " The percentage of event loop thread blocked.\n"); | ||
buffer.appendString("# TYPE " + eventLoopThreadBlockedMetricName + " gauge\n"); | ||
buffer.appendString(String.join(" ", eventLoopThreadBlockedMetricName, Long.toString(blockedThreadChecker.blockedEventLoopThreadPercentage()), Long.toString(timestamp)) + "\n\n"); | ||
routingContext | ||
.response() | ||
.putHeader(HttpHeaders.CONTENT_TYPE, "text/plain; version=0.0.4") | ||
.end(buffer); | ||
}; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters