Skip to content

Commit 43be1e7

Browse files
change polling interval property name to match spec (#6672)
Co-authored-by: Jack Berg <[email protected]>
1 parent 09de4bd commit 43be1e7

File tree

2 files changed

+21
-2
lines changed

2 files changed

+21
-2
lines changed

sdk-extensions/jaeger-remote-sampler/src/main/java/io/opentelemetry/sdk/extension/trace/jaeger/sampler/JaegerRemoteSamplerProvider.java

+20-1
Original file line numberDiff line numberDiff line change
@@ -10,16 +10,21 @@
1010
import io.opentelemetry.sdk.trace.samplers.Sampler;
1111
import java.util.Map;
1212
import java.util.concurrent.TimeUnit;
13+
import java.util.logging.Level;
14+
import java.util.logging.Logger;
1315

1416
public class JaegerRemoteSamplerProvider implements ConfigurableSamplerProvider {
1517

18+
private static final Logger LOGGER =
19+
Logger.getLogger(JaegerRemoteSamplerProvider.class.getName());
20+
1621
// visible for testing
1722
static final String ATTRIBUTE_PROPERTY = "otel.resource.attributes";
1823
static final String SERVICE_NAME_PROPERTY = "otel.service.name";
1924
static final String SAMPLER_ARG_PROPERTY = "otel.traces.sampler.arg";
2025
static final String RESOURCE_ATTRIBUTE_SERVICE_NAME_PROPERTY = "service.name";
2126
private static final String ENDPOINT_KEY = "endpoint";
22-
private static final String POLLING_INTERVAL = "pollingInterval";
27+
private static final String POLLING_INTERVAL = "pollingIntervalMs";
2328
private static final String INITIAL_SAMPLING_RATE = "initialSamplingRate";
2429

2530
@Override
@@ -43,9 +48,23 @@ public Sampler createSampler(ConfigProperties config) {
4348
builder.setEndpoint(endpoint);
4449
}
4550
String pollingInterval = params.get(POLLING_INTERVAL);
51+
// Previously, we mistakenly read from pollingInterval. For backwards compatibility, check
52+
// pollingInterval and log warning if set.
53+
if (pollingInterval == null) {
54+
pollingInterval = params.get("pollingInterval");
55+
if (pollingInterval != null) {
56+
LOGGER.log(
57+
Level.WARNING,
58+
SAMPLER_ARG_PROPERTY
59+
+ " contains deprecated \"pollingInterval\" property. Please use \""
60+
+ POLLING_INTERVAL
61+
+ "\" instead.");
62+
}
63+
}
4664
if (pollingInterval != null) {
4765
builder.setPollingInterval(Integer.valueOf(pollingInterval), TimeUnit.MILLISECONDS);
4866
}
67+
4968
String initialSamplingRate = params.get(INITIAL_SAMPLING_RATE);
5069
if (initialSamplingRate != null) {
5170
builder.setInitialSampler(

sdk-extensions/jaeger-remote-sampler/src/test/java/io/opentelemetry/sdk/extension/trace/jaeger/sampler/JaegerRemoteSamplerProviderTest.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ void serviceProvider() {
3434
.thenReturn("test_service");
3535
HashMap<String, String> samplerArgs = new HashMap<>();
3636
samplerArgs.put("endpoint", "http://localhost:9999");
37-
samplerArgs.put("pollingInterval", "99");
37+
samplerArgs.put("pollingIntervalMs", "99");
3838
double samplingRate = 0.33;
3939
samplerArgs.put("initialSamplingRate", String.valueOf(samplingRate));
4040
when(mockConfig.getMap(JaegerRemoteSamplerProvider.SAMPLER_ARG_PROPERTY))

0 commit comments

Comments
 (0)