Пример #1
0
		public void FindLastMessage_LastMessageIsAfterNow()
		{
			var lastEntryPK = AzureDiagnosticsUtils.FindLastMessagePartitionKey(
				new AzureDiagnosticLogsTableMock().Add(TestEventTimestampFromMinutes(1), "hey").Add(TestEventTimestampFromMinutes(10), "there"),
				new DateTime(TestEventTimestampFromMinutes(7), DateTimeKind.Utc));
			Assert.AreEqual(AzureDiagnosticsUtils.EventTickCountToEventPartitionKey(TestEventTimestampFromMinutes(10)), lastEntryPK.ToString());
		}
Пример #2
0
		public void EventTickCountToEventPartitionKeyTest()
		{
			// sample numbers are taken from read WADLogsTable

			Assert.AreEqual("0634923055200000000", AzureDiagnosticsUtils.EventTickCountToEventPartitionKey(634923055356353096));
			Assert.AreEqual("0634904775000000000", AzureDiagnosticsUtils.EventTickCountToEventPartitionKey(634904775152901748));
			Assert.AreEqual("0634903933800000000", AzureDiagnosticsUtils.EventTickCountToEventPartitionKey(634903934382982291));
		}
Пример #3
0
		public void FindLastMessage_ManyMessagesAtTheSameSecond()
		{
			var lastEntryPK = AzureDiagnosticsUtils.FindLastMessagePartitionKey(
				new AzureDiagnosticLogsTableMock()
					.Add(TestEventTimestampFromMinutes(2), "hey")
					.Add(TestEventTimestampFromMinutes(9), "there")
					.Add(TestEventTimestampFromMinutes(9)+1, "there2")
					.Add(TestEventTimestampFromMinutes(9)+2, "there3"),
				new DateTime(TestEventTimestampFromMinutes(15), DateTimeKind.Utc));
			Assert.AreEqual(AzureDiagnosticsUtils.EventTickCountToEventPartitionKey(TestEventTimestampFromMinutes(9)), lastEntryPK.ToString());
		}
Пример #4
0
			static WADLogsTableEntry MakeWADEntry(KeyValuePair<long, string> entry)
			{
				if (entry.Value == null)
					return null;
				return new WADLogsTableEntry()
				{
					PartitionKey = AzureDiagnosticsUtils.EventTickCountToEventPartitionKey(entry.Key),
					EventTickCount = entry.Key,
					Timestamp = new DateTime(entry.Key, DateTimeKind.Utc),
					Message = entry.Value
				};
			}
Пример #5
0
			public IEnumerable<AzureDiagnosticLogEntry> GetEntriesInRange(string beginPartitionKey, string endPartitionKey, int? limit)
			{
				EnsureCompleted();
				var x =
					from entry in entries
					let pk = AzureDiagnosticsUtils.EventTickCountToEventPartitionKey(entry.Key)
					where string.Compare(pk, beginPartitionKey) >= 0 && string.Compare(pk, endPartitionKey) < 0
					select MakeWADEntry(entry);
				if (limit != null)
					x = x.Take(limit.Value);
				return x;
			}
Пример #6
0
			public AzureDiagnosticLogEntry GetFirstEntryOlderThan(string partitionKey)
			{
				EnsureCompleted();
				return MakeWADEntry(entries.FirstOrDefault(entry => 
					string.Compare(AzureDiagnosticsUtils.EventTickCountToEventPartitionKey(entry.Key), partitionKey) > 0));
			}