Skip to content

Commit

Permalink
Add APM rate limiting when ASM standalone is activated
Browse files Browse the repository at this point in the history
  • Loading branch information
vpellan committed Sep 13, 2024
1 parent 545df53 commit f370d24
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions lib/datadog/tracing/sampling/rule_sampler.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,15 +29,20 @@ def initialize(
default_sampler: nil
)
@rules = rules
@rate_limiter = if rate_limiter
@rate_limiter = if Datadog.configuration.appsec.standalone.enabled
# 0.0167 ~ 1 trace per minute
Core::TokenBucket.new(0.0167, 1.0)
elsif rate_limiter
rate_limiter
elsif rate_limit
Core::TokenBucket.new(rate_limit)
else
Core::UnlimitedLimiter.new
end

@default_sampler = if default_sampler
@default_sampler = if Datadog.configuration.appsec.standalone.enabled
@rules = [SimpleRule.new(sample_rate: 1.0)]
nil
elsif default_sampler
default_sampler
elsif default_sample_rate
# Add to the end of the rule list a rule always matches any trace
Expand Down

0 comments on commit f370d24

Please sign in to comment.