Esempio n. 1
0
        protected virtual bool ExecuteCallback(bool timedout)
        {
            if (Disposed)
            {
                return(false);
            }

            using (new CorrelationScope())
            {
                using (IPerformanceTracker tracker = perf.TrackTask(Name))
                {
                    try
                    {
                        callback(!timedout);
                        tracker.Commit(new { timedout });
                        return(true);
                    }
                    catch (Exception ex)
                    {
                        bool seenBefore = exception != null && exception.GetType() == ex.GetType();
                        exception = ex;
                        OnTaskException(new TaskExceptionEventArgs(ex, this, seenBefore));
                        tracker.Commit(new { ex });
                        return(false);
                    }
                }
            }
        }
Esempio n. 2
0
        protected override async Task <HttpResponseMessage> SendAsync(HttpRequestMessage request, CancellationToken cancellationToken)
        {
            if (!logger.IsEnabled())
            {
                return(await base.SendAsync(request, cancellationToken).ConfigureAwait(false));
            }

            using (new CorrelationScope(request.GetCorrelationId()))
            {
                using (IPerformanceTracker tracker = logger.TrackRequest(request))
                {
                    HttpResponseMessage response = await base.SendAsync(request, cancellationToken).ConfigureAwait(true);

                    tracker.Commit(new { statusCode = response.StatusCode });
                    return(response);
                }
            }
        }