Skip to content

Rework metrics to use metrics crate #361

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

Merged
merged 4 commits into from
Apr 17, 2025

Conversation

ludfjig
Copy link
Contributor

@ludfjig ludfjig commented Mar 15, 2025

This simplifies metrics a lot by using the metrics crate. The metrics crate functions similar to the log crate in that libraries just call counter!, gauge! or histogram! to record metrics, and the user of the library can decide where to send the metrics by installing an appropriate recorder/exporter. If no exporter is installed, the overhead to call the macros are minimal.

NEW: got rid of the "nice" apis previously suggested, and now uses the metrics' crates macros directly. Hyperlight-wasm can easily do the same.

@ludfjig ludfjig marked this pull request as draft March 15, 2025 04:04
@ludfjig ludfjig changed the title Rework metrics to use metrics crate [draft] Rework metrics to use metrics crate Mar 15, 2025
@ludfjig ludfjig added kind/enhancement For PRs adding features, improving functionality, docs, tests, etc. kind/bugfix For PRs that fix bugs kind/refactor For PRs that restructure or remove code without adding new functionality. kind/dependencies For PRs that update dependencies or related components and removed kind/bugfix For PRs that fix bugs kind/enhancement For PRs adding features, improving functionality, docs, tests, etc. kind/refactor For PRs that restructure or remove code without adding new functionality. kind/dependencies For PRs that update dependencies or related components labels Mar 17, 2025
@ludfjig ludfjig added the kind/enhancement For PRs adding features, improving functionality, docs, tests, etc. label Mar 18, 2025
@ludfjig ludfjig force-pushed the simplify_metrics branch 7 times, most recently from f523fdb to 411b9f6 Compare April 15, 2025 19:02
@ludfjig ludfjig marked this pull request as ready for review April 15, 2025 20:11
@ludfjig ludfjig changed the title [draft] Rework metrics to use metrics crate Rework metrics to use metrics crate Apr 15, 2025
Copy link
Contributor

@simongdavies simongdavies left a comment

Choose a reason for hiding this comment

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

A couple of general questions:

Did we get rid of Gauges? There was a use of them previously and if I am not mistaken somewhere we have an issue that asks for a running total of memory in use, in addition the intent was that these could be used by things built on top of hyperlight such as hyperlight-wasm (we should maintain consistency in the way metrics are collected and emitted between hyperlight and crates built on top)

I may have commented on this in the code review but I dont see how a crate such as hyperlight-wasm would be able to use the metrics structs and macros?

@ludfjig ludfjig force-pushed the simplify_metrics branch 2 times, most recently from 0b50f7a to 704a954 Compare April 16, 2025 22:02
@ludfjig ludfjig force-pushed the simplify_metrics branch 2 times, most recently from b5f1cf5 to f4e48cc Compare April 16, 2025 22:56
ludfjig added 3 commits April 16, 2025 15:59
Signed-off-by: Ludvig Liljenberg <[email protected]>
Signed-off-by: Ludvig Liljenberg <[email protected]>
@ludfjig
Copy link
Contributor Author

ludfjig commented Apr 16, 2025

I totally changed the direction of this PR. We now simply use the macros directly where we want to emit metrics. I dont think we need any further abstractions @simongdavies

danbugs
danbugs previously approved these changes Apr 17, 2025
Copy link
Contributor

@danbugs danbugs left a comment

Choose a reason for hiding this comment

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

LGTM

Signed-off-by: Ludvig Liljenberg <[email protected]>
@ludfjig ludfjig merged commit 8df033a into hyperlight-dev:main Apr 17, 2025
24 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/enhancement For PRs adding features, improving functionality, docs, tests, etc.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants