Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move JobTelemetry and StepsTelemetry into GlobalContext. #1680

Merged
merged 3 commits into from
Feb 11, 2022

Conversation

TingluoHuang
Copy link
Member

@TingluoHuang TingluoHuang commented Feb 11, 2022

We introduced GlobalContext to ExecutionContext for holding shared objects of all ExecutionContext (Job + Steps).

Both ActionsStepsTelemetry and JobTelemetry fail into this shared objects category, so I am moving both into the GlobalContext.

Moving forward, you will not need to worry about which context (job vs. step) to use in order to get the right object.

image

@TingluoHuang TingluoHuang requested a review from a team as a code owner February 11, 2022 04:04
@@ -52,8 +52,7 @@ public interface IExecutionContext : IRunnerService
Dictionary<string, string> IntraActionState { get; }
Dictionary<string, VariableValue> JobOutputs { get; }
ActionsEnvironmentReference ActionsEnvironment { get; }
List<ActionsStepTelemetry> ActionsStepsTelemetry { get; }
List<JobTelemetry> JobTelemetry { get; }
ActionsStepTelemetry StepTelemetry { get; }
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Each ExecutionContext will hold a single ActionsStepTelemetry object, the object will get append to the GlobalContext.ActionsStepsTelemetry when ExecutionContext.Complete() is called.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For composite child steps we don't call complete() so I don't think you will be getting that data currently

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks for pointing this out, i will take a look.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like we only call .Complete() in one place under composite action.
https://github.com/actions/runner/blob/main/src/Runner.Worker/Handlers/CompositeActionHandler.cs#L296

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am adding a new PublishStepTelemetry() to executionContext, so composite actions can use that to publish step telemetry.


var jobCompletedEvent = new JobCompletedEvent(message.RequestId, message.JobId, result, jobContext.JobOutputs, jobContext.ActionsEnvironment, jobContext.Global.StepsTelemetry, jobContext.Global.JobTelemetry);
Trace.Info($"Raising job completed event: {StringUtil.ConvertToJson(jobCompletedEvent)}");
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

revert the trace after testing...

@@ -150,6 +118,40 @@ public override void Initialize(IHostContext hostContext)
ActionCommandManager = hostContext.CreateService<IActionCommandManager>();
}

protected string GetActionRef()
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this method is only get moved down and changed from public virtual to protected

Copy link
Collaborator

@thboop thboop left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@TingluoHuang TingluoHuang merged commit cb19da9 into main Feb 11, 2022
@TingluoHuang TingluoHuang deleted the users/tihuang/movethingsaround branch February 11, 2022 21:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants