Skip to content

Commit

Permalink
add actor metrics
Browse files Browse the repository at this point in the history
  • Loading branch information
Zelldon committed Jan 7, 2022
1 parent 8b63fe8 commit 82d618e
Show file tree
Hide file tree
Showing 5 changed files with 50 additions and 3 deletions.
2 changes: 1 addition & 1 deletion dist/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@
<goal>assemble</goal>
</goals>
<phase>package</phase>
<configuration />
<configuration></configuration>
</execution>
</executions>
</plugin>
Expand Down
2 changes: 1 addition & 1 deletion gateway-protocol-impl/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@
<phase>generate-sources</phase>
<configuration>
<target>
<copy failonerror="true" file="${project.build.directory}/generated-sources/protobuf/go/gateway.pb.go" tofile="${maven.multiModuleProjectDirectory}/clients/go/pkg/pb/gateway.pb.go" />
<copy failonerror="true" file="${project.build.directory}/generated-sources/protobuf/go/gateway.pb.go" tofile="${maven.multiModuleProjectDirectory}/clients/go/pkg/pb/gateway.pb.go"></copy>
</target>
</configuration>
</execution>
Expand Down
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
37 changes: 37 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,37 @@
/*
* 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;

public class ActorMetrics {

private static final Histogram EXECUTION_LATENCY =
Histogram.build()
.namespace("zeebe")
.name("sched_task_execution_latency")
.help("Latency to execute")
.labelNames("actorName")
.register();

private static final Counter EXECUTION_COUNT =
Counter.build()
.namespace("zeebe")
.name("sched_task_execution_count")
.labelNames("actorName")
.register();

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

public void countExecution(final String name) {
EXECUTION_COUNT.labels(name).inc();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@

public class ActorThread extends Thread implements Consumer<Runnable> {
static final Unsafe UNSAFE = UnsafeAccess.UNSAFE;
static final ActorMetrics ACTOR_METRICS = new ActorMetrics();
private static final long STATE_OFFSET;
private static final Logger LOG = Loggers.ACTOR_LOGGER;
private static final FatalErrorHandler FATAL_ERROR_HANDLER = FatalErrorHandler.withLogger(LOG);
Expand Down Expand Up @@ -77,7 +78,12 @@ private void doWork() {

if (currentTask != null) {
try {
executeCurrentTask();
final var actorName = currentTask.actor.getName();
ACTOR_METRICS.countExecution(actorName);

This comment has been minimized.

Copy link
@Zelldon

Zelldon May 4, 2022

Author Member

@pihme with that you could at least see which actor has been executed mostly and how long does it took. But it is not that fine granular on method level, like you described here #9282 (comment)

This comment has been minimized.

Copy link
@pihme

pihme May 4, 2022

Contributor

I like it. Where can I upvote for this to be merged?

This comment has been minimized.

Copy link
@Zelldon

Zelldon May 4, 2022

Author Member

I guess we / you can raise it in slack and we shortly discuss if team is ok with adding this. If so I can create a PR tomorrow and merge it. But until then you could also use that branch and create an own docker image which you use for your testing.

try (final var timer = ACTOR_METRICS.startExecutionTimer(actorName)) {
executeCurrentTask();
}

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

0 comments on commit 82d618e

Please sign in to comment.