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 metrics to follow reddit's spec #224

Merged
merged 4 commits into from
Jun 8, 2020

Conversation

pacejackson
Copy link
Contributor

No description provided.

@@ -10,7 +12,7 @@ import (

const (
success = "success"
fail = "fail"
failure = "failure"
Copy link
Member

@fishy fishy Jun 5, 2020

Choose a reason for hiding this comment

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

For easier transition, can we keep both fail and failure for a while (e.g. two weeks), then remove the wrong one (fail)?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

good call

}

func (c *atomicCounter) current() int64 {
return *c.count
Copy link
Member

Choose a reason for hiding this comment

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

this needs to be atomic.LoadInt64(c.count) instead.

)
go func() {
for {
time.Sleep(interval)
Copy link
Member

Choose a reason for hiding this comment

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

don't use time.Sleep in a for loop, use time.Tick/time.Ticker instead.

but I think this should be handled by RunSysStats function, using same prefixes and stuff (we are actually using labels for that one, and I think we should still use labels for this one as well).

hostname = "UNKOWN-HOSTNAME"
}
gauge := metrics.Gauge(
fmt.Sprintf("runtime.%s.PID%d.active_requests", hostname, os.Getpid()),
Copy link
Member

Choose a reason for hiding this comment

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

shouldn't the name be concurrency instead of active_requests?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No it's active_requests, concurrency was a mistake.


type atomicCounter struct {
count *int64
}
Copy link
Member

Choose a reason for hiding this comment

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

I also feel this is overkill/overcomplex.

That gauge, by its definition, is not per-request but only one per process. So it perfectly fine to just declare a global variable of int64, and just call atomic.AddInt64 1/-1 in the hook, and call atomic.LoadInt64 in RunSysStats to report it.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I dunno, to me directly editing a global value using the atomic functions seems like a bad example to set? I don't think this is complex at all and sets a better example for other developers reading the code.

I can change it if that's not the case.

@pacejackson
Copy link
Contributor Author

Should we also add the fmt.Sprintf("runtime.%s.PID%d.", hostname, os.Getpid()) prefix to the other RunSysStats metrics?

@pacejackson pacejackson marked this pull request as ready for review June 5, 2020 21:23
Copy link
Member

@fishy fishy left a comment

Choose a reason for hiding this comment

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

The build file needs to be sorted alphabetically :) https://cloud.drone.io/reddit/baseplate.go/1198/2/3

@@ -24,45 +28,49 @@ func pullRuntimeStats() (cpu cpuStats, mem runtime.MemStats) {
// RunSysStats starts a goroutine to periodically pull and report sys stats.
//
// Canceling the context passed into NewStatsd will stop this goroutine.
func (st *Statsd) RunSysStats(labels Labels) {
func (st *Statsd) RunSysStats(_ Tags) {
Copy link
Member

Choose a reason for hiding this comment

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

Oh I thought it was part of a config struct so I said leave it but ignore it to keep backward compatibility. Since this is a function arg, doing that is kinda defeating the point and we can just remove it. Also this is already a breaking change :)

@pacejackson pacejackson merged commit b78f1bd into reddit:master Jun 8, 2020
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.

3 participants