Skip to content

Commit

Permalink
fixed connectivity metrics gauges
Browse files Browse the repository at this point in the history
* they were not resetted when the actor closed
* they could be incremented for the same connection id and type multiple times which makes no sense

Signed-off-by: Thomas Jaeckle <thomas.jaeckle@bosch-si.com>
  • Loading branch information
thjaeckle committed Sep 27, 2019
1 parent b7d7195 commit ef71266
Showing 1 changed file with 11 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,13 @@ protected BaseClientActor(final Connection connection,
initialize();
}

@Override
public void postStop() {
clientGauge.reset();
clientConnectingGauge.reset();
super.postStop();
}

/**
* Handles {@link TestConnection} commands by returning a CompletionState of {@link akka.actor.Status.Status Status}
* which may be {@link akka.actor.Status.Success Success} or {@link akka.actor.Status.Failure Failure}.
Expand Down Expand Up @@ -393,17 +400,17 @@ private void onTransition(final BaseClientState from, final BaseClientState to)
ConnectionLogUtil.enhanceLogWithConnectionId(log, connectionId());
log.debug("Transition: {} -> {}", from, to);
if (to == CONNECTED) {
clientGauge.increment();
clientGauge.set(1L);
}
if (to == DISCONNECTED) {
clientGauge.decrement();
clientGauge.reset();
}
if (to == CONNECTING) {
clientConnectingGauge.increment();
clientConnectingGauge.set(1L);
}
// dont use else if since we might use goTo(CONNECTING) if in CONNECTING state. This will cause another onTransition.
if (from == CONNECTING) {
clientConnectingGauge.decrement();
clientConnectingGauge.reset();
}
// cancel our own state timeout if target state is stable
switch (to) {
Expand Down

0 comments on commit ef71266

Please sign in to comment.