-
Notifications
You must be signed in to change notification settings - Fork 291
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
[Do not merge]Consume latest tally #334
Conversation
@alsamylkin, thanks for your PR! By analyzing the history of the files in this pull request, we identified @sectioneight, @madhuravi and @glibsm to be potential reviewers. |
1 similar comment
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.
lgtm, would like a once-over from @glibsm or somebody else familiar with our tally stuff
metrics/nop_reporter.go
Outdated
@@ -99,3 +103,30 @@ type nopCachedTimer struct { | |||
|
|||
func (nopCachedTimer) ReportTimer(interval time.Duration) { | |||
} | |||
|
|||
// NopCachedHistogram is an implementation of tally.CachedHistogram |
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.
maybe mention this is exported for testing?
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.
Should we do this everywhere in this file? I'd prefer that, but not sure, if it will confuse reviewers.
metrics/nop_reporter.go
Outdated
// NopCachedHistogram is an implementation of tally.CachedHistogram | ||
var NopCachedHistogram tally.CachedHistogram = nopCachedHistogram{} | ||
|
||
type nopCachedHistogram struct { |
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.
style nit: empty struct on a single line generally, right? or are we doing differerently:
type nopCachedHistogram struct{}
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.
Well, I was following the leader(couple lines above) :)
metrics/nop_reporter.go
Outdated
} | ||
|
||
func (nopCachedHistogram) ValueBucket( | ||
bucketLowerBound, bucketUpperBound float64, |
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.
style nit: inconsistent oneline versus multiline. we may need a style guide :|
i thought we either did:
func foo(lotsAndLots, ofArgumentsHere ofThisType) {
or
func foo(
lotsAndLots,
ofArguments ofThisType,
)
but maybe i'm misremembering
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.
They have the same type, but sure.
@@ -62,6 +62,10 @@ func (nopCachedStatsReporter) AllocateGauge(name string, tags map[string]string) | |||
return NopCachedGauge | |||
} | |||
|
|||
func (nopCachedStatsReporter) AllocateHistogram(name string, tags map[string]string, buckets tally.Buckets) tally.CachedHistogram { |
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.
how come this one doesn't get godoc comments but the other one you added does?
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.
nopCachedStatsReporter is the internal type.
service/service_test.go
Outdated
@@ -38,7 +38,16 @@ import ( | |||
func TestServiceCreation(t *testing.T) { | |||
r := metrics.NewTestStatsReporter() | |||
r.CountersWG.Add(1) | |||
scope, closer := tally.NewRootScope("", nil, r, 50*time.Millisecond, tally.DefaultSeparator) | |||
opts := tally.ScopeOptions{ | |||
Tags: nil, |
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.
why the explicit nil/empty string stuff here? i think i actually like it, but generally see it elided as:
opts := tally.ScopeOptions {
Reporter: r,
Separator: ...,
DefaultBuckets: ...,
}
for brevity. thoughts?
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.
Well, I was afraid linter would complain, because, we can extend a struct and forget some mandatory fields. But it didn't. Let's get dangerous.
testutils/metrics/metrics.go
Outdated
DefaultBuckets: tally.DefaultBuckets, | ||
} | ||
|
||
scope, _ := tally.NewRootScope(opts, 100*time.Millisecond) |
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.
unrelated to this change, but what is this magic number for?
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.
It is the reporting interval, how often we are going to sample metrics.
Counters map[string]int64 | ||
Gauges map[string]float64 | ||
Timers map[string]time.Duration | ||
HistogramSamples map[string]tally.Buckets |
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.
Has this been implemented internally? If not we cannot use it until the internal implementation support these APIs.
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.
Why? Nop implementations doesn't have to do anything.
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.
This is needed only to implement interfaces.
The way service is using it is in service_setup.go, where options became a separate struct.
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 meant for Tally 2.0 CachedStatsReporter
. We don't have its implementation here, but we rely on internal implementation from our private repo.
metrics/nop_reporter.go
Outdated
|
||
func (nopCachedHistogram) ValueBucket( | ||
bucketLowerBound, bucketUpperBound float64, | ||
bucketLowerBound float64, |
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.
note: i wasn't suggesting repeating the type, just putting each param on its own line or having them all on one line, not some mix-and-match
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 know, personally, it is easier to read. Really wish go fmt will help with these things :)
Looks good. What Anup said about internal implementation changes applies. As soon as this lands, m3 backend will be broken. |
fb2ffe2
to
d303ea8
Compare
merging since we have all the necessary components ready. |
Tally introduced histograms to their interfaces and changed constructor for a scope, which requires us to implement it for NopReported and update some tests.
Will not merge, until migrate internal tools to the new tally version.