Skip to content

Commit

Permalink
Diagnostics: Adds request session token (#3176)
Browse files Browse the repository at this point in the history
Add Session Token into request diagnostics, which will simplify session consistency investigations.
  • Loading branch information
imanvt authored May 9, 2022
1 parent 51be60e commit 13d0f9e
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,7 @@ public void RecordResponse(
storeResult,
request.ResourceType,
request.OperationType,
request.Headers[HttpConstants.HttpHeaders.SessionToken],
locationEndpoint);

lock (this.storeResponseStatistics)
Expand Down Expand Up @@ -441,13 +442,15 @@ public StoreResponseStatistics(
StoreResult storeResult,
ResourceType resourceType,
OperationType operationType,
string requestSessionToken,
Uri locationEndpoint)
{
this.RequestStartTime = requestStartTime;
this.RequestResponseTime = requestResponseTime;
this.StoreResult = storeResult;
this.RequestResourceType = resourceType;
this.RequestOperationType = operationType;
this.RequestSessionToken = requestSessionToken;
this.LocationEndpoint = locationEndpoint;
this.IsSupplementalResponse = operationType == OperationType.Head || operationType == OperationType.HeadFeed;
}
Expand All @@ -457,6 +460,7 @@ public StoreResponseStatistics(
public StoreResult StoreResult { get; }
public ResourceType RequestResourceType { get; }
public OperationType RequestOperationType { get; }
public string RequestSessionToken { get; }
public Uri LocationEndpoint { get; }
public bool IsSupplementalResponse { get; }
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -330,6 +330,12 @@ private void VisitStoreResponseStatistics(
this.jsonWriter.WriteFieldName("OperationType");
this.jsonWriter.WriteStringValue(storeResponseStatistics.RequestOperationType.ToString());

if (!string.IsNullOrEmpty(storeResponseStatistics.RequestSessionToken))
{
this.jsonWriter.WriteFieldName("RequestSessionToken");
this.jsonWriter.WriteStringValue(storeResponseStatistics.RequestSessionToken);
}

this.jsonWriter.WriteFieldName("LocationEndpoint");
this.WriteStringValueOrNull(storeResponseStatistics.LocationEndpoint?.ToString());

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,7 @@
transportRequestStats: TraceWriterBaselineTests.CreateTransportRequestStats()),
ResourceType.Document,
OperationType.Query,
"42",
uri1.Uri);
TraceWriterBaselineTests.GetPrivateField<List<StoreResponseStatistics>>(datum, "storeResponseStatistics").Add(storeResponseStatistics);
Expand Down Expand Up @@ -341,6 +342,7 @@
"ResponseTimeUTC": "9999-12-31T23:59:59.9999999",
"ResourceType": "Document",
"OperationType": "Query",
"RequestSessionToken": "42",
"LocationEndpoint": "http://someuri1.com/",
"StoreResult": {
"ActivityId": "00000000-0000-0000-0000-000000000000",
Expand Down Expand Up @@ -463,6 +465,7 @@
transportRequestStats: TraceWriterBaselineTests.CreateTransportRequestStats()),
resourceType: default,
operationType: default,
requestSessionToken: default,
locationEndpoint: default);
TraceWriterBaselineTests.GetPrivateField<List<StoreResponseStatistics>>(datum, "storeResponseStatistics").Add(storeResponseStatistics);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,7 @@ public void ValidateStoreResultSerialization()
storeResult,
ResourceType.Document,
OperationType.Query,
"42",
new Uri("http://someUri1.com"));

((List<StoreResponseStatistics>)datum.GetType().GetField("storeResponseStatistics", BindingFlags.NonPublic | BindingFlags.Instance).GetValue(datum)).Add(storeResponseStatistics);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -385,6 +385,7 @@ public void TraceData()
transportRequestStats: TraceWriterBaselineTests.CreateTransportRequestStats()),
ResourceType.Document,
OperationType.Query,
"42",
uri1.Uri);

TraceWriterBaselineTests.GetPrivateField<List<StoreResponseStatistics>>(datum, "storeResponseStatistics").Add(storeResponseStatistics);
Expand Down Expand Up @@ -437,6 +438,7 @@ public void TraceData()
transportRequestStats: TraceWriterBaselineTests.CreateTransportRequestStats()),
resourceType: default,
operationType: default,
requestSessionToken: default,
locationEndpoint: default);

TraceWriterBaselineTests.GetPrivateField<List<StoreResponseStatistics>>(datum, "storeResponseStatistics").Add(storeResponseStatistics);
Expand Down

0 comments on commit 13d0f9e

Please sign in to comment.