Example #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());
		}
Example #2
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());
		}
Example #3
0
 protected override void LiveLogListen(CancellationToken stopEvt, LiveLogXMLWriter output)
 {
     using (host.Trace.NewFrame)
     {
         try
         {
             if (azureConnectParams.Mode == AzureConnectionParams.LoadMode.FixedRange)
             {
                 ReportBackgroundActivityStatus(true);
                 foreach (var entry in AzureDiagnosticsUtils.LoadEntriesRange(
                              table, new EntryPartition(azureConnectParams.From.Ticks), new EntryPartition(azureConnectParams.Till.Ticks), null, stopEvt))
                 {
                     WriteEntry(entry.Entry, output);
                     if (stopEvt.IsCancellationRequested)
                     {
                         return;
                     }
                 }
                 ReportBackgroundActivityStatus(false);
                 return;
             }
             else if (azureConnectParams.Mode == AzureConnectionParams.LoadMode.Recent)
             {
                 ReportBackgroundActivityStatus(true);
                 var lastPartition = AzureDiagnosticsUtils.FindLastMessagePartitionKey(table, DateTime.UtcNow, stopEvt);
                 if (lastPartition.HasValue)
                 {
                     var firstPartition = new EntryPartition(lastPartition.Value.Ticks + azureConnectParams.Period.Ticks);
                     foreach (var entry in AzureDiagnosticsUtils.LoadEntriesRange(table, firstPartition, EntryPartition.MaxValue, null, stopEvt))
                     {
                         WriteEntry(entry.Entry, output);
                         stopEvt.ThrowIfCancellationRequested();
                     }
                 }
                 ReportBackgroundActivityStatus(false);
                 return;
             }
         }
         catch (OperationCanceledException e)
         {
             host.Trace.Error(e, "WAD live log thread cancelled");
         }
         catch (Exception e)
         {
             host.Trace.Error(e, "WAD live log thread failed");
         }
     }
 }