Skip to content

Commit

Permalink
Fixing review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
vikrambe committed Aug 22, 2021
1 parent dfde6d6 commit 3980805
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 11 deletions.
2 changes: 1 addition & 1 deletion processor/tailsamplingprocessor/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ Multiple policies exist today and it is straight forward to add more. These incl
- `composite`: Sample based on a combination of above samplers, with ordering and rate allocation per sampler. Rate allocation allocates certain percentages of spans per policy order.
For example if we have set max_total_spans_per_second as 100 then we can set rate_allocation as follows
1. test-composite-policy-1 = 50 % of max_total_spans_per_second = 50 spans_per_second
2. test-composite-policy-1 = 25 % of max_total_spans_per_second = 25 spans_per_second
2. test-composite-policy-2 = 25 % of max_total_spans_per_second = 25 spans_per_second
3. To ensure remaining capacity is filled use always_sample as one of the policies

The following configuration options can also be modified:
Expand Down
11 changes: 5 additions & 6 deletions processor/tailsamplingprocessor/composite_helper.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,8 @@ import (
func getNewCompositePolicy(logger *zap.Logger, config CompositeCfg) (sampling.PolicyEvaluator, error) {
var subPolicyEvalParams []sampling.SubPolicyEvalParams
rateAllocationsMap := getRateAllocationMap(config)
for i := range config.SubPolicyCfg {
policyCfg := &config.SubPolicyCfg[i]
policy, _ := getSubPolicyEvaluator(logger, policyCfg)
for _, policyCfg := range config.SubPolicyCfg {
policy, _ := getSubPolicyEvaluator(logger, &policyCfg)

evalParams := sampling.SubPolicyEvalParams{
Evaluator: policy,
Expand All @@ -44,11 +43,11 @@ func getRateAllocationMap(config CompositeCfg) map[string]float64 {
maxTotalSPS := float64(config.MaxTotalSpansPerSecond)
// Default SPS determined by equally diving number of sub policies
defaultSPS := maxTotalSPS / float64(len(config.SubPolicyCfg))
for i := 0; i < len(config.RateAllocation); i++ {
rAlloc := &config.RateAllocation[i]
rateAllocationsMap[rAlloc.Policy] = defaultSPS
for _, rAlloc := range config.RateAllocation{
if rAlloc.Percent > 0 {
rateAllocationsMap[rAlloc.Policy] = (float64(rAlloc.Percent) / 100) * maxTotalSPS
}else {
rateAllocationsMap[rAlloc.Policy] = defaultSPS
}
}
return rateAllocationsMap
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ func TestCompositeEvaluatorThrottling(t *testing.T) {
// Create only one subpolicy, with 100% Sampled policy.
n1 := NewAlwaysSample(zap.NewNop())
timeProvider := &FakeTimeProvider{second: 0}
const totalSPS = 100
const totalSPS = 10
c := NewComposite(zap.NewNop(), totalSPS, []SubPolicyEvalParams{{n1, totalSPS}}, timeProvider)

trace := createTrace()
Expand Down Expand Up @@ -159,18 +159,18 @@ func TestOnLateArrivingSpans_Composite(t *testing.T) {
n1 := NewNumericAttributeFilter(zap.NewNop(), "tag", 0, 100)
n2 := NewAlwaysSample(zap.NewNop())
timeProvider := &FakeTimeProvider{second: 0}
const totalSPS = 100
const totalSPS = 10
c := NewComposite(zap.NewNop(), totalSPS, []SubPolicyEvalParams{{n1, totalSPS / 2}, {n2, totalSPS / 2}}, timeProvider)
e := c.OnLateArrivingSpans(Sampled, nil)
assert.Nil(t, e)
assert.NoError(t, e)
}

func TestCompositeEvaluator2SubpolicyThrottling(t *testing.T) {

n1 := NewNumericAttributeFilter(zap.NewNop(), "tag", 0, 100)
n2 := NewAlwaysSample(zap.NewNop())
timeProvider := &FakeTimeProvider{second: 0}
const totalSPS = 100
const totalSPS = 10
c := NewComposite(zap.NewNop(), totalSPS, []SubPolicyEvalParams{{n1, totalSPS / 2}, {n2, totalSPS / 2}}, timeProvider)

trace := createTrace()
Expand Down

0 comments on commit 3980805

Please sign in to comment.