Once we have collected our memory statistics, we will then use this information to publish a memory update message to the system. On the other end, the health monitor microservice could be listening and interested in high watermarks on CPU or memory. Here's what this function looks like:
public void PublishMemoryUpdateMessage(int gen1, int gen2, float timeSpent, string MemoryBefore, string MemoryAfter)
{
// publish a message
MemoryUpdateMessage msg = new MemoryUpdateMessage
{
Text = "Memory MicroService Ran",
Date = SystemClock.Instance.GetCurrentInstant().ToDateTimeUtc(),
Gen1CollectionCount = gen1,
Gen2CollectionCount = gen2,
TimeSpentPercent = timeSpent,
MemoryBeforeCollection = MemoryBefore,
MemoryAfterCollection = MemoryAfter
};
Bus.Publish(msg, "MemoryStatus");
}
Base Logger
Our base microservice class also exposes the ILogger...