Skip to content

Commit

Permalink
merge: #9294
Browse files Browse the repository at this point in the history
9294: Add actor metrics r=Zelldon a=Zelldon

## Description

As discussed here https://camunda.slack.com/archives/C037RS2JHB8/p1651668160788749 add new actor metrics but no new panels for now. 

Details:

- Add counter for actorTask execution
- Add histogram to observe actorTask execution

Currently starting a benchmark to verify whether metrics are exported as expected.

I will create a separate PR for the atomix executors.

`@npepinpe` I'm not sure whether it fulfills all requirements for #9282 I will remove my assignment then. 



<!-- Please explain the changes you made here. -->

## Related issues

<!-- Which issues are closed by this PR or are related -->

related #9282 



Co-authored-by: Christopher Zell <zelldon91@googlemail.com>
  • Loading branch information
zeebe-bors-camunda[bot] and Zelldon committed May 5, 2022
2 parents 7b7ab6b + 72fb6fa commit e0fdc2f
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 1 deletion.
4 changes: 4 additions & 0 deletions util/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@
<groupId>org.agrona</groupId>
<artifactId>agrona</artifactId>
</dependency>
<dependency>
<groupId>io.prometheus</groupId>
<artifactId>simpleclient</artifactId>
</dependency>

<dependency>
<groupId>org.slf4j</groupId>
Expand Down
38 changes: 38 additions & 0 deletions util/src/main/java/io/camunda/zeebe/util/sched/ActorMetrics.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
/*
* Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH under
* one or more contributor license agreements. See the NOTICE file distributed
* with this work for additional information regarding copyright ownership.
* Licensed under the Zeebe Community License 1.1. You may not use this file
* except in compliance with the Zeebe Community License 1.1.
*/
package io.camunda.zeebe.util.sched;

import io.prometheus.client.Counter;
import io.prometheus.client.Histogram;

final class ActorMetrics {

private static final Histogram EXECUTION_LATENCY =
Histogram.build()
.namespace("zeebe")
.name("actor_task_execution_latency")
.help("Execution time of a certain actor task")
.labelNames("actorName")
.register();

private static final Counter EXECUTION_COUNT =
Counter.build()
.namespace("zeebe")
.name("actor_task_execution_count")
.help("Number of times a certain actor task was executed successfully")
.labelNames("actorName")
.register();

Histogram.Timer startExecutionTimer(final String name) {
return EXECUTION_LATENCY.labels(name).startTimer();
}

void countExecution(final String name) {
EXECUTION_COUNT.labels(name).inc();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ public class ActorThread extends Thread implements Consumer<Runnable> {
protected final ActorTimerQueue timerJobQueue;
protected ActorTaskRunnerIdleStrategy idleStrategy = new ActorTaskRunnerIdleStrategy();
ActorTask currentTask;
private final ActorMetrics actorMetrics = new ActorMetrics();
private final CompletableFuture<Void> terminationFuture = new CompletableFuture<>();
private final ActorClock clock;
private final int threadId;
Expand Down Expand Up @@ -77,7 +78,12 @@ private void doWork() {

if (currentTask != null) {
try {
executeCurrentTask();
final var actorName = currentTask.actor.getName();
try (final var timer = actorMetrics.startExecutionTimer(actorName)) {
executeCurrentTask();
}
actorMetrics.countExecution(actorName);

} finally {
taskScheduler.onTaskReleased(currentTask);
}
Expand Down

0 comments on commit e0fdc2f

Please sign in to comment.