-
Notifications
You must be signed in to change notification settings - Fork 160
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
Parses schema extraction remote config configuration #2428
Conversation
05825bc
to
cbb6eed
Compare
336d777
to
e4f9b11
Compare
appsec/src/helper/sampler.hpp
Outdated
if (sample_rate_ != | ||
valid_sample_rate(service_config_->get_request_sample_rate())) { | ||
set_sampler_rate(service_config_->get_request_sample_rate()); |
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 makes no sense for you to be doing all these checks on each call to get()
, then calling valid_sample_rate
possibly twice, etc. Plus there's the lock and concurrent_
, ...
What I suggest is:
- Make the only mutable variable in
sampler
berequest_
(an atomic that you can increment with fetch_add and relaxed memory order btw). - Keep the sample rate, but never change it.
- Remove the mutex. Remove,
service_config_
. Removeconcurrent_
, maybe, I've no idea what it's doing. - Do all the normalization of the sample rate on the sampler constructor or before calling the constructor.
- Store the sampler in an atomic shared_ptr if this is c++20 or previous facilities if before.
- The condition in
request_ < std::numeric_limits<unsigned>::max()
is also redudant, unsigned numbers already wrap around.
3597b5d
to
3651c11
Compare
3651c11
to
20cac65
Compare
5e7989a
to
ccf2514
Compare
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.
Sorry I should've mentioned this sooner but the RFC related to sampling was deprecated in favour of a new one. So the sampling isn't provided through remote configuration any longer.
I'm not sure if there's anything from this PR you'd like to keep but otherwise it can't be merged.
Description
Reviewer checklist