-
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
Remove stats.New
#2442
Remove stats.New
#2442
Conversation
d701440
to
c029ecb
Compare
c029ecb
to
6d90d23
Compare
3b9c4c4
to
a69cc06
Compare
750b46d
to
83d73fc
Compare
Rebased this on #2426. This now depends on said PR. A notable change made is that we now use the The failing tests are inherited from #2426 and the PR should be green once those issues are addressed in said PR. |
591a0fe
to
f06d6f0
Compare
83d73fc
to
393d188
Compare
393d188
to
f168a73
Compare
58fca82
to
8276246
Compare
f168a73
to
2673d98
Compare
This commit drops the dependency on `stats.New`, in favor of `metrics.Registry.NewMetric`, which is considered the canonical way of creating metrics.
if len(t) > 0 { | ||
vt = t[0] | ||
// newMetric instantiates a new Metric | ||
func newMetric(name string, mt MetricType, vt ...ValueType) *Metric { |
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 guessing this will get deleted when things are moved to metrics/
?
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 ended up keeping it around, but private to, and only used in, the metrics
package; as a helper. See #2442 (comment) for more details :)
2673d98
to
f75251f
Compare
This is a fix for a breaking change introduced in k6 v0.38.0[1]. [1]: grafana/k6#2442
This PR removes the
stats.New
method from thestats
package. This change is intended to facilitate the move of thestats
package code in a top-levelmetrics
code. It was triggered and requested, as preparation step to #2433 and #2426.Note that this PR might be taking certain shortcut, assuming the API will be readjusted later by the mentioned PRs.
Question marks
I took the initiative to use the
registry.NewMetric
in places wherestats.New
used to be. I could see two main alternatives:registry.MustNewMetric
, but considering we userequire.NoError
everywhere else, I pickedregistry.NewMetric
insteadMetric
instances “manually” everywhere it's possible. However, considering we want to explicit that metrics should be created through a registry, I judged it more relevant.Dependencies
This should be merged before #2433 and #2426