Skip to content

Commit 5eafe61

Browse files
committed
fix: only log session closure metric if previously established
- Add condition to ensure `_metrics.SessionClosed()` is called only when the session was in an established state before transitioning to Idle. - Prevents misleading metrics logging for sessions that didn’t reach the established state.
1 parent d0e1cb8 commit 5eafe61

1 file changed

Lines changed: 3 additions & 1 deletion

File tree

BGPLite.Server/BgpSession.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -193,8 +193,10 @@ public async Task RunAsync(CancellationToken cancellationToken = default)
193193
}
194194
finally
195195
{
196+
var wasEstablished = _state == BgpFsmState.Established;
196197
TransitionTo(BgpFsmState.Idle);
197-
_metrics.SessionClosed();
198+
if (wasEstablished)
199+
_metrics.SessionClosed();
198200
_metrics.PeerDisconnected();
199201
_logger.LogInformation("SessionClosed with {Peer}", _peerConfig.Address);
200202
}

0 commit comments

Comments
 (0)