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

feat: resource execution metrics #6133

Open
wants to merge 12 commits into
base: main
Choose a base branch
from
Open

Conversation

dejanzele
Copy link
Contributor

Pull request description

Add resource execution metrics

Checklist (choose whats happened)

  • breaking change! (describe)
  • tested locally
  • tested on cluster
  • added new dependencies
  • updated the docs
  • added a test

Breaking changes

Changes

Fixes

@dejanzele dejanzele requested a review from a team as a code owner January 25, 2025 09:12
@dejanzele dejanzele requested review from a team as code owners February 18, 2025 10:25
@dejanzele dejanzele force-pushed the feat/resource-exec-metrics branch 5 times, most recently from 7963828 to 86e9358 Compare February 20, 2025 10:55
@dejanzele dejanzele changed the title [WIP] feat: initial work for resource execution metrics feat: initial work for resource execution metrics Feb 21, 2025
Comment on lines 270 to 272
fmt.Printf("Actions: %v\n", state.Actions)
fmt.Printf("Step: %v\n", state.GetStep(action.Execute.Ref))

Copy link
Member

Choose a reason for hiding this comment

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

debug log

Suggested change
fmt.Printf("Actions: %v\n", state.Actions)
fmt.Printf("Step: %v\n", state.GetStep(action.Execute.Ref))

Skip: action.Execute.Toolkit,
Workflow: d.InternalConfig.Workflow.Name,
Step: step.Ref,
Execution: d.InternalConfig.Execution.Id,
Copy link
Member

Choose a reason for hiding this comment

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

Maybe be worth to consider using Resource.Id too - it will differ on parallel steps and services

if err != nil {
return errors.Wrapf(err, "failed to open file")
}
fmt.Println("Printing file content")
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
fmt.Println("Printing file content")

if err != nil {
return errors.Wrapf(err, "failed to read file")
}
fmt.Println(string(data))
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
fmt.Println(string(data))

Comment on lines 178 to 182

// Print debug info
fmt.Printf("child process: %d\n", process.Pid)
name, _ := process.Name()
fmt.Printf("child process name: %s\n", name)
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
// Print debug info
fmt.Printf("child process: %d\n", process.Pid)
name, _ := process.Name()
fmt.Printf("child process name: %s\n", name)


}

func (r *MetricRecorder) Start(ctx context.Context) {
Copy link
Member

Choose a reason for hiding this comment

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

Likely information about starting/stopping should not be printed (unless debug)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yep, all debug logs will be removed


// Skip will be set to true for internal operations like git operations, artifact scraping...
if config.Skip {
stdoutUnsafe.Println("skipping metrics recording for internal operations")
Copy link
Member

Choose a reason for hiding this comment

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

Should it print about skipping?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

removed

commands.Run(*action.Execute, currentContainer)
d := data.GetState()
recorderConfig := utilization.Config{
Dir: "./.tk/metrics",
Copy link
Member

Choose a reason for hiding this comment

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

It rather should be stored in /.tktw directory, along with other internal files (for sure not CWD)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

updated

Execution: d.InternalConfig.Execution.Id,
Format: core.FormatInflux,
}
utilization.WithMetricsRecorder(recorderConfig, func() {
Copy link
Member

Choose a reason for hiding this comment

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

I don't see the metrics output being saved as artifact - is it meant to be uploaded only when users request it specifically?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

updated to use internal artifact storage


process, err := getChildProcess()
if err != nil {
stdoutUnsafe.Errorf("failed to get process: %v", err)
Copy link
Member

Choose a reason for hiding this comment

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

Missing \n

Comment on lines 138 to 139
stdoutUnsafe.Errorf("failed to create file writer: %v", err)
stdoutUnsafe.Warn("running the provided function without metrics recorder")
Copy link
Member

Choose a reason for hiding this comment

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

Missing \ns

@dejanzele dejanzele changed the title feat: initial work for resource execution metrics feat: resource execution metrics Feb 27, 2025
@dejanzele dejanzele force-pushed the feat/resource-exec-metrics branch from d504acd to 0a2463c Compare February 27, 2025 14:18
@dejanzele dejanzele force-pushed the feat/resource-exec-metrics branch from 0a2463c to 37c1c80 Compare February 27, 2025 14:28
Signed-off-by: Dejan Zele Pejchev <pejcev.dejan@gmail.com>
@dejanzele dejanzele force-pushed the feat/resource-exec-metrics branch from 37c1c80 to 1ada3ec Compare February 28, 2025 08:26
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.

2 participants