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

Start moving components of adaptive sampling to OSS #973

Merged
merged 7 commits into from
Nov 13, 2018

Conversation

black-adder
Copy link
Contributor

@black-adder black-adder commented Aug 7, 2018

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.

@codecov
Copy link

codecov bot commented Aug 7, 2018

Codecov Report

❗ No coverage uploaded for pull request base (master@c296998). Click here to learn what that means.
The diff coverage is 100%.

Impacted file tree graph

@@           Coverage Diff           @@
##             master   #973   +/-   ##
=======================================
  Coverage          ?   100%           
=======================================
  Files             ?    157           
  Lines             ?   7101           
  Branches          ?      0           
=======================================
  Hits              ?   7101           
  Misses            ?      0           
  Partials          ?      0
Impacted Files Coverage Δ
...sampling/internal/calculationstrategy/interface.go 100% <100%> (ø)
pkg/testutils/logger.go 100% <100%> (ø)
...nstrategy/percentage_increase_capped_calculator.go 100% <100%> (ø)
...ampling/internal/leaderelection/leader_election.go 100% <100%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update c296998...5f52d42. Read the comment docs.

@@ -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 {
Copy link
Member

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.

Copy link
Member

Choose a reason for hiding this comment

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

ping

Copy link
Contributor Author

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.
Copy link
Member

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)
Copy link
Member

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.
Copy link
Member

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()
Copy link
Member

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.

}

// Calculate wraps a function of appropriate signature and makes a ProbabilityCalculator from it.
type Calculate func(targetQPS, curQPS, prevProbability float64) (newProbability float64)
Copy link
Member

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

@@ -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 {
Copy link
Member

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.
Copy link
Member

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.

Copy link
Contributor Author

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

Copy link
Contributor Author

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"
Copy link
Member

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 <[email protected]>
Signed-off-by: Won Jun Jang <[email protected]>
Signed-off-by: Won Jun Jang <[email protected]>
Signed-off-by: Won Jun Jang <[email protected]>
Signed-off-by: Won Jun Jang <[email protected]>
Signed-off-by: Won Jun Jang <[email protected]>
@black-adder black-adder force-pushed the move_adaptive_sampling_over branch from 807668d to fcaf701 Compare November 13, 2018 18:01
Signed-off-by: Won Jun Jang <[email protected]>
@black-adder black-adder force-pushed the move_adaptive_sampling_over branch from fcaf701 to 5f52d42 Compare November 13, 2018 18:13
@black-adder black-adder merged commit 4cc25e6 into master Nov 13, 2018
@ghost ghost removed the review label Nov 13, 2018
@pavolloffay pavolloffay deleted the move_adaptive_sampling_over branch November 13, 2018 20:57
@yurishkuro yurishkuro mentioned this pull request Apr 7, 2019
3 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants