From 6008c93347799cdfacc3fa0b5c9320f12bc4043e Mon Sep 17 00:00:00 2001 From: giladvidal Date: Thu, 28 Nov 2019 11:40:11 +0200 Subject: [PATCH] request response metrics --- Gigya.Microdot.ServiceProxy/ServiceProxyProvider.cs | 8 +++++++- Gigya.Microdot.SharedLogic/Events/ClientCallEvent.cs | 9 +++++++++ Gigya.Microdot.SharedLogic/Events/EventConsts.cs | 4 ++++ 3 files changed, 20 insertions(+), 1 deletion(-) diff --git a/Gigya.Microdot.ServiceProxy/ServiceProxyProvider.cs b/Gigya.Microdot.ServiceProxy/ServiceProxyProvider.cs index effd48ad..0c2a74bc 100644 --- a/Gigya.Microdot.ServiceProxy/ServiceProxyProvider.cs +++ b/Gigya.Microdot.ServiceProxy/ServiceProxyProvider.cs @@ -380,8 +380,14 @@ private async Task InvokeCore(HttpServiceRequest request, Type resultRet clientCallEvent.RequestStartTimestamp = Stopwatch.GetTimestamp(); try { - response = await GetHttpClient(config).PostAsync(uri, httpContent).ConfigureAwait(false); + HttpClient cli = GetHttpClient(config); + + response = await cli.PostAsync(uri, httpContent).ConfigureAwait(false); + responseContent = await response.Content.ReadAsStringAsync().ConfigureAwait(false); + + clientCallEvent.clientCallSize = requestContent.Length; + clientCallEvent.clientResponseSize = (responseContent != null ? responseContent.Length : 0); } finally { diff --git a/Gigya.Microdot.SharedLogic/Events/ClientCallEvent.cs b/Gigya.Microdot.SharedLogic/Events/ClientCallEvent.cs index e1de195b..d30bc0e0 100644 --- a/Gigya.Microdot.SharedLogic/Events/ClientCallEvent.cs +++ b/Gigya.Microdot.SharedLogic/Events/ClientCallEvent.cs @@ -74,5 +74,14 @@ public class ClientCallEvent : Event [EventField(EventConsts.statsNetworkTime, OmitFromAudit = true)] public double? NetworkTimeMS => TotalTimeMS - ServerTimeMs; + [EventField(EventConsts.numDocumentsRead)] + public int? numDocumentsRead { get; set; } + + [EventField(EventConsts.clientCallSize)] + public int? clientCallSize { get; set; } + + [EventField(EventConsts.clientResponseSize)] + public int? clientResponseSize { get; set; } + } } diff --git a/Gigya.Microdot.SharedLogic/Events/EventConsts.cs b/Gigya.Microdot.SharedLogic/Events/EventConsts.cs index da00184b..7ebde9d7 100644 --- a/Gigya.Microdot.SharedLogic/Events/EventConsts.cs +++ b/Gigya.Microdot.SharedLogic/Events/EventConsts.cs @@ -74,6 +74,10 @@ public static class EventConsts public const string runtimeDC = "runtime.dc"; public const string runtimeENV = "runtime.env"; + public const string numDocumentsRead = "numDocumentsRead"; + public const string clientCallSize = "clientCallSize"; + public const string clientResponseSize = "clientResponseSize"; + public const string siteID = "siteID"; public const string apikey = "apikey"; public const string partnerID = "partnerID";