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

Update default Go metrics #564

Merged
merged 1 commit into from
Sep 23, 2022
Merged

Conversation

SuperQ
Copy link
Contributor

@SuperQ SuperQ commented Sep 13, 2022

Closes #

πŸ’Έ TL;DR

Re-register the Go metrics collector with new baseplate defaults that include Go runtime/metrics scheduler metrics.

πŸ“œ Details

Design Doc

Jira

πŸ§ͺ Testing Steps / Validation

βœ… Checks

  • CI tests (if present) are passing
  • Adheres to code style for repo
  • Contributor License Agreement (CLA) completed if not a Reddit employee

@SuperQ SuperQ requested a review from a team as a code owner September 13, 2022 11:17
@SuperQ SuperQ requested review from fishy, kylelemons and pacejackson and removed request for a team September 13, 2022 11:17
Re-register the Go metrics collector with new baseplate defaults
that include Go `runtime/metrics` scheduler metrics.

Signed-off-by: SuperQ <[email protected]>
@SuperQ SuperQ requested review from pacejackson and removed request for fishy and kylelemons September 13, 2022 16:08
Copy link
Contributor

@pacejackson pacejackson left a comment

Choose a reason for hiding this comment

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

This looks fine to me, I would want at least one of the other approvers to sign off as well since I'm not really familiar with the metrics side of things.

@SuperQ
Copy link
Contributor Author

SuperQ commented Sep 13, 2022

Yes, somehow when I hit the "re-request review", github removed @kylelemons and @fishy. πŸ˜•

Comment on lines +38 to +39
// Unregister the default GoCollector.
prometheus.Unregister(collectors.NewGoCollector())
Copy link
Member

Choose a reason for hiding this comment

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

πŸ”• why do we have to do this :sigh:, why isn't that the default?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Because the default registry includes some default settings for Go metrics to make it easy for end users.

Customizing the default registry is a bit awkward. We could avoid this by completely eliminating use of the default registry in baseplate.go. But, that means we would need to have user switch to promauto.With(reg)....

So, we do a little bit of dance to get around it.

Copy link
Member

Choose a reason for hiding this comment

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

we are actually already using promauto.With(reg) because of f68284f

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yea, I'm not sure that was the right thing to do. :-/

"go_memstats_stack_inuse_bytes",
"go_memstats_stack_sys_bytes",
"go_memstats_sys_bytes",
"go_sched_gomaxprocs_threads",
Copy link
Member

Choose a reason for hiding this comment

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

πŸ”• this one seems to be the diff between 1.18 and 1.19?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yup, new feature in Go 1.19.

Copy link
Contributor

Choose a reason for hiding this comment

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

I think I would skip the build tags and just do

expectedMetrics := ...

if !strings.HasPrefix(runtime.Version(), "go1.18") {
  expectedMetrics = append(...)
}

Or you could use https://pkg.go.dev/golang.org/x/mod/semver if you want to be a bit more precise.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sure, I can do that.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

So, I thought about this a bit.

  • Go doesn't actually use semver, so semver.Compare() is going to be messy.
  • The build tags match Go version >=, so its a bit future-proof .

I think we need to keep this testing the way it is. (This is how upstream Prometheus client_golang does testing)

"go_memstats_stack_inuse_bytes",
"go_memstats_stack_sys_bytes",
"go_memstats_sys_bytes",
"go_sched_gomaxprocs_threads",
Copy link
Contributor

Choose a reason for hiding this comment

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

I think I would skip the build tags and just do

expectedMetrics := ...

if !strings.HasPrefix(runtime.Version(), "go1.18") {
  expectedMetrics = append(...)
}

Or you could use https://pkg.go.dev/golang.org/x/mod/semver if you want to be a bit more precise.

@SuperQ
Copy link
Contributor Author

SuperQ commented Sep 20, 2022

Should we merge this?

@kylelemons kylelemons merged commit ad5ade7 into reddit:master Sep 23, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

4 participants