jaegertracing/jaeger · error
could not convert sampling strategy type
Error message
could not convert sampling strategy type
What it means
convertStrategyTypeToDomain returns this error when the legacy Thrift sampling strategy type is neither PROBABILISTIC nor RATE_LIMITING, so it cannot be mapped into the domain model enum. The function returns the zero domain value alongside the error.
Source
Thrown at internal/converter/thrift/jaeger/sampling_to_domain.go:71
ProbabilisticSampling: convertProbabilisticToDomain(pos.GetProbabilisticSampling()),
}
}
return &api_v2.PerOperationSamplingStrategies{
DefaultSamplingProbability: s.GetDefaultSamplingProbability(),
DefaultUpperBoundTracesPerSecond: s.GetDefaultUpperBoundTracesPerSecond(),
DefaultLowerBoundTracesPerSecond: s.GetDefaultLowerBoundTracesPerSecond(),
PerOperationStrategies: poss,
}
}
func convertStrategyTypeToDomain(t sampling.SamplingStrategyType) (api_v2.SamplingStrategyType, error) {
switch t {
case sampling.SamplingStrategyType_PROBABILISTIC:
return api_v2.SamplingStrategyType_PROBABILISTIC, nil
case sampling.SamplingStrategyType_RATE_LIMITING:
return api_v2.SamplingStrategyType_RATE_LIMITING, nil
default:
return api_v2.SamplingStrategyType_PROBABILISTIC, errors.New("could not convert sampling strategy type")
}
}
View on GitHub (pinned to 806f444784)
Solutions
- Ensure the remote client only sends PROBABILISTIC or RATE_LIMITING strategy types
- Align the thrift IDL/generated code versions on both sides of the conversion
- In the caller, check err != nil and fall back to a default sampling response instead of using the zero-value result
Example fix
// before
resp, err := ConvertSamplingResponseToDomain(thriftResp) // thriftResp.StrategyType unknown
_ = resp // zero-value result used even on error
// after
resp, err := ConvertSamplingResponseToDomain(thriftResp)
if err != nil {
resp = defaultSamplingResponse()
} Defensive patterns
Strategy: type-guard
Validate before calling
switch t.StrategyType {
case sampling.SamplingStrategyType_PROBABILISTIC, sampling.SamplingStrategyType_RATE_LIMITING:
// ok
default:
return errors.New("unsupported thrift sampling strategy type")
}
resp, err := jaegerconv.ConvertSamplingResponseToDomain(t) Type guard
func convertibleToDomain(t sampling.SamplingStrategyType) bool {
return t == sampling.SamplingStrategyType_PROBABILISTIC ||
t == sampling.SamplingStrategyType_RATE_LIMITING
} Try / catch
resp, err := ConvertSamplingResponseToDomain(t)
if err != nil {
if strings.Contains(err.Error(), "could not convert sampling strategy type") {
return defaultDomainResponse(), nil
}
return nil, err
} Prevention
- Validate incoming thrift strategy type before conversion
- Keep thrift IDL versions synchronized with the collector
- Ignore the zero-value result when the error is non-nil
When it happens
Trigger: ConvertSamplingResponseToDomain receives a sampling.SamplingStrategyType outside the two known enum values — typically a value added by a newer Thrift IDL or a corrupt/unknown wire value; the switch default errors.
Common situations: Old/other Jaeger clients sending a strategy type this converter doesn't know; thrift IDL mismatch between the remote client library and the collector's generated code; fuzzed or malformed remote-sampling responses.
Related errors
- could not convert sampling strategy type
- maxTracesPerSecond is higher than int16
- no sampling strategy provider specified, expecting 'adaptive
- only one sampling strategy provider can be specified, 'adapt
- reload interval must be a positive value, or zero to disable
AI-assisted analysis of jaegertracing/jaeger@806f444784 (2026-09-01).
Data as JSON: /api/errors/7318642619714492.
Report an issue: GitHub.