private void ParseLogFile(string filename, DateTime startTimeUTC, DateTime endTimeUTC, List <AzureBlobLogRecordV1> records) { string line1; using (StreamReader reader = File.OpenText(filename)) { while ((line1 = reader.ReadLine()) != null) { string line = line1.Replace("&", "&"); string[] fields = line.Split(';'); var record = new AzureBlobLogRecordV1(); record.RequestStartTimeUTC = DateTime.Parse(fields[1], CultureInfo.InvariantCulture).ToUniversalTime(); record.OperationType = (AzureOperationTypeV1)Enum.Parse(typeof(AzureOperationTypeV1), fields[2]); record.RequestStatus = (AzureRequestStatusV1)Enum.Parse(typeof(AzureRequestStatusV1), fields[3]); record.HttpStatusCode = int.Parse(fields[4], CultureInfo.InvariantCulture); record.EndToEndLatencyMilliseconds = int.Parse(fields[5], CultureInfo.InvariantCulture); record.ServerLatencyMilliseconds = int.Parse(fields[6], CultureInfo.InvariantCulture); record.RequestPacketSize = int.Parse(fields[18], CultureInfo.InvariantCulture); record.ResponsePacketSize = int.Parse(fields[20], CultureInfo.InvariantCulture); record.RequestContentLength = int.Parse(fields[21], CultureInfo.InvariantCulture); if (record.RequestStartTimeUTC.CompareTo(startTimeUTC) >= 0 && record.RequestStartTimeUTC.CompareTo(endTimeUTC) <= 0) { records.Add(record); } } } }
private void ParseLogFile(string filename, DateTime startTimeUTC, DateTime endTimeUTC, List<AzureBlobLogRecordV1> records) { string line1; using (StreamReader reader = File.OpenText(filename)) { while ((line1 = reader.ReadLine()) != null) { string line = line1.Replace("&", "&"); string[] fields = line.Split(';'); var record = new AzureBlobLogRecordV1(); record.RequestStartTimeUTC = DateTime.Parse(fields[1], CultureInfo.InvariantCulture).ToUniversalTime(); record.OperationType = (AzureOperationTypeV1)Enum.Parse(typeof(AzureOperationTypeV1), fields[2]); record.RequestStatus = (AzureRequestStatusV1)Enum.Parse(typeof(AzureRequestStatusV1), fields[3]); record.HttpStatusCode = int.Parse(fields[4], CultureInfo.InvariantCulture); record.EndToEndLatencyMilliseconds = int.Parse(fields[5], CultureInfo.InvariantCulture); record.ServerLatencyMilliseconds = int.Parse(fields[6], CultureInfo.InvariantCulture); record.RequestPacketSize = int.Parse(fields[18], CultureInfo.InvariantCulture); record.ResponsePacketSize = int.Parse(fields[20], CultureInfo.InvariantCulture); record.RequestContentLength = int.Parse(fields[21], CultureInfo.InvariantCulture); if (record.RequestStartTimeUTC.CompareTo(startTimeUTC) >= 0 && record.RequestStartTimeUTC.CompareTo(endTimeUTC) <= 0) { records.Add(record); } } } }
private List <PerSecondAggregate> CalculatePerSecondAggregates(List <AzureBlobLogRecordV1> records) { var perSecondAggregates = new List <PerSecondAggregate>(); DateTime start = records[0].RequestStartTimeUTC; long currentSecond = 0; long successBytes = 0; long throttleBytes = 0; long failBytes = 0; long totalBytes = 0; long readBytes = 0; long writeBytes = 0; long requestCount = 0; long maxLatencyTotalMilliseconds = 0; for (int i = 0; i < records.Count; i++) { AzureBlobLogRecordV1 r = records[i]; TimeSpan ts = r.RequestStartTimeUTC.Subtract(start); var sec = (long)ts.TotalSeconds; //if we have entered a new accumulation period if (sec != currentSecond) { perSecondAggregates.Add( new PerSecondAggregate( currentSecond, Utils.ByteToMbit(successBytes), Utils.ByteToMbit(readBytes), Utils.ByteToMbit(writeBytes), Utils.ByteToMbit(throttleBytes), Utils.ByteToMbit(failBytes), Utils.ByteToMbit(totalBytes), maxLatencyTotalMilliseconds)); currentSecond = sec; successBytes = 0; readBytes = 0; writeBytes = 0; throttleBytes = 0; failBytes = 0; totalBytes = 0; requestCount = 0; maxLatencyTotalMilliseconds = 0; } if (r.IsRead) { readBytes += r.DataSize; } if (r.OperationType == AzureOperationTypeV1.PutBlob || r.OperationType == AzureOperationTypeV1.PutBlock) { writeBytes += r.DataSize; } if (r.IsSuccess) { successBytes += r.DataSize; } else if (r.IsThrottle) { throttleBytes += r.DataSize; } else { failBytes += r.DataSize; } totalBytes += r.DataSize; requestCount++; if (r.EndToEndLatencyMilliseconds > maxLatencyTotalMilliseconds) { maxLatencyTotalMilliseconds = r.EndToEndLatencyMilliseconds; } } // and emit the last period.. perSecondAggregates.Add( new PerSecondAggregate( currentSecond, Utils.ByteToMbit(successBytes), Utils.ByteToMbit(readBytes), Utils.ByteToMbit(writeBytes), Utils.ByteToMbit(throttleBytes), Utils.ByteToMbit(failBytes), Utils.ByteToMbit(totalBytes), maxLatencyTotalMilliseconds)); return(perSecondAggregates); }