Skip to content

Commit

Permalink
Make embedded timeline record has same order as its parent record. (a…
Browse files Browse the repository at this point in the history
  • Loading branch information
TingluoHuang authored Jan 26, 2024
1 parent 7310ba0 commit b7ab810
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions src/Runner.Worker/ExecutionContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -397,11 +397,11 @@ public IExecutionContext CreateChild(

if (recordOrder != null)
{
child.InitializeTimelineRecord(_mainTimelineId, recordId, _record.Id, ExecutionContextType.Task, displayName, refName, recordOrder);
child.InitializeTimelineRecord(_mainTimelineId, recordId, _record.Id, ExecutionContextType.Task, displayName, refName, recordOrder, embedded: isEmbedded);
}
else
{
child.InitializeTimelineRecord(_mainTimelineId, recordId, _record.Id, ExecutionContextType.Task, displayName, refName, ++_childTimelineRecordOrder);
child.InitializeTimelineRecord(_mainTimelineId, recordId, _record.Id, ExecutionContextType.Task, displayName, refName, ++_childTimelineRecordOrder, embedded: isEmbedded);
}
if (logger != null)
{
Expand Down Expand Up @@ -432,7 +432,7 @@ public IExecutionContext CreateEmbeddedChild(
Dictionary<string, string> intraActionState = null,
string siblingScopeName = null)
{
return Root.CreateChild(_record.Id, _record.Name, _record.Id.ToString("N"), scopeName, contextName, stage, logger: _logger, isEmbedded: true, cancellationTokenSource: null, intraActionState: intraActionState, embeddedId: embeddedId, siblingScopeName: siblingScopeName, timeout: GetRemainingTimeout());
return Root.CreateChild(_record.Id, _record.Name, _record.Id.ToString("N"), scopeName, contextName, stage, logger: _logger, isEmbedded: true, cancellationTokenSource: null, intraActionState: intraActionState, embeddedId: embeddedId, siblingScopeName: siblingScopeName, timeout: GetRemainingTimeout(), recordOrder: _record.Order);
}

public void Start(string currentOperation = null)
Expand Down Expand Up @@ -1160,7 +1160,7 @@ public void WriteWebhookPayload()
}
}

private void InitializeTimelineRecord(Guid timelineId, Guid timelineRecordId, Guid? parentTimelineRecordId, string recordType, string displayName, string refName, int? order)
private void InitializeTimelineRecord(Guid timelineId, Guid timelineRecordId, Guid? parentTimelineRecordId, string recordType, string displayName, string refName, int? order, bool embedded = false)
{
_mainTimelineId = timelineId;
_record.Id = timelineRecordId;
Expand All @@ -1186,7 +1186,11 @@ private void InitializeTimelineRecord(Guid timelineId, Guid timelineRecordId, Gu
var configuration = HostContext.GetService<IConfigurationStore>();
_record.WorkerName = configuration.GetSettings().AgentName;

_jobServerQueue.QueueTimelineRecordUpdate(_mainTimelineId, _record);
// We don't want to update the timeline record for embedded steps since they are not really represented in the UI.
if (!embedded)
{
_jobServerQueue.QueueTimelineRecordUpdate(_mainTimelineId, _record);
}
}

private void JobServerQueueThrottling_EventReceived(object sender, ThrottlingEventArgs data)
Expand Down

0 comments on commit b7ab810

Please sign in to comment.