Skip to content

Commit

Permalink
Diagnostics: Adds Duration field to HttpResponseStatistics in Diagnos…
Browse files Browse the repository at this point in the history
…tics (#2558)

This PR replaces the EndTimeUtc with a Duration field in HttpResponseStats, which makes it easier to read.
  • Loading branch information
asketagarwal authored Jun 16, 2021
1 parent 867c8c8 commit b2614ce
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -380,7 +380,7 @@ public HttpResponseStatistics(
Exception exception)
{
this.RequestStartTime = requestStartTime;
this.RequestEndTime = requestEndTime;
this.Duration = requestEndTime - requestStartTime;
this.HttpResponseMessage = responseMessage;
this.Exception = exception;
this.ResourceType = resourceType;
Expand All @@ -399,7 +399,7 @@ public HttpResponseStatistics(
}

public DateTime RequestStartTime { get; }
public DateTime RequestEndTime { get; }
public TimeSpan Duration { get; }
public HttpResponseMessage HttpResponseMessage { get; }
public Exception Exception { get; }
public ResourceType ResourceType { get; }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -253,8 +253,8 @@ private void VisitHttpResponseStatistics(ClientSideRequestStatisticsTraceDatum.H
jsonWriter.WriteFieldName("StartTimeUTC");
this.WriteDateTimeStringValue(stat.RequestStartTime);

jsonWriter.WriteFieldName("EndTimeUTC");
this.WriteDateTimeStringValue(stat.RequestEndTime);
jsonWriter.WriteFieldName("DurationInMs");
jsonWriter.WriteNumber64Value(stat.Duration.TotalMilliseconds);

jsonWriter.WriteFieldName("RequestUri");
jsonWriter.WriteStringValue(stat.RequestUri.ToString());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -447,7 +447,7 @@ public void Visit(ClientSideRequestStatisticsTraceDatum clientSideRequestStatist
{
stringBuilder.AppendLine($"{space}HttpResponse");
stringBuilder.AppendLine($"{space}{space}RequestStartTime: {stat.RequestStartTime.ToString("o", CultureInfo.InvariantCulture)}");
stringBuilder.AppendLine($"{space}{space}RequestEndTime: {stat.RequestEndTime.ToString("o", CultureInfo.InvariantCulture)}");
stringBuilder.AppendLine($"{space}{space}DurationInMs: {stat.Duration.TotalMilliseconds:0.00}");
stringBuilder.AppendLine($"{space}{space}RequestUri: {stat.RequestUri}");
stringBuilder.AppendLine($"{space}{space}ResourceType: {stat.ResourceType}");
stringBuilder.AppendLine($"{space}{space}HttpMethod: {stat.HttpMethod}");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public async Task GatewayRequestStatsTest()
Assert.IsNotNull(datum.HttpResponseStatisticsList);
Assert.AreEqual(datum.HttpResponseStatisticsList.Count, 1);
Assert.IsNotNull(datum.HttpResponseStatisticsList[0].HttpResponseMessage);
Assert.AreEqual(datum.RequestEndTimeUtc, datum.HttpResponseStatisticsList[0].RequestEndTime);
Assert.AreEqual(datum.RequestEndTimeUtc, datum.HttpResponseStatisticsList[0].RequestStartTime + datum.HttpResponseStatisticsList[0].Duration);
}

[TestMethod]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -653,14 +653,14 @@
Http Response Statistics
HttpResponse
RequestStartTime: 0001-01-01T00:00:00.0000000
RequestEndTime: 9999-12-31T23:59:59.9999999
DurationInMs: 315537897600000.00
RequestUri: http://someuri1.com/
ResourceType: Document
HttpMethod: GET
StatusCode: OK
HttpResponse
RequestStartTime: 0001-01-01T00:00:00.0000000
RequestEndTime: 9999-12-31T23:59:59.9999999
DurationInMs: 315537897600000.00
RequestUri: http://someuri1.com/
ResourceType: Document
HttpMethod: GET
Expand Down Expand Up @@ -689,7 +689,7 @@
"HttpResponseStats": [
{
"StartTimeUTC": "0001-01-01T00:00:00",
"EndTimeUTC": "9999-12-31T23:59:59.9999999",
"DurationInMs": 315537897600000,
"RequestUri": "http://someuri1.com/",
"ResourceType": "Document",
"HttpMethod": "GET",
Expand All @@ -698,7 +698,7 @@
},
{
"StartTimeUTC": "0001-01-01T00:00:00",
"EndTimeUTC": "9999-12-31T23:59:59.9999999",
"DurationInMs": 315537897600000,
"RequestUri": "http://someuri1.com/",
"ResourceType": "Document",
"HttpMethod": "GET",
Expand Down

0 comments on commit b2614ce

Please sign in to comment.