-
Notifications
You must be signed in to change notification settings - Fork 533
[Internal] Thin Client Integration: Adds diagnostic log info for thinclient mode. #5263
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
Changes from 1 commit
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
e7bb6c0
Add diagnostic log info for thinclient.
aavasthy e5a4b5a
Update user agent flag names.
aavasthy ad13205
Merge branch 'master' into users/aavasthy/thinclientDiagnostics
aavasthy 841756e
Code changes to address review comments and add more tests.
kundadebdatta 2ab112c
Code changes to update the writers
kundadebdatta File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -19,7 +19,10 @@ public SummaryDiagnostics(ITrace trace) | |
| this.DirectRequestsSummary | ||
| = new Lazy<Dictionary<(int, int), int>>(() => new Dictionary<(int, int), int>()); | ||
| this.GatewayRequestsSummary | ||
| = new Lazy<Dictionary<(int, int), int>>(() => new Dictionary<(int, int), int>()); | ||
| = new Lazy<Dictionary<(int, int), int>>(() => new Dictionary<(int, int), int>()); | ||
| this.ThinclientRequestsSummary | ||
| = new Lazy<Dictionary<(int, int), int>>(() => new Dictionary<(int, int), int>()); | ||
|
|
||
| this.AllRegionsContacted | ||
| = new Lazy<HashSet<Uri>>(() => new HashSet<Uri>()); | ||
|
|
||
|
|
@@ -31,27 +34,34 @@ public SummaryDiagnostics(ITrace trace) | |
|
|
||
| public Lazy<List<StoreResponseStatistics>> StoreResponseStatistics { get; private set; } = new Lazy<List<StoreResponseStatistics>>(() => new List<StoreResponseStatistics>()); | ||
| // Count of (StatusCode, SubStatusCode) tuples | ||
| public Lazy<Dictionary<(int statusCode, int subStatusCode), int>> DirectRequestsSummary { get; private set; } | ||
|
|
||
| public Lazy<Dictionary<(int statusCode, int subStatusCode), int>> DirectRequestsSummary { get; private set; } | ||
|
|
||
| public Lazy<List<HttpResponseStatistics>> ThinclientResponseStatistics { get; private set; } = new Lazy<List<HttpResponseStatistics>>(() => new List<HttpResponseStatistics>()); | ||
| public Lazy<Dictionary<(int statusCode, int subStatusCode), int>> ThinclientRequestsSummary { get; private set; } | ||
| public Lazy<List<HttpResponseStatistics>> HttpResponseStatistics { get; private set; } = new Lazy<List<HttpResponseStatistics>>(() => new List<HttpResponseStatistics>()); | ||
| public Lazy<Dictionary<(int statusCode, int subStatusCode), int>> GatewayRequestsSummary { get; private set; } | ||
|
|
||
| private void CollectSummaryFromTraceTree(ITrace currentTrace) | ||
| { | ||
| foreach (object datums in currentTrace.Data.Values) | ||
| { | ||
| if (datums is ClientSideRequestStatisticsTraceDatum clientSideRequestStatisticsTraceDatum) | ||
| { | ||
| this.AggregateStatsFromStoreResults(clientSideRequestStatisticsTraceDatum.StoreResponseStatisticsList); | ||
| this.AggregateGatewayStatistics(clientSideRequestStatisticsTraceDatum.HttpResponseStatisticsList); | ||
| this.AggregateRegionsContacted(clientSideRequestStatisticsTraceDatum.RegionsContacted); | ||
| } | ||
| } | ||
|
|
||
| foreach (ITrace childTrace in currentTrace.Children) | ||
| { | ||
| this.CollectSummaryFromTraceTree(childTrace); | ||
| } | ||
|
|
||
| private void CollectSummaryFromTraceTree(ITrace currentTrace) | ||
| { | ||
| foreach (object datums in currentTrace.Data.Values) | ||
| { | ||
| if (datums is ClientSideRequestStatisticsTraceDatum clientSideRequestStatisticsTraceDatum) | ||
| { | ||
| this.AggregateStatsFromStoreResults(clientSideRequestStatisticsTraceDatum.StoreResponseStatisticsList); | ||
| this.AggregateGatewayStatistics(clientSideRequestStatisticsTraceDatum.HttpResponseStatisticsList); | ||
| this.AggregateRegionsContacted(clientSideRequestStatisticsTraceDatum.RegionsContacted); | ||
|
|
||
| if (clientSideRequestStatisticsTraceDatum.ThinclientResponseStatisticsList != null) | ||
| { | ||
| this.AggregateThinclientStatistics(clientSideRequestStatisticsTraceDatum.ThinclientResponseStatisticsList); | ||
| } | ||
| } | ||
| } | ||
|
|
||
| foreach (ITrace childTrace in currentTrace.Children) | ||
| { | ||
| this.CollectSummaryFromTraceTree(childTrace); | ||
| } | ||
| } | ||
|
|
||
| private void AggregateRegionsContacted(HashSet<(string, Uri)> regionsContacted) | ||
|
|
@@ -112,43 +122,86 @@ private void AggregateStatsFromStoreResults(IReadOnlyList<ClientSideRequestStati | |
| this.DirectRequestsSummary.Value[(statusCode, subStatusCode)]++; | ||
| } | ||
| } | ||
| } | ||
|
|
||
| public void WriteSummaryDiagnostics(IJsonWriter jsonWriter) | ||
| { | ||
| jsonWriter.WriteObjectStart(); | ||
|
|
||
| if (this.DirectRequestsSummary.IsValueCreated) | ||
| { | ||
| jsonWriter.WriteFieldName("DirectCalls"); | ||
| jsonWriter.WriteObjectStart(); | ||
| foreach (KeyValuePair<(int, int), int> kvp in this.DirectRequestsSummary.Value) | ||
| { | ||
| jsonWriter.WriteFieldName(kvp.Key.ToString()); | ||
| jsonWriter.WriteNumberValue(kvp.Value); | ||
| } | ||
| jsonWriter.WriteObjectEnd(); | ||
| } | ||
|
|
||
| if (this.AllRegionsContacted.IsValueCreated) | ||
| { | ||
| jsonWriter.WriteFieldName("RegionsContacted"); | ||
| jsonWriter.WriteNumberValue(this.AllRegionsContacted.Value.Count); | ||
| } | ||
|
|
||
| if (this.GatewayRequestsSummary.IsValueCreated) | ||
| { | ||
| jsonWriter.WriteFieldName("GatewayCalls"); | ||
| jsonWriter.WriteObjectStart(); | ||
| foreach (KeyValuePair<(int, int), int> kvp in this.GatewayRequestsSummary.Value) | ||
| { | ||
| jsonWriter.WriteFieldName(kvp.Key.ToString()); | ||
| jsonWriter.WriteNumberValue(kvp.Value); | ||
| } | ||
| jsonWriter.WriteObjectEnd(); | ||
| } | ||
|
|
||
| jsonWriter.WriteObjectEnd(); | ||
| } | ||
|
|
||
| private void AggregateThinclientStatistics(IReadOnlyList<ClientSideRequestStatisticsTraceDatum.HttpResponseStatistics> thinclientResponseStatisticsList) | ||
| { | ||
| foreach (ClientSideRequestStatisticsTraceDatum.HttpResponseStatistics thinclientResponseStatistics in thinclientResponseStatisticsList) | ||
| { | ||
| this.ThinclientResponseStatistics.Value.Add(thinclientResponseStatistics); // <-- Add this line | ||
|
|
||
| int statusCode = 0; | ||
| int substatusCode = 0; | ||
| if (thinclientResponseStatistics.HttpResponseMessage != null) | ||
| { | ||
| statusCode = (int)thinclientResponseStatistics.HttpResponseMessage.StatusCode; | ||
| if (!int.TryParse(SummaryDiagnostics.GetSubStatusCodes(thinclientResponseStatistics), | ||
| NumberStyles.Integer, | ||
| CultureInfo.InvariantCulture, | ||
| out substatusCode)) | ||
| { | ||
| substatusCode = 0; | ||
| } | ||
| } | ||
|
|
||
| if (!this.ThinclientRequestsSummary.Value.ContainsKey((statusCode, substatusCode))) | ||
| { | ||
| this.ThinclientRequestsSummary.Value[(statusCode, substatusCode)] = 1; | ||
| } | ||
| else | ||
| { | ||
| this.ThinclientRequestsSummary.Value[(statusCode, substatusCode)]++; | ||
| } | ||
| } | ||
| } | ||
|
|
||
| public void WriteSummaryDiagnostics(IJsonWriter jsonWriter) | ||
| { | ||
| jsonWriter.WriteObjectStart(); | ||
|
|
||
| if (this.DirectRequestsSummary.IsValueCreated) | ||
| { | ||
| jsonWriter.WriteFieldName("DirectCalls"); | ||
| jsonWriter.WriteObjectStart(); | ||
| foreach (KeyValuePair<(int, int), int> kvp in this.DirectRequestsSummary.Value) | ||
| { | ||
| jsonWriter.WriteFieldName(kvp.Key.ToString()); | ||
| jsonWriter.WriteNumberValue(kvp.Value); | ||
| } | ||
| jsonWriter.WriteObjectEnd(); | ||
| } | ||
|
|
||
| if (this.AllRegionsContacted.IsValueCreated) | ||
| { | ||
| jsonWriter.WriteFieldName("RegionsContacted"); | ||
| jsonWriter.WriteNumberValue(this.AllRegionsContacted.Value.Count); | ||
| } | ||
|
|
||
| if (this.GatewayRequestsSummary.IsValueCreated) | ||
| { | ||
| jsonWriter.WriteFieldName("GatewayCalls"); | ||
| jsonWriter.WriteObjectStart(); | ||
| foreach (KeyValuePair<(int, int), int> kvp in this.GatewayRequestsSummary.Value) | ||
| { | ||
| jsonWriter.WriteFieldName(kvp.Key.ToString()); | ||
| jsonWriter.WriteNumberValue(kvp.Value); | ||
| } | ||
| jsonWriter.WriteObjectEnd(); | ||
| } | ||
|
|
||
| if (this.ThinclientRequestsSummary.IsValueCreated) | ||
| { | ||
| jsonWriter.WriteFieldName("ThinclientCalls"); | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Change it to
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Let's keep thinclient across, thinclient is the mode name and summary has details about different mode names. |
||
| jsonWriter.WriteObjectStart(); | ||
| foreach (KeyValuePair<(int, int), int> kvp in this.ThinclientRequestsSummary.Value) | ||
| { | ||
| jsonWriter.WriteFieldName(kvp.Key.ToString()); | ||
| jsonWriter.WriteNumberValue(kvp.Value); | ||
| } | ||
| jsonWriter.WriteObjectEnd(); | ||
| } | ||
|
|
||
| jsonWriter.WriteObjectEnd(); | ||
| } | ||
|
|
||
| /// <summary> | ||
|
|
||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.