Esempio n. 1
0
        /// <summary>
        /// Captures the overall execution time and logs final metrics.
        /// </summary>
        /// <typeparam name="T">The response type for the current request.</typeparam>
        /// <param name="executionContext">
        /// The execution context, it contains the request and response context.
        /// </param>
        /// <returns>A task that represents the asynchronous operation.</returns>
        public override async System.Threading.Tasks.Task <T> InvokeAsync <T>(IExecutionContext executionContext)
        {
            executionContext.RequestContext.Metrics.AddProperty(Metric.AsyncCall, true);
            try
            {
                executionContext.RequestContext.Metrics.StartEvent(Metric.ClientExecuteTime);
                var response = await base.InvokeAsync <T>(executionContext).ConfigureAwait(false);

                return(response);
            }
            finally
            {
                var latency = AWSSDKUtils.ConvertTimeSpanToMilliseconds(executionContext.RequestContext.Metrics
                                                                        .StopEvent(Metric.ClientExecuteTime)
                                                                        .ElapsedTime);

#if BCL || CORECLR
                // capture the latency for the entire SDK call if CSM is enabled
                if (executionContext.RequestContext.CSMEnabled)
                {
                    executionContext.RequestContext.CSMCallEvent.Latency = latency;
                    CSMUtilities.SerializetoJsonAndPostOverUDPAsync(executionContext.RequestContext.CSMCallEvent).ConfigureAwait(false);
                }
#endif
                this.LogMetrics(executionContext);
            }
        }
Esempio n. 2
0
        /// <summary>
        /// Calls the PreInvoke and PostInvoke methods before and after calling the next handler
        /// in the pipeline.
        /// </summary>
        public override async System.Threading.Tasks.Task <T> InvokeAsync <T>(IExecutionContext executionContext)
        {
            try
            {
                PreInvoke(executionContext);
                var response = await base.InvokeAsync <T>(executionContext).ConfigureAwait(false);

                return(response);
            }

            catch (AmazonServiceException e)
            {
                CaptureAmazonException(executionContext.RequestContext.CSMCallAttempt, e);
                throw;
            }
            catch (Exception e)
            {
                CaptureSDKExceptionMessage(executionContext.RequestContext.CSMCallAttempt, e);
                throw;
            }
            finally
            {
                CSMCallAttemptMetricsCapture(executionContext.RequestContext, executionContext.ResponseContext);
                CSMUtilities.SerializetoJsonAndPostOverUDPAsync(executionContext.RequestContext.CSMCallAttempt).ConfigureAwait(false);
            }
        }
Esempio n. 3
0
        /// <summary>
        /// Calls the PreInvoke and PostInvoke methods before and after calling the next handler
        /// in the pipeline.
        /// </summary>
        public override async System.Threading.Tasks.Task <T> InvokeAsync <T>(IExecutionContext executionContext)
        {
            try
            {
                PreInvoke(executionContext);
                var response = await base.InvokeAsync <T>(executionContext).ConfigureAwait(false);

                return(response);
            }
            catch (Exception e)
            {
                CaptureCSMCallEventExceptionData(executionContext.RequestContext);
                throw;
            }
            finally
            {
                CSMCallEventMetricsCapture(executionContext);
                CSMUtilities.SerializetoJsonAndPostOverUDPAsync(executionContext.RequestContext.CSMCallEvent).ConfigureAwait(false);
            }
        }