protected override async Task InterceptAsync(IInvocation invocation, IInvocationProceedInfo proceedInfo, Func <IInvocation, IInvocationProceedInfo, Task> proceed) { if (Enabled) { var loggingAttribute = invocation.Method.GetCustomAttribute <InsightAttribute>(); var eventName = loggingAttribute?.EventName; if (eventName != null) { await _insights.StartTrackEvent(eventName); } try { await proceed(invocation, proceedInfo).ConfigureAwait(false); return; } finally { if (eventName != null) { await _insights.StopTrackEvent(eventName); } } } await proceed(invocation, proceedInfo).ConfigureAwait(false); }