I am trying to implement statistics reporting for internal components of an OLTP web application. For example, I want to track near real time the usage or performance of things like: number of successful/failed logins, number of nhibernate sessions, time to serve a HTTP request, number transactions of different types (orders, accesses, etc). All these stats are sent via UDP to a statsd server (https://github.com/etsy/statsd) and plotted as charts with Graphite.
The application is using dependency injection for wiring internal components. I want to centralize statistics reporting towards statsd server in a class of its own and hide it under an interface. However, I feel like injecting an instance of the stats reporting class/interface in every component of the application which is reporting performance or usage data to be a smell. It seems to me that performance reporting events should be something like a cross cutting concern, pretty much like logging.
How do you approach the internal design for such a request? Would you approach with constructor injection, static methods (e.g. PerformanceCounters.Increment("name.of.counter")) which are called my monitored components or how?
If it is of any help for context, the app is done in C# and is using ASP.NET and Castle Windsor as IoC.
Thanks, Robert