-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
[extension/jaegerremotesampling] remove jaeger sampling dependency #36977
base: main
Are you sure you want to change the base?
Conversation
Signed-off-by: Aryan Goyal <[email protected]>
extension/jaegerremotesampling/internal/remote_strategy_store.go
Outdated
Show resolved
Hide resolved
Signed-off-by: Aryan Goyal <[email protected]>
Signed-off-by: Aryan Goyal <[email protected]>
Signed-off-by: Aryan Goyal <[email protected]>
Signed-off-by: Aryan Goyal <[email protected]>
Signed-off-by: Aryan Goyal <[email protected]>
Signed-off-by: Aryan Goyal <[email protected]>
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.
The organization of the components needs to be improved, it's all over the place. I would recommend
internal/
source/
source.go - define interface
filesource/ - define reading from file
remotesource/ - a proxy that reads from a remote service
server/
grpc/ - grpc server that uses Source
http/ - http server that uses Source and defines its own JSON model
// Flag for enabling possibly breaking change which includes default operations level | ||
// strategies when calculating Ratelimiting type service level strategy | ||
// more information https://github.com/jaegertracing/jaeger/issues/5270 | ||
IncludeDefaultOpStrategies 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.
this does not seem to be populated or used
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 used by the filesource(currently in newProvider in provider.go, will update the PR soon):
if !h.options.IncludeDefaultOpStrategies {
h.logger.Warn("Default operations level strategies will not be included for Ratelimiting service strategies." +
"This behavior will be changed in future releases. " +
"Cf. https://github.com/jaegertracing/jaeger/issues/5270")
h.parseStrategies_deprecated(strategies)
} else {
h.parseStrategies(strategies)
}
) | ||
|
||
// Options holds configuration for the static sampling strategy store. | ||
type Options 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.
if provider only takes two arguments I would just pass them directly without this extra struct
type strategyLoader func() ([]byte, error) | ||
|
||
// newProvider creates a strategy store that holds static sampling strategies. | ||
func newProvider(options Options, logger *zap.Logger) (internal.Provider, error) { |
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.
internal.Provider is an interface. You have two possible implementations, File and Remote. Calling this function newProvider
when it's actually creating FileProvider is misleading
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.
also, the main Config calls this Source
, so I would get rid of "provider" nomenclature altogether and have FileSource & RemoteSource (both should be in internal package)
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.
That makes sense, I'll try and improve it
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.
Still need to clean up a bit before updating the PR, but here's the new internal
package structure:
└── internal
├── mocks
│ └── mock_source.go (Needed for grpc_test and http_test. Should I just include these in both the test files and skip making this package?)
├── server
│ ├── grpc
│ │ ├── grpc.go
│ │ ├── grpc_handler.go
│ │ ├── grpc_handler_test.go
│ │ └── grpc_test.go
│ └── http
│ ├── http.go
│ └── http_test.go
└── source
├── interface.go
├── filesource
│ ├── constants.go
│ ├── fixtures/ (used for testing)
│ ├── model.go
│ ├── options.go
│ ├── filesource.go (previously provider.go; newProvider will be renamed NewFileSource function that returns a source.Source)
│ └── filesource_test.go
└── remotesource
├── manager.go
├── manager_test.go
├── remote_strategy_cache.go
├── remote_strategy_cache_test.go
└── remote_strategy_store.go (rename NewRemoteStrategyStore to NewRemoteSource, returns a source.Source)
|
||
// 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 { |
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.
where are these used? Do they need to be in the root package? It seems these define the data types for JSON output, so should be next to http server code.
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 think http uses the response from the Source interface's GetSamplingStrategy for the JSON output, which is github.com/jaegertracing/jaeger/proto-gen/api_v2.SamplingStrategyResponse
.
This is used by the filesource to load the strategies
...rremotesampling/fixtures/TestServiceNoPerOperationStrategiesDeprecatedBehavior_ServiceA.json
Outdated
Show resolved
Hide resolved
Co-authored-by: Yuri Shkuro <[email protected]>
Signed-off-by: Aryan Goyal <[email protected]>
lgtm! Let's makes sure all CI checks are green. |
Signed-off-by: Aryan Goyal <[email protected]>
Signed-off-by: Aryan Goyal <[email protected]>
Sorry, closing was a misclick on
|
600 permission should be fine
There's rarely a good reason to ignore errors, even in tests - at some point something might break, and ignored error makes it harder to debug. You can always add |
Signed-off-by: Aryan Goyal <[email protected]>
Thanks for your help :) Should be fixed now |
Description
Copy the required code from jaeger to extension/jaegerremotesampling:
plugin/sampling/strategyprovider/static
cmd/collector/app/sampling
tointernal
Link to tracking issue
Fixes #36976
Testing
grpc_handler_test.go
fromcmd/collector/app/sampling/grpc_handler_test.go
provider_test.go
fromplugin/sampling/strategyprovider/static/provider_test.go
withplugin/sampling/strategyprovider/static/fixtures