{"record":{"id":"1c113ffd4da7d7ea","repo":"jaegertracing/jaeger","slug":"bucketsforcalculation-cannot-be-less-than-1","errorCode":null,"errorMessage":"BucketsForCalculation cannot be less than 1","messagePattern":"BucketsForCalculation cannot be less than 1","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/sampling/samplingstrategy/adaptive/post_aggregator.go","lineNumber":33,"sourceCode":"\t\"github.com/jaegertracing/jaeger/internal/leaderelection\"\n\t\"github.com/jaegertracing/jaeger/internal/metrics\"\n\t\"github.com/jaegertracing/jaeger/internal/sampling/samplingstrategy/adaptive/calculationstrategy\"\n\t\"github.com/jaegertracing/jaeger/internal/storage/v1/api/samplingstore\"\n\t\"github.com/jaegertracing/jaeger/internal/storage/v1/api/samplingstore/model\"\n)\n\nconst (\n\tmaxSamplingProbability = 1.0\n\n\tgetThroughputErrMsg = \"failed to get throughput from storage\"\n\n\t// The number of past entries for samplingCache the leader keeps in memory\n\tserviceCacheSize = 25\n)\n\nvar (\n\terrNonZero               = errors.New(\"CalculationInterval and AggregationBuckets must be greater than 0\")\n\terrBucketsForCalculation = errors.New(\"BucketsForCalculation cannot be less than 1\")\n)\n\n// nested map: service -> operation -> throughput.\ntype serviceOperationThroughput map[string]map[string]*model.Throughput\n\nfunc (t serviceOperationThroughput) get(service, operation string) (*model.Throughput, bool) {\n\tsvcThroughput, ok := t[service]\n\tif ok {\n\t\tv, ok := svcThroughput[operation]\n\t\treturn v, ok\n\t}\n\treturn nil, false\n}\n\n// nested map: service -> operation -> buckets of QPS values.\ntype serviceOperationQPS map[string]map[string][]float64\n\ntype throughputBucket struct {","sourceCodeStart":15,"sourceCodeEnd":51,"githubUrl":"https://github.com/jaegertracing/jaeger/blob/806f4447841ecdb60519f408b004a599d515f437/internal/sampling/samplingstrategy/adaptive/post_aggregator.go#L15-L51","documentation":"errBucketsForCalculation is returned by newPostAggregator when the Configuration's BucketsForCalculation is less than 1. This value defines how many aggregation buckets participate in each calculation, so zero or negative values make the adaptive sampling computation meaningless.","triggerScenarios":"Constructing the adaptive sampling post-aggregator with a Configuration whose BucketsForCalculation is 0 or negative — commonly when the field is omitted in config code or set via an env parse that yields 0.","commonSituations":"Custom YAML for the adaptive_sampling extension missing BucketsForCalculation; env var parsing returning 0 for an empty value; programmatically zero-valued structs.","solutions":["Set BucketsForCalculation to at least 1 (e.g. 1 or more buckets covering the calculation interval).","Verify any env-var/flag mapping that populates BucketsForCalculation defaults to a positive value.","Rely on the standard flag-based configuration to fill sane defaults."],"exampleFix":"// before\nconf := &sampling.Config{BucketsForCalculation: 0}\n// after\nconf := &sampling.Config{BucketsForCalculation: 1, CalculationInterval: 10 * time.Second, AggregationBuckets: 10}","handlingStrategy":"validation","validationCode":"if cfg.BucketsForCalculation < 1 {\n    return errors.New(\"BucketsForCalculation cannot be less than 1\")\n}","typeGuard":null,"tryCatchPattern":"agg, err := sampling.NewAggregator(cfg)\nif err != nil {\n    logger.Fatal(\"invalid adaptive sampling config\", zap.Error(err))\n}","preventionTips":["Set BucketsForCalculation >= 1 in the adaptive sampling config.","Check env parsing that may yield 0 for unset values.","Validate the whole config struct before constructing the aggregator."],"tags":["config","sampling","validation"],"backgroundTag":"invalid-config-value","analyzedSha":"806f4447841ecdb60519f408b004a599d515f437","analyzedAt":"2026-09-01T02:39:22.140Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T05:18:18.240Z"}