Мне нужно измерить время вызова метода Handle в каждом случае интерфейса IHandleMessages <>. Я пытался использовать перехватчик замка Виндзор,Как измерить время вызова метода «Ручка» в NServiceBus?
public class NsbHandlerMeasurementInterceptor : IInterceptor
{
public void Intercept(IInvocation invocation)
{
if (invocation.Method.Name == ExpressionExtender.GetMethodName<IHandleMessages<DummyType>>(b => b.Handle(null)))
{
Stopwatch stopwatch = new Stopwatch();
stopwatch.Start();
invocation.Proceed();
stopwatch.Stop();
// save stopwatch.ElapsedMilliseconds value
}
else
{
invocation.Proceed();
}
}
}
с кодом установки:
container.Register(Component.For<NsbHandlerMeasurementInterceptor>());
container.Kernel.ComponentModelBuilder.AddContributor(new NsbWindsorModelConstructionContributor());
public class NsbWindsorModelConstructionContributor : IContributeComponentModelConstruction
{
public void ProcessModel(global::Castle.MicroKernel.IKernel kernel, global::Castle.Core.ComponentModel model)
{
if (model.Services.Any(s => s.ImplementsGenericInterface(typeof(IHandleMessages<>))))
{
model.Interceptors.AddIfNotInCollection(new InterceptorReference(typeof(NsbHandlerMeasurementInterceptor)));
}
}
}
но от этого метода момент ручки не стреляя.
Я знаю о счетчиках производительности в NSB, но мне нужны более конкретные, ориентированные на тип измерения. Возможно ли это и достижимо?