Skip to content
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

Diagnostics: Adds Gateway Request Stats #2324

Merged
merged 20 commits into from
Apr 23, 2021
Merged

Conversation

asketagarwal
Copy link
Contributor

@asketagarwal asketagarwal commented Mar 19, 2021

Pull Request Template

The current client side request stats does not record http operations. This is extending the contract to include all http operations which is necessary for troubleshooting latency issues. It was chosen to extend the IClientSideRequestStats rather than wiring though ITrace because of the dependencies in the direct package. Using ITrace would require wiring through all the shared code which is much larger task.

Diagostics Changes

{
   "HttpResponseStatistics":[
      {
         "StartTimeUTC":"2021-03-22T10:11:47.5592589Z",
         "EndTimeUTC":"2021-03-22T10:11:50.3805645Z",
         "RequestUri":"https://127.0.0.1:8081/dbs/7423ce13-7c53-4d86-aa0f-8baafe5350a2/colls/176a5bb7-368b-4444-82
9b-ef5c8308afd8/docs/7dd28a8a-f2d3-4d9d-869a-40754c82db3c",
         "ResourceType":"Document",
         "HttpMethod":"GET",
         "ExceptionType":"System.OperationCanceledException",
         "ExceptionMessage":"The operation was canceled."
      },
      {
         "StartTimeUTC":"2021-03-22T10:11:47.5592589Z",
         "EndTimeUTC":"2021-03-22T10:11:51.2861564Z",
         "RequestUri":"https://127.0.0.1:8081/dbs/7423ce13-7c53-4d86-aa0f-8baafe5350a2/colls/176a5bb7-368b-4444-829b-ef5c8308afd8/docs/7dd28a8a-f2d3-4d9d-869a-40754c82db3c",
         "ResourceType":"Document",
         "HttpMethod":"GET",
         "ExceptionType":"System.OperationCanceledException",
         "ExceptionMessage":"The operation was canceled."
      },
      {
         "StartTimeUTC":"2021-03-22T10:11:47.5592589Z",
         "EndTimeUTC":"2021-03-22T10:11:52.2945455Z",
         "RequestUri":"https://127.0.0.1:8081/dbs/7423ce13-7c53-4d86-aa0f-8baafe5350a2/colls/176a5bb7-368b-4444-829b-ef5c8308afd8/docs/7dd28a8a-f2d3-4d9d-869a-40754c82db3c",
         "ResourceType":"Document",
         "HttpMethod":"GET",
         "StatusCode":"OK"
      }
   ]
}

@kirankumarkolli
Copy link
Member

Do the address resolution statics cover these?

@@ -169,7 +169,7 @@ public static HttpMessageHandler CreateHttpClientHandler(int gatewayModeMaxConne
INameValueCollection additionalHeaders,
ResourceType resourceType,
HttpTimeoutPolicy timeoutPolicy,
ITrace trace,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When to use ITrace vs IClientSideRequestStatistics?

Copy link
Contributor

@j82w j82w Mar 23, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IClientSideRequestStatistics will be used for any contracts with the Direct package. Taking a dependency on ITrace will cause a circle reference which make it difficult to make any contract changes. This allows the v2 SDK to get the additional tracing. If it is decided that ITrace should replace IClientSideRequestStatistics it will require refactoring the v2 SDK and the entire Direct package.

jsonWriter.WriteStringValue(stat.Exception.GetType().ToString());

jsonWriter.WriteFieldName("ExceptionMessage");
jsonWriter.WriteStringValue(stat.Exception.Message);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If it worth instead capturing the ToString instead of the Message? Or the stack trace?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is the size a concern? Stack trace and tostring which also prints the stack trace can be very large.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not the size, but rather, would we have enough troubleshooting information just from the message

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will only include exception thrown by the HttpClient so I think it will be ok to just record the message. The Trace structure will let us know where it was thrown from.

@j82w j82w requested a review from neildsh as a code owner April 16, 2021 21:24
j82w
j82w previously approved these changes Apr 16, 2021

Debug.Assert(System.Diagnostics.Trace.CorrelationManager.ActivityId != Guid.Empty, "Trace activity id is missing");
CosmosException cosmosException = CosmosExceptionFactory.CreateRequestTimeoutException(
message: ex.Data?["Message"].ToString(),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not just ex.Message?

Copy link
Member

@kirankumarkolli kirankumarkolli left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please verify that there is no perf impact in steady state.

Copy link
Member

@kirankumarkolli kirankumarkolli left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please verify that there is no perf impact in steady state.

@j82w
Copy link
Contributor

j82w commented Apr 23, 2021

Please verify that there is no perf impact in steady state.

I verified the end to end perf shows no changes in steady state.

@j82w j82w merged commit 64cbee3 into master Apr 23, 2021
@j82w j82w deleted the users/askagarw/GatewayRequestStats branch April 23, 2021 11:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants