Skip to content

Add sampling handler and sampling strategy store #674

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

Merged
merged 6 commits into from
Feb 28, 2018

Conversation

black-adder
Copy link
Contributor

@black-adder black-adder commented Feb 2, 2018

This adds a tchannel sampling handler and a static sampling strategy store that reads sampling strategies from a json file.

I added a factory for this so that when we move adaptive sampling over to open source, we can easily extend the existing factory with adaptive sampling and all its flags (I've counted 15 flags at the time of writing).

Locations of files might be up for debate (should this belong in pkg and plugin?)
Do I even need a separate sampling strategy store? should I just use the sampling handler interface and have a factory for that?

Fixes #661

Signed-off-by: Won Jun Jang [email protected]

@ghost ghost assigned black-adder Feb 2, 2018
@ghost ghost added the review label Feb 2, 2018
)

const (
samplingStrategies = "sampling.strategies"
Copy link
Member

Choose a reason for hiding this comment

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

I would prefer a bit more explicit name "sampling.strategies-file"

return h.defaultStrategy, nil
}

// TODO good candidate for a global util function
Copy link
Member

Choose a reason for hiding this comment

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

how much overlap is in this code with what the client is doing when parsing JSON response from the agent? Maybe we can combine that all into jaeger-lib?

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 TODO was originally meant for creating a util function for reading a json file and unmarshalling it. I didn't have as lofty goal of moving the client and this logic into jaeger-lib. I don't think it's similar enough to warrant that.

@pavolloffay
Copy link
Member

@black-adder does this fix #661?

Signed-off-by: Won Jun Jang <[email protected]>
Signed-off-by: Won Jun Jang <[email protected]>
@coveralls
Copy link

coveralls commented Feb 27, 2018

Coverage Status

Coverage remained the same at 100.0% when pulling f5268ed on add_sampling_handler into b61b7ec on master.

@@ -0,0 +1,44 @@
// 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.

yes, the pkg is rather suspicious for this. It is meant for things not directly related to Jaeger. The simplest approach would be to define the storage interface in cmd/collector/sampling/strategystore/interface.go

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done, should I have the static/adaptive implementations in plugin or should I move the whole thing over to cmd/collector/app?

//
// See also
//
// plugin.Configurable
Copy link
Member

Choose a reason for hiding this comment

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

Configurable also has AddFlags(flagSet *flag.FlagSet). Do you actually need to require Configurable methods in the Factory interface?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It doesn't have to be but it makes life easier.

"github.com/jaegertracing/jaeger/thrift-gen/sampling"
)

const (
Copy link
Member

Choose a reason for hiding this comment

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

is this needed in the "interface" package? Could it not be placed in the static impl?


// Strategy defines a sampling strategy. Type can be "probabilistic" or "ratelimiting"
// and Param will represent "sampling probability" and "max traces per second" respectively.
type Strategy struct {
Copy link
Member

Choose a reason for hiding this comment

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

these types look like private intermediate model used by static impl. Or did you mean the StrategyStorage interface to return these?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

made private

// FactoryConfigFromEnv reads the desired sampling type from the SAMPLING_TYPE environment variable. Allowed values:
// * `static` - built-in
// * `adaptive` - built-in // TODO
func FactoryConfigFromEnv() FactoryConfig {
Copy link
Member

Choose a reason for hiding this comment

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

are you planning to add changes to collector.main() here? Right now this function is not used.

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'm going to do that in the next PR, this one for API

Signed-off-by: Won Jun Jang <[email protected]>
Signed-off-by: Won Jun Jang <[email protected]>
Copy link
Member

@yurishkuro yurishkuro left a comment

Choose a reason for hiding this comment

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

check why code coverage drops

@black-adder black-adder merged commit d5ad797 into master Feb 28, 2018
@ghost ghost removed the review label Feb 28, 2018
@black-adder black-adder deleted the add_sampling_handler branch February 28, 2018 20:20
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.

4 participants