Skip to content

Commit

Permalink
code changes to use correct sampling options
Browse files Browse the repository at this point in the history
Signed-off-by: Shubhanshu Surana <[email protected]>
  • Loading branch information
Shubhanshu Surana committed Nov 4, 2019
1 parent 8ed347a commit 7eb554e
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
12 changes: 11 additions & 1 deletion pkg/config/sampling/sampling.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ func (u *Config) Get() *corev1.ConfigMap {
if CheckForSamplingConfigFile(u.jaeger) {
return nil
}

// Check for empty map
if u.jaeger.Spec.Sampling.Options.IsEmpty() {
jsonObject = []byte(defaultSamplingStrategy)
Expand Down Expand Up @@ -84,7 +85,16 @@ func (u *Config) Get() *corev1.ConfigMap {
// CheckForSamplingConfigFile will check if there is a config file present
// if there is one it returns true
func CheckForSamplingConfigFile(jaeger *v1.Jaeger) bool {
jsonObject, err := jaeger.Spec.Sampling.Options.MarshalJSON()
options := v1.Options{}

// check for deployment strategy
if jaeger.Spec.Strategy == "allInOne" {
options = jaeger.Spec.AllInOne.Options
} else {
options = jaeger.Spec.Collector.Options
}

jsonObject, err := options.MarshalJSON()

if err != nil {
return false
Expand Down
6 changes: 4 additions & 2 deletions pkg/config/sampling/sampling_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,11 +83,13 @@ func TestUpdateWithSamplingConfig(t *testing.T) {

func TestUpdateWithSamplingConfigFileOption(t *testing.T) {
jaeger := v1.NewJaeger(types.NamespacedName{Name: "TestUpdateWithSamplingConfigFileOption"})
jaeger.Spec.Sampling.Options = v1.NewFreeForm(map[string]interface{}{
jaeger.Spec.Strategy = "allInOne"
jaeger.Spec.AllInOne.Options = v1.NewOptions(map[string]interface{}{
"sampling.strategies-file": "/etc/jaeger/sampling.json",
})
options := []string{}
commonSpec := v1.JaegerCommonSpec{}

Update(jaeger, &commonSpec, &options)
assert.Len(t, commonSpec.Volumes, 0)
assert.Len(t, commonSpec.VolumeMounts, 0)
Expand All @@ -96,7 +98,7 @@ func TestUpdateWithSamplingConfigFileOption(t *testing.T) {

func TestGetWithSamplingConfigFileOption(t *testing.T) {
jaeger := v1.NewJaeger(types.NamespacedName{Name: "TestGetWithSamplingConfigFileOption"})
jaeger.Spec.Sampling.Options = v1.NewFreeForm(map[string]interface{}{
jaeger.Spec.Collector.Options = v1.NewOptions(map[string]interface{}{
"sampling.strategies-file": "/etc/jaeger/sampling.json",
})

Expand Down

0 comments on commit 7eb554e

Please sign in to comment.