Skip to content

Commit

Permalink
Updated the ruleCache to update the rule during refresh.
Browse files Browse the repository at this point in the history
  • Loading branch information
AsakerMohd committed Jun 14, 2024
1 parent 32c7132 commit ae6da76
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/OpenTelemetry.Sampler.AWS/RulesCache.cs
Original file line number Diff line number Diff line change
Expand Up @@ -60,12 +60,14 @@ public void UpdateRules(List<SamplingRule> newRules)
List<SamplingRuleApplier> newRuleAppliers = new List<SamplingRuleApplier>();
foreach (var rule in newRules)
{
// If the rule already exists in the current list of appliers, then we reuse it.
// If there are any changes to the rule, UpdateTargets would update the rule.
// If the ruleApplier already exists in the current list of appliers, then we reuse it.
var ruleApplier = this.RuleAppliers
.FirstOrDefault(currentApplier => currentApplier.RuleName == rule.RuleName) ??
new SamplingRuleApplier(this.ClientId, this.Clock, rule, new Statistics());

// update the rule in the applier in case rule attributes have changed
ruleApplier.Rule = rule;

newRuleAppliers.Add(ruleApplier);
}

Expand Down

0 comments on commit ae6da76

Please sign in to comment.