Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

change polling interval property name to match spec #6672

Merged
merged 4 commits into from
Sep 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,21 @@
import io.opentelemetry.sdk.trace.samplers.Sampler;
import java.util.Map;
import java.util.concurrent.TimeUnit;
import java.util.logging.Level;
import java.util.logging.Logger;

public class JaegerRemoteSamplerProvider implements ConfigurableSamplerProvider {

private static final Logger LOGGER =
Logger.getLogger(JaegerRemoteSamplerProvider.class.getName());

// visible for testing
static final String ATTRIBUTE_PROPERTY = "otel.resource.attributes";
static final String SERVICE_NAME_PROPERTY = "otel.service.name";
static final String SAMPLER_ARG_PROPERTY = "otel.traces.sampler.arg";
static final String RESOURCE_ATTRIBUTE_SERVICE_NAME_PROPERTY = "service.name";
private static final String ENDPOINT_KEY = "endpoint";
private static final String POLLING_INTERVAL = "pollingInterval";
private static final String POLLING_INTERVAL = "pollingIntervalMs";
jack-berg marked this conversation as resolved.
Show resolved Hide resolved
private static final String INITIAL_SAMPLING_RATE = "initialSamplingRate";

@Override
Expand All @@ -43,9 +48,23 @@
builder.setEndpoint(endpoint);
}
String pollingInterval = params.get(POLLING_INTERVAL);
// Previously, we mistakenly read from pollingInterval. For backwards compatibility, check
// pollingInterval and log warning if set.
if (pollingInterval == null) {
pollingInterval = params.get("pollingInterval");
if (pollingInterval != null) {
LOGGER.log(

Check warning on line 56 in sdk-extensions/jaeger-remote-sampler/src/main/java/io/opentelemetry/sdk/extension/trace/jaeger/sampler/JaegerRemoteSamplerProvider.java

View check run for this annotation

Codecov / codecov/patch

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

Added line #L56 was not covered by tests
Level.WARNING,
SAMPLER_ARG_PROPERTY
+ " contains deprecated \"pollingInterval\" property. Please use \""
+ POLLING_INTERVAL
+ "\" instead.");
}
}
if (pollingInterval != null) {
builder.setPollingInterval(Integer.valueOf(pollingInterval), TimeUnit.MILLISECONDS);
}

String initialSamplingRate = params.get(INITIAL_SAMPLING_RATE);
if (initialSamplingRate != null) {
builder.setInitialSampler(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ void serviceProvider() {
.thenReturn("test_service");
HashMap<String, String> samplerArgs = new HashMap<>();
samplerArgs.put("endpoint", "http://localhost:9999");
samplerArgs.put("pollingInterval", "99");
samplerArgs.put("pollingIntervalMs", "99");
double samplingRate = 0.33;
samplerArgs.put("initialSamplingRate", String.valueOf(samplingRate));
when(mockConfig.getMap(JaegerRemoteSamplerProvider.SAMPLER_ARG_PROPERTY))
Expand Down
Loading