jaegertracing/jaeger · error
could not convert sampling strategy type
Error message
could not convert sampling strategy type
What it means
convertStrategyTypeFromDomain returns this error when the domain sampling strategy type is neither PROBABILISTIC nor RATE_LIMITING, i.e. an unknown/unsupported enum value for the legacy Thrift representation.
Source
Thrown at internal/converter/thrift/jaeger/sampling_from_domain.go:89
func convertOperationFromDomain(s *api_v2.OperationSamplingStrategy) *sampling.OperationSamplingStrategy {
if s == nil {
return nil
}
return &sampling.OperationSamplingStrategy{
Operation: s.GetOperation(),
ProbabilisticSampling: convertProbabilisticFromDomain(s.GetProbabilisticSampling()),
}
}
func convertStrategyTypeFromDomain(s api_v2.SamplingStrategyType) (sampling.SamplingStrategyType, error) {
switch s {
case api_v2.SamplingStrategyType_PROBABILISTIC:
return sampling.SamplingStrategyType_PROBABILISTIC, nil
case api_v2.SamplingStrategyType_RATE_LIMITING:
return sampling.SamplingStrategyType_RATE_LIMITING, nil
default:
return sampling.SamplingStrategyType_PROBABILISTIC, errors.New("could not convert sampling strategy type")
}
}
View on GitHub (pinned to 806f444784)
Solutions
- Set the strategy type explicitly to PROBABILISTIC or RATE_LIMITING before conversion
- Regenerate/upgrade the api_v2 and thrift bindings together so enum sets match
- Treat the error as a protocol-compat signal: log and fall back to a default strategy in the caller
Example fix
// before
resp := &api_v2.SamplingStrategyResponse{} // StrategyType unset
// after
resp := &api_v2.SamplingStrategyResponse{
StrategyType: api_v2.SamplingStrategyType_PROBABILISTIC,
} Defensive patterns
Strategy: type-guard
Validate before calling
switch s.StrategyType {
case api_v2.SamplingStrategyType_PROBABILISTIC, api_v2.SamplingStrategyType_RATE_LIMITING:
// ok
default:
return errors.New("unsupported sampling strategy type")
}
resp, err := jaegerconv.ConvertSamplingResponseFromDomain(s) Type guard
func convertibleStrategyType(t api_v2.SamplingStrategyType) bool {
return t == api_v2.SamplingStrategyType_PROBABILISTIC ||
t == api_v2.SamplingStrategyType_RATE_LIMITING
} Try / catch
resp, err := ConvertSamplingResponseFromDomain(s)
if err != nil {
if strings.Contains(err.Error(), "could not convert sampling strategy type") {
return defaultSamplingResponse(), nil
}
return nil, err
} Prevention
- Always set StrategyType explicitly in the domain response
- Keep api_v2 and thrift enum bindings version-aligned
- Fall back to a default strategy on unknown enum values
When it happens
Trigger: ConvertSamplingResponseFromDomain receives an api_v2.SamplingStrategyType outside the two known values (e.g. an enum value from a newer IDL or a zero/unset type in a hand-built struct); the switch default errors.
Common situations: Deserializing a sampling response produced by a newer service using an added enum value; constructing the strategy struct manually and leaving StrategyType unset (0 fallback in proto2 enums); IDL version skew between client and server.
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/28a791892800b818.
Report an issue: GitHub.