perf(metrics): cache MxEventFamily names for per-event metric tags

WorkerClient.StageWorkerEvent and StreamEvents called Enum.ToString per
event (per subscriber on the stream path). MxEventFamilyNames serves the
contract-fixed names from a frozen lookup, falling back to ToString for
undefined values so exported tag values are unchanged.
This commit is contained in:
Joseph Doherty
2026-10-22 06:30:57 -04:00
parent 6ae5ed905f
commit 68d6b5fd6f
4 changed files with 71 additions and 2 deletions
@@ -183,7 +183,7 @@ public sealed class MxAccessGatewayService(
// call is cancelled, instead of leaving it to the transport's own timeout.
await responseStream.WriteAsync(publicEvent, context.CancellationToken).ConfigureAwait(false);
metrics.RecordEventStreamSend(
publicEvent.Family.ToString(),
MxEventFamilyNames.Get(publicEvent.Family),
Stopwatch.GetElapsedTime(sendStartTimestamp));
}
}