private void VisitAddressResolutionStatistics( ClientSideRequestStatisticsTraceDatum.AddressResolutionStatistics addressResolutionStatistics) { this.jsonWriter.WriteObjectStart(); this.jsonWriter.WriteFieldName("StartTimeUTC"); this.WriteDateTimeStringValue(addressResolutionStatistics.StartTime); this.jsonWriter.WriteFieldName("EndTimeUTC"); if (addressResolutionStatistics.EndTime.HasValue) { this.WriteDateTimeStringValue(addressResolutionStatistics.EndTime.Value); } else { this.jsonWriter.WriteStringValue("EndTime Never Set."); } this.jsonWriter.WriteFieldName("TargetEndpoint"); if (addressResolutionStatistics.TargetEndpoint == null) { this.jsonWriter.WriteNullValue(); } else { this.jsonWriter.WriteStringValue(addressResolutionStatistics.TargetEndpoint); } this.jsonWriter.WriteObjectEnd(); }
private static void VisitAddressResolutionStatistics( ClientSideRequestStatisticsTraceDatum.AddressResolutionStatistics addressResolutionStatistics, IJsonWriter jsonWriter) { jsonWriter.WriteObjectStart(); jsonWriter.WriteFieldName("StartTimeUTC"); jsonWriter.WriteStringValue(addressResolutionStatistics.StartTime.ToString("o", CultureInfo.InvariantCulture)); jsonWriter.WriteFieldName("EndTimeUTC"); if (addressResolutionStatistics.EndTime.HasValue) { jsonWriter.WriteStringValue(addressResolutionStatistics.EndTime.Value.ToString("o", CultureInfo.InvariantCulture)); } else { jsonWriter.WriteStringValue("EndTime Never Set."); } jsonWriter.WriteFieldName("TargetEndpoint"); if (addressResolutionStatistics.TargetEndpoint == null) { jsonWriter.WriteNullValue(); } else { jsonWriter.WriteStringValue(addressResolutionStatistics.TargetEndpoint); } jsonWriter.WriteObjectEnd(); }
public void TraceData() { List <Input> inputs = new List <Input>(); int startLineNumber; int endLineNumber; //---------------------------------------------------------------- // Point Operation Statistics //---------------------------------------------------------------- { startLineNumber = GetLineNumber(); TraceForBaselineTesting rootTrace; using (rootTrace = TraceForBaselineTesting.GetRootTrace()) { PointOperationStatisticsTraceDatum datum = new PointOperationStatisticsTraceDatum( activityId: Guid.Empty.ToString(), responseTimeUtc: new DateTime(2020, 1, 2, 3, 4, 5, 6), statusCode: System.Net.HttpStatusCode.OK, subStatusCode: Documents.SubStatusCodes.WriteForbidden, requestCharge: 4, errorMessage: null, method: HttpMethod.Post, requestUri: "http://localhost.com", requestSessionToken: nameof(PointOperationStatisticsTraceDatum.RequestSessionToken), responseSessionToken: nameof(PointOperationStatisticsTraceDatum.ResponseSessionToken)); rootTrace.AddDatum("Point Operation Statistics", datum); } endLineNumber = GetLineNumber(); inputs.Add(new Input("Point Operation Statistics", rootTrace, startLineNumber, endLineNumber)); } //---------------------------------------------------------------- //---------------------------------------------------------------- // Query Metrics //---------------------------------------------------------------- { startLineNumber = GetLineNumber(); TraceForBaselineTesting rootTrace; using (rootTrace = TraceForBaselineTesting.GetRootTrace()) { QueryMetricsTraceDatum datum = new QueryMetricsTraceDatum( new QueryMetrics( BackendMetricsTests.MockBackendMetrics, IndexUtilizationInfoTests.MockIndexUtilizationInfo, ClientSideMetricsTests.MockClientSideMetrics)); rootTrace.AddDatum("Query Metrics", datum); } endLineNumber = GetLineNumber(); inputs.Add(new Input("Query Metrics", rootTrace, startLineNumber, endLineNumber)); } //---------------------------------------------------------------- //---------------------------------------------------------------- // Client Side Request Stats //---------------------------------------------------------------- { startLineNumber = GetLineNumber(); TraceForBaselineTesting rootTrace; using (rootTrace = TraceForBaselineTesting.GetRootTrace()) { ClientSideRequestStatisticsTraceDatum datum = new ClientSideRequestStatisticsTraceDatum(DateTime.MinValue); Uri uri1 = new Uri("http://someUri1.com"); Uri uri2 = new Uri("http://someUri2.com"); datum.ContactedReplicas.Add(uri1); datum.ContactedReplicas.Add(uri2); ClientSideRequestStatisticsTraceDatum.AddressResolutionStatistics mockStatistics = new ClientSideRequestStatisticsTraceDatum.AddressResolutionStatistics( DateTime.MinValue, DateTime.MaxValue, "http://localhost.com"); datum.EndpointToAddressResolutionStatistics["asdf"] = mockStatistics; datum.EndpointToAddressResolutionStatistics["asdf2"] = mockStatistics; datum.FailedReplicas.Add(uri1); datum.FailedReplicas.Add(uri2); datum.RegionsContacted.Add(uri1); datum.RegionsContacted.Add(uri2); datum.RequestEndTimeUtc = DateTime.MaxValue; StoreResponseStatistics storeResponseStatistics = new StoreResponseStatistics( DateTime.MinValue, DateTime.MaxValue, new Documents.StoreResult( storeResponse: new StoreResponse(), exception: null, partitionKeyRangeId: 42.ToString(), lsn: 1337, quorumAckedLsn: 23, requestCharge: 3.14, currentReplicaSetSize: 4, currentWriteQuorum: 3, isValid: true, storePhysicalAddress: new Uri("http://storephysicaladdress.com"), globalCommittedLSN: 1234, numberOfReadRegions: 13, itemLSN: 15, sessionToken: new SimpleSessionToken(42), usingLocalLSN: true, activityId: Guid.Empty.ToString()), ResourceType.Document, OperationType.Query, uri1); datum.StoreResponseStatisticsList.Add(storeResponseStatistics); rootTrace.AddDatum("Client Side Request Stats", datum); } endLineNumber = GetLineNumber(); inputs.Add(new Input("Client Side Request Stats", rootTrace, startLineNumber, endLineNumber)); } //---------------------------------------------------------------- //---------------------------------------------------------------- // CPU History //---------------------------------------------------------------- { startLineNumber = GetLineNumber(); TraceForBaselineTesting rootTrace; using (rootTrace = TraceForBaselineTesting.GetRootTrace()) { CpuHistoryTraceDatum datum = new CpuHistoryTraceDatum( new Documents.Rntbd.CpuLoadHistory( new ReadOnlyCollection <Documents.Rntbd.CpuLoad>( new List <Documents.Rntbd.CpuLoad>() { new Documents.Rntbd.CpuLoad(DateTime.MinValue, 42), new Documents.Rntbd.CpuLoad(DateTime.MinValue, 23), }), monitoringInterval: TimeSpan.MaxValue)); rootTrace.AddDatum("CPU History", datum); } endLineNumber = GetLineNumber(); inputs.Add(new Input("CPU History", rootTrace, startLineNumber, endLineNumber)); } //---------------------------------------------------------------- this.ExecuteTestSuite(inputs); }