-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
Start moving components of adaptive sampling to OSS #973
Conversation
Codecov Report
@@ Coverage Diff @@
## master #973 +/- ##
=======================================
Coverage ? 100%
=======================================
Files ? 157
Lines ? 7101
Branches ? 0
=======================================
Hits ? 7101
Misses ? 0
Partials ? 0
Continue to review full report at Codecov.
|
pkg/testutils/logger.go
Outdated
@@ -88,3 +89,17 @@ func (b *Buffer) Write(p []byte) (int, error) { | |||
defer b.Unlock() | |||
return b.Buffer.Write(p) | |||
} | |||
|
|||
// LogMatcher is a helper func that returns true if the subStr appears more than 'occurrences' times in the logs. | |||
var LogMatcher = func(occurrences int, subStr string, logs []string) bool { |
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.
(non-blocking) nit: not a fun of such function since the way you would use it is with assert.True()
, which provides no feedback in case of mismatch. I prefer passing the T object and doing asserts directly.
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.
ping
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.
passing in T makes this hard to test since if we try to test the failure case, the test itself will fail (unless I can mock T which seems overkill). I'll update this func to return (bool, errMsg)
@@ -0,0 +1,28 @@ | |||
// Copyright (c) 2018 The Jaeger Authors. |
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 is this under strategystore
?
} | ||
|
||
// Func wraps a function of appropriate signature and makes a ProbabilityCalculator from it. | ||
type Func func(targetQPS, curQPS, prevProbability float64) (newProbability 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.
Do you envision ever having other methods in the interface? Consider:
type Calculate func(targetQPS, curQPS, prevProbability float64) (newProbability float64)
@@ -0,0 +1,117 @@ | |||
// Copyright (c) 2018 The Jaeger Authors. |
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.
again, weird package path. Too long on one hand, while .../internal/leader_election/*.go
would make more sense than being directly in 'internal'.
// ElectionParticipant partakes in leader election to become leader. | ||
type ElectionParticipant interface { | ||
IsLeader() bool | ||
Start() |
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 not sure Start() semantically belongs in this interface.
c05121d
to
a3eb125
Compare
a3eb125
to
41ec3ba
Compare
} | ||
|
||
// Calculate wraps a function of appropriate signature and makes a ProbabilityCalculator from it. | ||
type Calculate func(targetQPS, curQPS, prevProbability float64) (newProbability 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.
std lib calls this XyzFunc
pkg/testutils/logger.go
Outdated
@@ -88,3 +89,17 @@ func (b *Buffer) Write(p []byte) (int, error) { | |||
defer b.Unlock() | |||
return b.Buffer.Write(p) | |||
} | |||
|
|||
// LogMatcher is a helper func that returns true if the subStr appears more than 'occurrences' times in the logs. | |||
var LogMatcher = func(occurrences int, subStr string, logs []string) bool { |
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.
ping
@@ -0,0 +1,28 @@ | |||
// Copyright (c) 2018 The Jaeger Authors. |
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.
what is the thinking for this thing to be under plugins
? I can see swappable storage to be under plugins, but this seems like the core impl. I would keep it inside the collector app.
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 core only to the adaptive sampling strategystore. Don't feel the collector app is the right place for this
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.
gonna go ahead and land, we can figure out where these files should live later
) | ||
|
||
var ( | ||
acquireLockErrMsg = "Failed to acquire lock" |
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's a const
Signed-off-by: Won Jun Jang <wjang@uber.com>
Signed-off-by: Won Jun Jang <wjang@uber.com>
Signed-off-by: Won Jun Jang <wjang@uber.com>
Signed-off-by: Won Jun Jang <wjang@uber.com>
Signed-off-by: Won Jun Jang <wjang@uber.com>
807668d
to
fcaf701
Compare
Signed-off-by: Won Jun Jang <wjang@uber.com>
fcaf701
to
5f52d42
Compare
Which problem is this PR solving?
This PR is the start of moving adaptive sampling (#365) over to OSS. This is moving over calculation_strategy and leader_election code.