-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Expose runtime Go metrics #3535
Conversation
api/server.go
Outdated
@@ -42,6 +43,7 @@ func injectProfilerHandler(mux *http.ServeMux, profilingEnabled bool) { | |||
} | |||
|
|||
mux.Handle("/debug/pprof/", handler) | |||
mux.Handle("/metrics", promhttp.Handler()) |
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 have reused the --profiling-enabled
flag, but I'm also happy with any other, separate, suggestion.
My rationale is that the potential user or use case for both probably overlaps most of the cases, like trying to understand how k6 behaves in terms of resource utilization, etc.
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 actually like that the feature lives behind --profiling-enabled
👍🏻 🙇🏻
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #3535 +/- ##
==========================================
- Coverage 73.07% 73.03% -0.05%
==========================================
Files 281 279 -2
Lines 21102 21098 -4
==========================================
- Hits 15421 15408 -13
- Misses 4705 4710 +5
- Partials 976 980 +4
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
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 good to me, thanks a lot for acting on this, much appreciated 🙇🏻 🚀
This is currently through due to us having an experimental prometheus remote-write output. But it is not certain it will stay or will we move fully to oTEL as such I would argue at some point it won't be free at all. I also really do prefer to just use stdlib options where possible and golang does have expvar and (after some unsuccesful tries)
Seems to does the job. |
TBH, I'm not sure about the usability of expvar compared to promhttp, nor what will be "the new standard" in the near/mid future, but I agree that, considering this has been there for a year without much claim, it's better to start simple and avoid adding new dependencies, if we have an alternative way to expose such data in case we need them for profiling/debugging. So, I replaced |
What?
It exposes the
/metrics
endpoint when--profiling-enabled
, with the Go runtime metrics from https://github.com/prometheus/client_golang.Why?
As stated in #2955, these metrics can be critical to spot problems and further optimize scripts, extensions, and k6 core. It comes almost by free (as part of
github.com/prometheus/client_golang
is already an -indirect- dependency of the project), and in the future we could even introduce our own custom metrics, like the amount of VUs, ongoing HTTP requests, etc.Checklist
make lint
) and all checks pass.make tests
) and all tests pass.Related PR(s)/Issue(s)
Closes #2955