Skip to content

Commit

Permalink
merge: #15416
Browse files Browse the repository at this point in the history
15416: [Backport stable/8.3] fix(raft): update role metrics when closing or transitioning to inactive r=github-actions[bot] a=backport-action

# Description
Backport of #15413 to `stable/8.3`.

relates to 
original author: `@deepthidevaki`

Co-authored-by: Deepthi Devaki Akkoorath <[email protected]>
  • Loading branch information
zeebe-bors-camunda[bot] and deepthidevaki authored Nov 29, 2023
2 parents d25c1ae + b6c6c11 commit e7bbcf2
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -853,6 +853,7 @@ public void checkThread() {
private RaftRole createRole(final Role role) {
switch (role) {
case INACTIVE:
raftRoleMetrics.becomingInactive();
return new InactiveRole(this);
case PASSIVE:
return new PassiveRole(this);
Expand Down Expand Up @@ -915,6 +916,7 @@ public void transition(final Type type) {

@Override
public void close() {
raftRoleMetrics.becomingInactive();
started = false;
// Unregister protocol listeners.
unregisterHandlers(protocol);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,10 @@ public RaftRoleMetrics(final String partitionName) {
electionLatency = ELECTION_LATENCY.labels(partitionGroupName, partition);
}

public void becomingInactive() {
role.set(0);
}

public void becomingFollower() {
role.set(1);
}
Expand Down

0 comments on commit e7bbcf2

Please sign in to comment.