-
Notifications
You must be signed in to change notification settings - Fork 0
_AspNet_Mvc_DecoratingYourControllers
Decorate your Controller
action methods. All the usual rules having to do with routing and controller actions applies. Adding the decoration enables performance measurement filtering.
We can leverage some language features to make our lives a bit easier.
using static Discovery.MeasurementBoundary;
We have made an effort to provide a filter whose inputs are consistent with ad-hoc instrumentation. However, make no mistake, this is a different class.
[PerformanceMeasurementFilter(
categoryType: typeof(MyPerformanceCounterCategoryAdapter)
, adapterType: typeof(AverageTimePerformanceCounterAdapter)
, otherAdapterTypes: new[] {typeof(TotalMemberAccessesPerformanceCounterAdapter)}
, PublishCounters = true, PublishEvent = true, ThrowPublishErrors = true
, Boundary = new[] {BeginAction, EndAction}
)]
public ActionResult Index()
{
return View();
}
In this case, we organize a category via the type MyPerformanceCounterCategoryAdapter
and with two counter adapters, AverageTimePerformanceCounterAdapter
and TotalMemberAccessesPerformanceCounterAdapter
. Several flags are also indicated, as well as the Boundary
.
The MVC filter is similar to the Web API filter but not quite the same, and both are very similar to the ad-hoc attribute. The MVC filter adds the ability to specify boundaries around action and/or result.
Synchronous as well as asynchronous methods are also supported.
- Framework agnostic
- ASP.NET