DEV Community

Discussion on: Reporting Metrics Using .Net (Core) EventSource and EventCounter

Collapse
 
steveharveyuk profile image
SteveHarveyUK • Edited

Great post - just what I was looking for to help with metrics in a .Net Standard library... But... I think that there might be another bug in there.

Have you ever tried having multiple EventSources?

While WriteEvent() calls do appear to be filtered based on the EventSource used to enable to EventListener, I appear to be seeing all EventCounter events on all my EventListeners regardless of how I enabled them.

Collapse
 
expecho profile image
Peter Bons

I've tried to reproduce it but I can't. Can you share some details (or code) how you defined and enabled the EventSources?

Collapse
 
steveharveyuk profile image
SteveHarveyUK

I've forked your repo to github.com/SteveHarveyUK/Blog.git

In there I've moved things around to provide a factory base example that demonstrates my usage pattern and the issue I see.

If you change the enableFiltering parameter on the factory it'll turn on my own implementation of filtering in the EventListener.

Thread Thread
 
expecho profile image
Peter Bons

So let me get this clear: you want to be able to enable or disable collection metrics of a specific EventSource?

Thread Thread
 
steveharveyuk profile image
SteveHarveyUK

I want to be able to have a number of independent EventSources with EventCounters collecting different metrics with each having its own EventListener that only receives the events from the EventSource and EventCounter that was enabled against it at potentially different frequencies.

So for instance I can have one instance monitoring cache table usage and delivering me the update rate per second and perhaps another giving me the stats against all queues in an application every five seconds.

I believe that I've achieved that with my example code, BUT I've had to manually filter the EventCounter events as they don't seem to be filtered by the framework based on the EventSource passed into EventListener.EnableEvents() method.

I'm just trying to check that I've not missed something as I'd have expected the built in filtering that appears to work on EventSource.WriteEvent() to work for the EventCounter events too.

Thread Thread
 
expecho profile image
Peter Bons

If you do not want to collect metrics just don't pass the EventCounterIntervalSec argument in the dictionary. Otherwise just use another interval. I made some changes to your repo but can't push them to your repo. Can you add me as a contributer? (I can't fork your repo since it is a fork of mine)

Thread Thread
 
steveharveyuk profile image
SteveHarveyUK

Added as collaborator. Thanks for your help!!

Thread Thread
 
expecho profile image
Peter Bons • Edited

I've created a pull request in which I demonstrate how I would do it. Probably better to communicate using the PR from now on.