public static void Add(DateTime time, TimeSpan duration, string method, Uri uri, string query)
        {
            HttpContext context = HttpContext.Current;
            if (context == null)
                return;

            var requestItem = new RequestItem
            {
                Time = time,
                Duration = duration,
                Method = method,
                Index = GetSegment(uri, 1),
                Document = GetSegment(uri, 2),
                Query = query
            };

            if (context.Items[Key] == null)
                lock (ContextLock)
                {
                    if (context.Items[Key] == null)
                        context.Items[Key] = new List<RequestItem>();
                }

            var items = context.Items[Key] as List<RequestItem>;
            items.Add(requestItem);
        }
        public static void Add(DateTime time, TimeSpan duration, string method, Uri uri, string query)
        {
            HttpContext context = HttpContext.Current;

            if (context == null)
            {
                return;
            }

            var requestItem = new RequestItem
            {
                Time     = time,
                Duration = duration,
                Method   = method,
                Index    = GetSegment(uri, 1),
                Document = GetSegment(uri, 2),
                Endpoint = GetSegment(uri, 3),
                Query    = query
            };

            if (context.Items[Key] == null)
            {
                lock (ContextLock)
                {
                    if (context.Items[Key] == null)
                    {
                        context.Items[Key] = new List <RequestItem>();
                    }
                }
            }

            var items = context.Items[Key] as List <RequestItem>;

            items.Add(requestItem);
        }
        public static void OnRequestCompletedHandler(IApiCallDetails apiCallDetails)
        {
            var context = HttpContext.Current;

            if (context == null)
            {
                return;
            }

            var requestItem = new RequestItem
            {
                HttpMethod   = apiCallDetails.HttpMethod.ToString(),
                HttpStatus   = apiCallDetails.HttpStatusCode.ToString(),
                Index        = apiCallDetails.Uri.TryGetSegment(1),
                Document     = apiCallDetails.Uri.TryGetSegment(2),
                Endpoint     = apiCallDetails.Uri.TryGetSegment(3),
                Query        = Encoding.UTF8.GetString(apiCallDetails.RequestBodyInBytes ?? new byte[0]),
                ResponseData = Encoding.UTF8.GetString(apiCallDetails.ResponseBodyInBytes ?? new byte[0])
            };

            if (context.Items[Key] == null)
            {
                lock (ContextLock)
                {
                    if (context.Items[Key] == null)
                    {
                        context.Items[Key] = new List <RequestItem>();
                    }
                }
            }

            var items = context.Items[Key] as List <RequestItem>;

            items.Add(requestItem);
        }