pinpoint-apm/pinpoint · error · IllegalArgumentException
Invalid samplingRate
Error message
Invalid samplingRate
What it means
CountingSampler samples 1 of every N requests; its constructor requires samplingRate > 0 and throws IllegalArgumentException for zero or negative values. The rate is the denominator of the counting strategy, so 0 is meaningless and negative is invalid.
Solutions
- Set profiler.sampling.rate (or the constructor argument) to a positive integer >= 1
- If the intent is to never sample, configure sampling.type to disable/never-sampling rather than rate 0
- Check the config source/placeholder resolution so the value isn't interpolated to 0
Example fix
// before sampling.rate=0 // after sampling.rate=7
Defensive patterns
Strategy: validation
Validate before calling
int rate = Integer.parseInt(props.getProperty("profiler.sampling.rate"));
if (rate <= 0) throw new IllegalArgumentException("profiler.sampling.rate must be >= 1, got " + rate); Type guard
boolean isValidSamplingRate(Integer r) { return r != null && r > 0; } Try / catch
try { sampler = new CountingSampler(rate); } catch (IllegalArgumentException e) { log.error("Bad sampling rate: {}", e.getMessage()); sampler = Samplers.createSamplingSampler(...); } Prevention
- Never set profiler.sampling.rate to 0; use a non-sampling sampler type for that intent
- Validate config values at startup with clear messages
- Beware unresolved placeholders interpolating to 0
When it happens
Trigger: Constructing new CountingSampler(0) or new CountingSampler(<0), typically from profiler config Profiler.sampling.rate=0 or a parsed/interpolated config value resolving to <= 0.
Common situations: User sets profiler.sampling.rate=0 intending "sample nothing" (should use a disabling sampler instead), or config parsing yields 0 due to a placeholder not being substituted.
Related errors
- Invalid samplingRate
- Failed to detect pinpoint profile. Please add…
- access error
- Illegal report period:
- injectField error field
AI-assisted analysis of pinpoint-apm/pinpoint@744c3d3075 (2026-09-07).
Data as JSON: /api/errors/177384d06122001b.
Report an issue: GitHub.
Appendix: source
Thrown at agent-module/profiler/src/main/java/com/navercorp/pinpoint/profiler/sampler/CountingSampler.java:34
package com.navercorp.pinpoint.profiler.sampler;
import com.navercorp.pinpoint.bootstrap.sampler.Sampler;
import com.navercorp.pinpoint.common.util.MathUtils;
import java.util.concurrent.atomic.AtomicInteger;
/**
* @author emeroad
*/
public class CountingSampler implements Sampler {
private final AtomicInteger counter = new AtomicInteger(0);
private final int samplingRate;
public CountingSampler(int samplingRate) {
if (samplingRate <= 0) {
throw new IllegalArgumentException("Invalid samplingRate " + samplingRate);
}
this.samplingRate = samplingRate;
}
@Override
public boolean isSampling() {
int samplingCount = counter.getAndIncrement();
int isSampling = MathUtils.floorMod(samplingCount, samplingRate);
return isSampling == 0;
}
@Override
public String toString() {
return "SamplingRateSampler{" +
"counter=" + counter +
"samplingRate=" + samplingRate +
'}';View on GitHub (pinned to 744c3d3075)