Skip to main content

Monitor your application using Event Counters–Part II

I’m building a data pipeline using TPL Dataflow to migrate data from a database to an external API. As this data pipeline could run for a long time, I was looking for a good way to monitor the progress. This turned out to be a perfect use case for Event Counters.

Yesterday I introduced EventCounters and showed a small example. Today let’s have a look on how we can monitor the EventCounters values.

Monitor EventCounters using dotnet-counters

There are multiple ways to read out EventCounters values but the way I want to use during the migration is through the dotnet-counters global tool:

dotnet-counters is a performance monitoring tool for ad-hoc health monitoring and first-level performance investigation. It can observe performance counter values that are published via the EventCounter API or the Meter API. For example, you can quickly monitor things like the CPU usage or the rate of exceptions being thrown in your .NET Core application to see if there's anything suspicious before diving into more serious performance investigation using PerfView or dotnet-trace.

If you don’t have the tool installed yet, you can install the latest version using dotnet install:

dotnet tool install --global dotnet-counters

Now that we have the dotnet-counters tool available, we can use dotnet-counters ps to display a list of .NET processes that can be monitored:

Now we can invoke the dotnet-counters monitor command and pass the process id as a parameter:

dotnet-counters monitor --process-id 28444

This will start the monitoring. By default we get a list of eventcounters from System.Runtime:

To view the EventCounter we created in the previous post, we should specify the counter name:

dotnet-counters monitor --process-id 28444 – --counters Migrator.MigratedRecordsCounter

Now we should see the values from our counter:

Nice!

In the next post, we'll have a look at some of the other counters and see how we can further improve our example. Stay tuned!

Popular posts from this blog

XUnit - Assert.Collection

A colleague asked me to take a look at the following code inside a test project: My first guess would be that this code checks that the specified condition(the contains) is true for every element in the list.  This turns out not to be the case. The Assert.Collection expects a list of element inspectors, one for every item in the list. The first inspector is used to check the first item, the second inspector the second item and so on. The number of inspectors should match the number of elements in the list. An example: The behavior I expected could be achieved using the Assert.All method:

Azure DevOps/ GitHub emoji

I’m really bad at remembering emoji’s. So here is cheat sheet with all emoji’s that can be used in tools that support the github emoji markdown markup: All credits go to rcaviers who created this list.

Angular --deploy-url and --base-href

As long you are running your Angular application at a root URL (e.g. www.myangularapp.com ) you don’t need to worry that much about either the ‘--deploy-url’ and ‘--base-href’ parameters. But once you want to serve your Angular application from a server sub folder(e.g. www.mywebsite.com/angularapp ) these parameters become important. --base-href If you deploy your Angular app to a subfolder, the ‘--base-href’ is important to generate the correct routes. This parameter will update the <base href> tag inside the index.html. For example, if the index.html is on the server at /angularapp/index.html , the base href should be set to <base href="/angularapp/"> . More information: https://angular.io/guide/deployment --deploy-url A second parameter that is important is ‘--deploy-url’. This parameter will update the generated url’s for our assets(scripts, css) inside the index.html. To make your assets available at /angularapp/, the deploy url should