Skip to content

Commit 0dad653

Browse files
sophiatevSophia Tevosyan
andauthored
Added a "LatestEvents" field to the FetchedInstanceHistory log (#1373)
* added the LastEvents field * removed unnecessary usings * updated the log event version --------- Co-authored-by: Sophia Tevosyan <stevosyan@microsoft.com>
1 parent 7448bac commit 0dad653

4 files changed

Lines changed: 18 additions & 7 deletions

File tree

src/DurableTask.AzureStorage/AnalyticsEventSource.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -306,7 +306,7 @@ public void PoisonMessageDetected(
306306
ExtensionVersion);
307307
}
308308

309-
[Event(EventIds.FetchedInstanceHistory, Level = EventLevel.Informational, Version = 4)]
309+
[Event(EventIds.FetchedInstanceHistory, Level = EventLevel.Informational, Version = 5)]
310310
public void FetchedInstanceHistory(
311311
string Account,
312312
string TaskHub,
@@ -318,6 +318,7 @@ public void FetchedInstanceHistory(
318318
long LatencyMs,
319319
string ETag,
320320
DateTime LastCheckpointTime,
321+
string LatestEvents,
321322
string AppName,
322323
string ExtensionVersion)
323324
{
@@ -333,6 +334,7 @@ public void FetchedInstanceHistory(
333334
LatencyMs,
334335
ETag ?? string.Empty,
335336
LastCheckpointTime,
337+
LatestEvents,
336338
AppName,
337339
ExtensionVersion);
338340
}

src/DurableTask.AzureStorage/Logging/LogEvents.cs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -745,7 +745,8 @@ public FetchedInstanceHistory(
745745
int requestCount,
746746
long latencyMs,
747747
string eTag,
748-
DateTime lastCheckpointTime)
748+
DateTime lastCheckpointTime,
749+
string latestEvents)
749750
{
750751
this.Account = account;
751752
this.TaskHub = taskHub;
@@ -757,6 +758,7 @@ public FetchedInstanceHistory(
757758
this.LatencyMs = latencyMs;
758759
this.ETag = eTag;
759760
this.LastCheckpointTime = lastCheckpointTime;
761+
this.LatestEvents = latestEvents;
760762
}
761763

762764
[StructuredLogField]
@@ -789,6 +791,9 @@ public FetchedInstanceHistory(
789791
[StructuredLogField]
790792
public DateTime LastCheckpointTime { get; }
791793

794+
[StructuredLogField]
795+
public string LatestEvents { get; }
796+
792797
public override EventId EventId => new EventId(
793798
EventIds.FetchedInstanceHistory,
794799
nameof(EventIds.FetchedInstanceHistory));
@@ -811,6 +816,7 @@ void IEventSourceEvent.WriteEventSource() => AnalyticsEventSource.Log.FetchedIns
811816
this.LatencyMs,
812817
this.ETag,
813818
this.LastCheckpointTime,
819+
this.LatestEvents,
814820
Utils.AppName,
815821
Utils.ExtensionVersion);
816822
}

src/DurableTask.AzureStorage/Logging/LogHelper.cs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -261,7 +261,8 @@ internal void FetchedInstanceHistory(
261261
int requestCount,
262262
long latencyMs,
263263
string eTag,
264-
DateTime lastCheckpointTime)
264+
DateTime lastCheckpointTime,
265+
string latestEvents)
265266
{
266267
var logEvent = new LogEvents.FetchedInstanceHistory(
267268
account,
@@ -273,7 +274,8 @@ internal void FetchedInstanceHistory(
273274
requestCount,
274275
latencyMs,
275276
eTag,
276-
lastCheckpointTime);
277+
lastCheckpointTime,
278+
latestEvents);
277279
this.WriteStructuredLog(logEvent);
278280
}
279281

src/DurableTask.AzureStorage/Tracking/AzureTableTrackingStore.cs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
namespace DurableTask.AzureStorage.Tracking
1515
{
1616
using System;
17-
using System.Collections.Concurrent;
1817
using System.Collections.Generic;
1918
using System.Diagnostics;
2019
using System.Linq;
@@ -226,7 +225,8 @@ public override async Task<OrchestrationHistory> GetHistoryEventsAsync(string in
226225
results.RequestCount,
227226
results.ElapsedMilliseconds,
228227
eTagValue?.ToString(),
229-
checkpointCompletionTime);
228+
checkpointCompletionTime,
229+
string.Join(",", historyEvents.Skip(Math.Max(0, historyEvents.Count - 10)).Select(e => e.EventType.ToString())));
230230

231231
return new OrchestrationHistory(historyEvents, checkpointCompletionTime, eTagValue, trackingStoreContext);
232232
}
@@ -264,7 +264,8 @@ async Task<IReadOnlyList<TableEntity>> QueryHistoryAsync(string filter, string i
264264
results.RequestCount,
265265
results.ElapsedMilliseconds,
266266
eTag: string.Empty,
267-
DateTime.MinValue);
267+
DateTime.MinValue,
268+
string.Join(",", entities.Skip(Math.Max(0, entities.Count - 10)).Select(e => e.GetString(nameof(HistoryEvent.EventType)))));
268269

269270
return entities;
270271
}

0 commit comments

Comments
 (0)