fix(GWC-33): unregister terminal worker queue gauge
This commit is contained in:
@@ -444,11 +444,10 @@ public sealed class WorkerClient : IWorkerClient
|
||||
{
|
||||
_state = WorkerClientState.Closed;
|
||||
}
|
||||
|
||||
UnregisterEventQueueDepthSource();
|
||||
}
|
||||
|
||||
// Drop out of the worker queue-depth gauge before teardown: whatever this client still holds
|
||||
// is about to be discarded, and the sum must not keep counting a client that is going away.
|
||||
_eventQueueDepthRegistration?.Dispose();
|
||||
KillOwnedProcess("Dispose");
|
||||
_stopCts.Cancel();
|
||||
_outboundEnvelopes.Writer.TryComplete();
|
||||
@@ -1092,6 +1091,7 @@ public sealed class WorkerClient : IWorkerClient
|
||||
}
|
||||
|
||||
_state = WorkerClientState.Closed;
|
||||
UnregisterEventQueueDepthSource();
|
||||
}
|
||||
|
||||
_stopCts.Cancel();
|
||||
@@ -1126,6 +1126,7 @@ public sealed class WorkerClient : IWorkerClient
|
||||
}
|
||||
|
||||
_state = WorkerClientState.Faulted;
|
||||
UnregisterEventQueueDepthSource();
|
||||
}
|
||||
|
||||
_stopCts.Cancel();
|
||||
@@ -1139,6 +1140,16 @@ public sealed class WorkerClient : IWorkerClient
|
||||
_logger.LogWarning(exception, "Worker client faulted for session {SessionId}: {Message}", SessionId, message);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Removes this terminal client's abandoned backlog from the gateway-wide queue-depth
|
||||
/// gauge. The registration handle is idempotent, so terminal transitions and later disposal
|
||||
/// may all call this safely while the faulted client remains retained for diagnostics.
|
||||
/// </summary>
|
||||
private void UnregisterEventQueueDepthSource()
|
||||
{
|
||||
_eventQueueDepthRegistration?.Dispose();
|
||||
}
|
||||
|
||||
private void KillOwnedProcess(string reason)
|
||||
{
|
||||
WorkerProcessHandle? processHandle = _connection.ProcessHandle;
|
||||
|
||||
Reference in New Issue
Block a user