-
Notifications
You must be signed in to change notification settings - Fork 1k
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
Changes from 2 commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,13 @@ | ||
using GitHub.DistributedTask.WebApi; | ||
using GitHub.Runner.Common.Util; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Threading.Tasks; | ||
using System.Linq; | ||
using System.IO; | ||
using Pipelines = GitHub.DistributedTask.Pipelines; | ||
using System.Linq; | ||
using System.Threading.Tasks; | ||
using GitHub.DistributedTask.WebApi; | ||
using GitHub.Runner.Common; | ||
using GitHub.Runner.Common.Util; | ||
using GitHub.Runner.Sdk; | ||
using Pipelines = GitHub.DistributedTask.Pipelines; | ||
|
||
namespace GitHub.Runner.Worker.Handlers | ||
{ | ||
|
@@ -44,42 +44,10 @@ public abstract class Handler : RunnerService | |
public string ActionDirectory { get; set; } | ||
public List<JobExtensionRunner> LocalActionContainerSetupSteps { get; set; } | ||
|
||
public virtual string GetActionRef() | ||
{ | ||
if (Action.Type == Pipelines.ActionSourceType.ContainerRegistry) | ||
{ | ||
var registryAction = Action as Pipelines.ContainerRegistryReference; | ||
return registryAction.Image; | ||
} | ||
else if (Action.Type == Pipelines.ActionSourceType.Repository) | ||
{ | ||
var repoAction = Action as Pipelines.RepositoryPathReference; | ||
if (string.Equals(repoAction.RepositoryType, Pipelines.PipelineConstants.SelfAlias, StringComparison.OrdinalIgnoreCase)) | ||
{ | ||
return repoAction.Path; | ||
} | ||
else | ||
{ | ||
if (string.IsNullOrEmpty(repoAction.Path)) | ||
{ | ||
return $"{repoAction.Name}@{repoAction.Ref}"; | ||
} | ||
else | ||
{ | ||
return $"{repoAction.Name}/{repoAction.Path}@{repoAction.Ref}"; | ||
} | ||
} | ||
} | ||
else | ||
{ | ||
// this should never happen | ||
Trace.Error($"Can't generate ref for {Action.Type.ToString()}"); | ||
} | ||
return ""; | ||
} | ||
|
||
public virtual void PrintActionDetails(ActionRunStage stage) | ||
{ | ||
|
||
if (stage == ActionRunStage.Post) | ||
{ | ||
ExecutionContext.Output($"Post job cleanup."); | ||
|
@@ -150,6 +118,40 @@ public override void Initialize(IHostContext hostContext) | |
ActionCommandManager = hostContext.CreateService<IActionCommandManager>(); | ||
} | ||
|
||
protected string GetActionRef() | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this method is only get moved down and changed from |
||
{ | ||
if (Action.Type == Pipelines.ActionSourceType.ContainerRegistry) | ||
{ | ||
var registryAction = Action as Pipelines.ContainerRegistryReference; | ||
return registryAction.Image; | ||
} | ||
else if (Action.Type == Pipelines.ActionSourceType.Repository) | ||
{ | ||
var repoAction = Action as Pipelines.RepositoryPathReference; | ||
if (string.Equals(repoAction.RepositoryType, Pipelines.PipelineConstants.SelfAlias, StringComparison.OrdinalIgnoreCase)) | ||
{ | ||
return repoAction.Path; | ||
} | ||
else | ||
{ | ||
if (string.IsNullOrEmpty(repoAction.Path)) | ||
{ | ||
return $"{repoAction.Name}@{repoAction.Ref}"; | ||
} | ||
else | ||
{ | ||
return $"{repoAction.Name}/{repoAction.Path}@{repoAction.Ref}"; | ||
} | ||
} | ||
} | ||
else | ||
{ | ||
// this should never happen | ||
Trace.Error($"Can't generate ref for {Action.Type.ToString()}"); | ||
} | ||
return ""; | ||
} | ||
|
||
protected void AddInputsToEnvironment() | ||
{ | ||
// Validate args. | ||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
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 singleActionsStepTelemetry
object, the object will get append to theGlobalContext.ActionsStepsTelemetry
whenExecutionContext.Complete()
is called.There was a problem hiding this comment.
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 currentlyThere was a problem hiding this comment.
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.
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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.