Skip to content

many: metrics option for stage durations#317

Merged
achilleas-k merged 2 commits intoosbuild:mainfrom
lzap:stats2
Nov 17, 2025
Merged

many: metrics option for stage durations#317
achilleas-k merged 2 commits intoosbuild:mainfrom
lzap:stats2

Conversation

@lzap
Copy link
Contributor

@lzap lzap commented Sep 23, 2025

This PR introduces a new statistics option for the image building stages, allowing users to get more insights into the duration of each stage.


Split out from: #303

I need to re-test, got a bunch of conflicts and I am not confident that the code is okay. Feel free to drop comments tho.

@lzap lzap marked this pull request as ready for review September 29, 2025 06:31
@lzap lzap requested a review from a team as a code owner September 29, 2025 06:31
@lzap lzap requested review from croissanne, mvo5 and thozza and removed request for a team September 29, 2025 06:31
@lzap
Copy link
Contributor Author

lzap commented Sep 29, 2025

Ready for re-reviews. This is how it looks now, I think the pipeline should probably go after the stage name, but stage name is delivered with comma already so I would need to parse it or something:

Message: Finished pipeline xz
Statistics:
	os: Finished module org.osbuild.rpm: 1m8s
	xz: Finished module org.osbuild.xz: 21s
	build: Finished module org.osbuild.rpm: 10s
	os: Finished module org.osbuild.selinux: 6s
	image: Finished module org.osbuild.copy: 3s

@thozza
Copy link
Member

thozza commented Sep 29, 2025

Ready for re-reviews. This is how it looks now, I think the pipeline should probably go after the stage name, but stage name is delivered with comma already so I would need to parse it or something:

I don't understand your idea, but having the pipeline at the beginning makes sense. Pipelines are encapsulating stages and are the higher-level component, so it makes sense to present the pipeline name before the stage name. TBH, it may make sense to present it in a tree-like view, where all stages are nested under the pipeline, rather than having an unordered list of stages from various pipelines.

Message: Finished pipeline xz
Statistics:
	os: Finished module org.osbuild.rpm: 1m8s
	xz: Finished module org.osbuild.xz: 21s
	build: Finished module org.osbuild.rpm: 10s
	os: Finished module org.osbuild.selinux: 6s
	image: Finished module org.osbuild.copy: 3s

An unfortunate thing IMHO is that the stage is called a module, but it originates from osbuild, so it is not something that the PR can address.

@mvo5
Copy link
Contributor

mvo5 commented Sep 29, 2025

[...]

An unfortunate thing IMHO is that the stage is called a module, but it originates from osbuild, so it is not something that the PR can address.

The json is based on a spec from @achilleas-k, iirc we was open for tweaks, we only use it internally so far and it would be a bit painful but probably still okay to make changes at this point (rather than later)

@lzap
Copy link
Contributor Author

lzap commented Sep 29, 2025

unordered list of stages

It is ordered by the execution time.

Let me know guys how should I continue this. As I stated already, I would like to use this same code in composer and send the data as trace logs so we can have statistics for the hosted image builder service.

@thozza
Copy link
Member

thozza commented Sep 29, 2025

unordered list of stages

It is ordered by the execution time.

Sorry, I missed that. I think that the core of the problem from my PoV is that all pipelines are mixed. If the sorting based on execution time were to stay, but the stages were grouped by pipeline name, that would be much better. I'm not sure if and how that would affect your next steps for the service.

supakeen
supakeen previously approved these changes Sep 30, 2025
Copy link
Member

@supakeen supakeen left a comment

Choose a reason for hiding this comment

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

Any presentation issues can, IMHO, be done as followups I have some ideas as well about how we could make this prettier or more useful to a command line user.

For example, totals per pipeline; in a prett(y|ier) table (or not) or exported seperately as trace data.

I could argue about the --with prefix of the argument since historically (as far as we have history) this implies that an additional file would be written into the output directory. I won't :)

@achilleas-k
Copy link
Member

Rebased for new github workflows.

@lzap
Copy link
Contributor Author

lzap commented Oct 22, 2025

Rebased, renamed the option to --with-metrics.

supakeen
supakeen previously approved these changes Oct 22, 2025
Copy link
Member

@thozza thozza left a comment

Choose a reason for hiding this comment

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

Code-wise, the PR looks good to me.

However, the last commit says many: statistics option for stage durations, while it adds --with-metrics option. Moreover, metrics and statistics are both used in different packages. It would probably make sense to use a single common name to describe the feature everywhere, unless I'm missing some good reason to use different names in different places.

@lzap
Copy link
Contributor Author

lzap commented Nov 3, 2025

Oh that is a good catch, this was a leftover from "statistics" to "metrics" renaming. I searched and replaced all of them hopefully, as well as instances in commit messages. Rebased.

supakeen
supakeen previously approved these changes Nov 3, 2025
@lzap
Copy link
Contributor Author

lzap commented Nov 11, 2025

Rebased, also renamed the remaining struct type name and the stats.go filename to metrics.go thanks.

Copy link
Member

@supakeen supakeen left a comment

Choose a reason for hiding this comment

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

Thanks :)

@supakeen supakeen changed the title many: statistics option for stage durations many: metrics option for stage durations Nov 13, 2025
@achilleas-k achilleas-k added this pull request to the merge queue Nov 17, 2025
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Nov 17, 2025
@supakeen supakeen added this pull request to the merge queue Nov 17, 2025
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Nov 17, 2025
lzap added 2 commits November 17, 2025 13:34
When something needs to be printed after the progress bar is done, it
was not possible to do so without messing up the terminal. This patch
adds a mutex around the buffer used to store output while the progress
bar is active. This allows to safely print after stopping the progress
bar.
This commit introduces a new metrics option for the image building
stages, allowing users to get more insights into the duration of each
stage.
@achilleas-k achilleas-k added this pull request to the merge queue Nov 17, 2025
Merged via the queue into osbuild:main with commit de4e4a0 Nov 17, 2025
38 checks passed
@lzap lzap deleted the stats2 branch November 18, 2025 09:05
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.

5 participants