jaegertracing/jaeger · error

CalculationInterval and AggregationBuckets must be greater t

Error message

CalculationInterval and AggregationBuckets must be greater than 0

What it means

errNonZero is returned by newPostAggregator in the adaptive sampling strategy when its Configuration has a zero or negative CalculationInterval or AggregationBuckets. Both values drive the periodic post-aggregation loop, so they must be strictly positive for the aggregator to function.

Source

Thrown at internal/sampling/samplingstrategy/adaptive/post_aggregator.go:32

	"github.com/jaegertracing/jaeger/internal/leaderelection"
	"github.com/jaegertracing/jaeger/internal/metrics"
	"github.com/jaegertracing/jaeger/internal/sampling/samplingstrategy/adaptive/calculationstrategy"
	"github.com/jaegertracing/jaeger/internal/storage/v1/api/samplingstore"
	"github.com/jaegertracing/jaeger/internal/storage/v1/api/samplingstore/model"
)

const (
	maxSamplingProbability = 1.0

	getThroughputErrMsg = "failed to get throughput from storage"

	// The number of past entries for samplingCache the leader keeps in memory
	serviceCacheSize = 25
)

var (
	errNonZero               = errors.New("CalculationInterval and AggregationBuckets must be greater than 0")
	errBucketsForCalculation = errors.New("BucketsForCalculation cannot be less than 1")
)

// nested map: service -> operation -> throughput.
type serviceOperationThroughput map[string]map[string]*model.Throughput

func (t serviceOperationThroughput) get(service, operation string) (*model.Throughput, bool) {
	svcThroughput, ok := t[service]
	if ok {
		v, ok := svcThroughput[operation]
		return v, ok
	}
	return nil, false
}

// nested map: service -> operation -> buckets of QPS values.
type serviceOperationQPS map[string]map[string][]float64

View on GitHub (pinned to 806f444784)

Solutions

  1. Set CalculationInterval to a positive duration (e.g. 10s).
  2. Set AggregationBuckets to a positive integer (e.g. 10).
  3. Use the provided default/flag-driven configuration rather than hand-building the struct so defaults apply.

Example fix

// before
conf := &sampling.Config{}
agg := sampling.NewAggregator(conf) // error
// after
conf := &sampling.Config{CalculationInterval: 10 * time.Second, AggregationBuckets: 10}
agg := sampling.NewAggregator(conf) // ok
Defensive patterns

Strategy: validation

Validate before calling

if cfg.CalculationInterval <= 0 || cfg.AggregationBuckets <= 0 {
    return errors.New("CalculationInterval and AggregationBuckets must be greater than 0")
}

Try / catch

agg, err := sampling.NewAggregator(cfg)
if err != nil {
    logger.Fatal("invalid adaptive sampling config", zap.Error(err))
}

Prevention

When it happens

Trigger: Starting the adaptive sampling leader/aggregator with a Configuration where CalculationInterval <= 0 or AggregationBuckets <= 0 (e.g. unset interval in the adaptive sampling config).

Common situations: Building a custom config struct in Go without setting these fields; YAML/env config omitting the values; copying a minimal config that only sets a few options.

Understand the failure class

Background: "Invalid value" and "allowed values are" config errors: what your library rejected and how to fix it — this error's family across 41 libraries.

Related errors


AI-assisted analysis of jaegertracing/jaeger@806f444784 (2026-09-01). Data as JSON: /api/errors/147cd4b63f243670. Report an issue: GitHub.