Microsoft Orleans — Dashboard Update — CPU/Memory Stats

Install the NuGet Package

The IHostEnvironmentStatistics implementation exists within the Microsoft.Orleans.OrleansTelemetryConsumers.Counters package, install it via the GUI, CLI, etc. The csproj file from the SiloHost project should look something like this when done:

csproj after installing the NuGet package Microsoft.Orleans.OrleansTelemetryConsumers.Counters

Registering the implementation of IHostEnvironmentStatistics

As previously mentioned, the new NuGet package has a Windows specific implementation of IHostEnvironmentStatistics contained within it, although it is an internal class. There is however, an extension method that can be used to register that internal class.

Let’s update our SiloHostBuilder:

Original

var builder = new SiloHostBuilder()
.ConfigureClustering(
ServiceProvider.GetService>(),
Startup.HostingEnvironment.EnvironmentName
)
.Configure(options =>
{
options.ClusterId = "dev";
options.ServiceId = "HelloWorldApp";
})
.Configure(options => options.AdvertisedIPAddress = IPAddress.Loopback)
.AddMemoryGrainStorage(Constants.OrleansMemoryProvider)
.ConfigureApplicationParts(parts =>
{
parts.AddApplicationPart(typeof(IGrainMarker).Assembly).WithReferences();
})
.ConfigureServices(DependencyInjectionHelper.IocContainerRegistration)
.UseDashboard(options => { })
.UseInMemoryReminderService()
.ConfigureLogging(logging => logging.AddConsole());

And we just need to add .UsePerfCounterEnvironmentStatistics().

Updated

var builder = new SiloHostBuilder()
.ConfigureClustering(
ServiceProvider.GetService>(),
Startup.HostingEnvironment.EnvironmentName
)
.Configure(options =>
{
options.ClusterId = "dev";
options.ServiceId = "HelloWorldApp";
})
.Configure(options => options.AdvertisedIPAddress = IPAddress.Loopback)
.AddMemoryGrainStorage(Constants.OrleansMemoryProvider)
.ConfigureApplicationParts(parts =>
{
parts.AddApplicationPart(typeof(IGrainMarker).Assembly).WithReferences();
})
.ConfigureServices(DependencyInjectionHelper.IocContainerRegistration)
.UsePerfCounterEnvironmentStatistics() // <- this guy
.UseDashboard(options => { })
.UseInMemoryReminderService()
.ConfigureLogging(logging => logging.AddConsole());

That’s all there is to it! Now, we should get our CPU/Memory utilization reported on the Orleans Dashboard, and be in a better position to work in LoadShedding — perhaps for the next post!

Now, looking at our dashboard, we can see:

CPU/Memory utilization!

read original article here