pinpoint-apm/pinpoint · error · IllegalStateException
Unexpected samplerType: ${samplerType}
Error message
Unexpected samplerType: ${samplerType} What it means
SamplerProvider.newSamplerFactory throws IllegalStateException('Unexpected samplerType') when the parsed TraceSamplerType does not match any supported switch case (e.g. COUNTING or PERCENT). The default branch marks a parse failure of the configured sampler type string. It prevents the profiler from running with an unknown sampling strategy.
Source
Thrown at agent-module/profiler/src/main/java/com/navercorp/pinpoint/profiler/context/provider/sampler/SamplerProvider.java:67
if (!config.isSamplingEnable()) {
return FalseSampler.INSTANCE;
}
SamplerType samplerType = config.getSamplerType();
SamplerFactory samplerFactory = newSamplerFactory(samplerType, profilerConfig);
return samplerFactory.createSampler();
}
private SamplerFactory newSamplerFactory(SamplerType samplerType, ProfilerConfig profilerConfig) {
switch (samplerType) {
case COUNTING:
return newCountingSamplerFactory(profilerConfig);
case PERCENT:
return newPercentSamplerFactory(profilerConfig);
default:
// parse fail
throw new IllegalStateException("Unexpected samplerType: " + samplerType);
}
}
private SamplerFactory newCountingSamplerFactory(ProfilerConfig profilerConfig) {
CountingSamplerFactory.Config config = CountingSamplerFactory.config(profilerConfig);
logger.info("CountingSamplerFactory.Config:{}", config);
return new CountingSamplerFactory(config);
}
private SamplerFactory newPercentSamplerFactory(ProfilerConfig profilerConfig) {
PercentSamplerFactory.Config config = PercentSamplerFactory.config(profilerConfig);
logger.info("PercentSamplerFactory.Config:{}", config);
return new PercentSamplerFactory(config);
}View on GitHub (pinned to 744c3d3075)
Solutions
- Set profiler.sampling.type... to a supported value: PERCENT or COUNTING
- Fix typos in the sampling configuration property value
- Check the Pinpoint version's documentation for valid sampler type names and remove unsupported values
- Validate the whole profiler configuration file after an upgrade
Example fix
// before profiler.sampling.type.sampling=new profiler.sampling.new.sampler.type=percet // after profiler.sampling.type.sampling=new profiler.sampling.new.sampler.type=percent
Defensive patterns
Strategy: validation
Validate before calling
String samplerType = config.readString("profiler.sampling.new.sampler.type");
if (!"PERCENT".equalsIgnoreCase(samplerType) && !"COUNTING".equalsIgnoreCase(samplerType)) {
throw new IllegalArgumentException("Invalid sampler type: " + samplerType);
} Type guard
boolean isValidSamplerType(String s) {
return "PERCENT".equalsIgnoreCase(s) || "COUNTING".equalsIgnoreCase(s);
} Try / catch
try {
Sampler sampler = samplerProvider.get();
} catch (IllegalStateException e) {
logger.error("Sampler configuration invalid: {}", e.getMessage());
throw e;
} Prevention
- Validate profiler.sampling.* values against the documented enum after every config edit
- Copy sampling config only from the same Pinpoint version's example files
- Lint the profiler configuration at startup before sampling is needed
When it happens
Trigger: The profiler.sampling.type... configuration value fails to map to a known TraceSamplerType during parsing, so samplerFactory -> newSamplerFactory ends in the switch default branch.
Common situations: Typos in the sampling type property (e.g. 'percet' instead of 'percent'), an unsupported sampler type name copied from an example config, or a config file from a different Pinpoint version with a removed sampler type.
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
- service type name must not be empty
- Invalid type provider definition :
- invalid full qualified method name(). not found method
- invalid oracle jdbc url:<driverUrl>
- agentInfoRefreshIntervalMs must be greater than 0
AI-assisted analysis of pinpoint-apm/pinpoint@744c3d3075 (2026-09-07).
Data as JSON: /api/errors/063717ea12e80152.
Report an issue: GitHub.