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

fix: jaeger-agent sampling endpoint returns backwards incompatible JSON #3892

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 6 additions & 5 deletions model/converter/thrift/jaeger/sampling_from_domain.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,11 +67,12 @@ func convertPerOperationFromDomain(s *api_v2.PerOperationSamplingStrategies) *sa
DefaultLowerBoundTracesPerSecond: s.GetDefaultLowerBoundTracesPerSecond(),
DefaultUpperBoundTracesPerSecond: &s.DefaultUpperBoundTracesPerSecond,
}
if s.GetPerOperationStrategies() != nil {
r.PerOperationStrategies = make([]*sampling.OperationSamplingStrategy, len(s.GetPerOperationStrategies()))
for i, k := range s.PerOperationStrategies {
r.PerOperationStrategies[i] = convertOperationFromDomain(k)
}

perOp := s.GetPerOperationStrategies()
// Default to empty array so that json.Marshal returns [] instead of null (Issue #3891).
r.PerOperationStrategies = make([]*sampling.OperationSamplingStrategy, len(perOp))
for i, k := range perOp {
r.PerOperationStrategies[i] = convertOperationFromDomain(k)
}
Copy link
Member

@yurishkuro yurishkuro Sep 1, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you can simply remove the if statement and only keep its content

        perOp := s.GetPerOperationStrategies()
        // Default to empty array so that json.Marshal returns [] instead of null (Issue #3891).
        r.PerOperationStrategies = make([]*sampling.OperationSamplingStrategy, len(perOp))
        for i, k := range perOp {
            r.PerOperationStrategies[i] = convertOperationFromDomain(k)
        }

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

D'oh! ty!

return r
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,13 @@ func TestConvertPerOperationStrategyFromDomain(t *testing.T) {
PerOperationStrategies: []*sampling.OperationSamplingStrategy{{Operation: "fao"}},
},
},
{},
{
in: &api_v2.PerOperationSamplingStrategies{DefaultSamplingProbability: 15.2, DefaultUpperBoundTracesPerSecond: a, DefaultLowerBoundTracesPerSecond: 2},
expected: &sampling.PerOperationSamplingStrategies{
DefaultSamplingProbability: 15.2, DefaultUpperBoundTracesPerSecond: &a, DefaultLowerBoundTracesPerSecond: 2,
PerOperationStrategies: []*sampling.OperationSamplingStrategy{},
},
},
}
for _, test := range tests {
o := convertPerOperationFromDomain(test.in)
Expand Down