Skip to content
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

XRay Remote Sampler - Preserve previous rule reservoir if rule property has not changed #3620

Merged
merged 10 commits into from
May 2, 2023
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm

- AWS SDK span name to be of the format `Service.Operation` in `go.opentelemetry.io/contrib/instrumentation/github.com/aws/aws-sdk-go-v2/otelaws`. (#3582, #3521)
- Prevent sampler configuration reset from erroneously sampling first span in `go.opentelemetry.io/contrib/samplers/jaegerremote`. (#3603, #3604)
- AWS XRay Remote Sampling to preserve previous rule if updated rule property has not changed in `go.opentelemetry.io/contrib/samplers/aws/xray`. (#3619, # TBD)
jj22ee marked this conversation as resolved.
Show resolved Hide resolved

## [1.16.0-rc.1/0.41.0-rc.1/0.9.0-rc.1] - 2023-03-02

Expand Down
15 changes: 15 additions & 0 deletions samplers/aws/xray/internal/manifest.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import (
"fmt"
"math"
"net/url"
"reflect"
"sort"
"strings"
"sync"
Expand Down Expand Up @@ -183,7 +184,21 @@ func (m *Manifest) updateRules(rules *getSamplingRulesOutput) {
// Re-sort to fix matching priorities.
tempManifest.sort()

var currentRuleMap = make(map[string]Rule)

m.mu.Lock()
for _, rule := range m.Rules {
currentRuleMap[rule.ruleProperties.RuleName] = rule
}

for i, newRule := range tempManifest.Rules {
if curRule, ok := currentRuleMap[newRule.ruleProperties.RuleName]; ok {
if reflect.DeepEqual(newRule.ruleProperties, curRule.ruleProperties) {
tempManifest.Rules[i] = curRule
}
}
}

m.Rules = tempManifest.Rules
m.refreshedAt = m.clock.now()
m.mu.Unlock()
Expand Down