Skip to content
Draft
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 @@ -235,4 +235,45 @@ void create_SpiExporter_Valid() {
assertThat(((SamplerComponentProvider.TestSampler) sampler).config.getString("key1"))
.isEqualTo("value1");
}

@Test
void create_JaegerRemote_interval() {
Sampler sampler =
SamplerFactory.getInstance()
.create(
new SamplerModel()
.withJaegerRemoteDevelopment(
new ExperimentalJaegerRemoteSamplerModel()
.withEndpoint("http://jaeger-remote-endpoint")
.withInterval(10_000)
.withInitialSampler(
new SamplerModel().withAlwaysOff(new AlwaysOffSamplerModel()))),
context);
cleanup.addCloseable(sampler);

assertThat(sampler)
.isInstanceOf(JaegerRemoteSampler.class)
.extracting("pollingIntervalMs")
.isEqualTo(10_000);
}

@Test
void create_JaegerRemote_intervalDefault() {
Sampler sampler =
SamplerFactory.getInstance()
.create(
new SamplerModel()
.withJaegerRemoteDevelopment(
new ExperimentalJaegerRemoteSamplerModel()
.withEndpoint("http://jaeger-remote-endpoint")
.withInitialSampler(
new SamplerModel().withAlwaysOff(new AlwaysOffSamplerModel()))),
context);
cleanup.addCloseable(sampler);

assertThat(sampler)
.isInstanceOf(JaegerRemoteSampler.class)
.extracting("pollingIntervalMs")
.isEqualTo(60_000);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ public final class JaegerRemoteSampler implements Sampler {
private static final String TYPE = "remoteSampling";

private final String serviceName;
private final int pollingIntervalMs;
private final ScheduledExecutorService pollExecutor;
private final ScheduledFuture<?> pollFuture;

Expand All @@ -52,6 +53,7 @@ public final class JaegerRemoteSampler implements Sampler {
int pollingIntervalMs,
Sampler initialSampler) {
this.serviceName = serviceName != null ? serviceName : "";
this.pollingIntervalMs = pollingIntervalMs;
this.grpcSender = grpcSender;
this.sampler = initialSampler;
pollExecutor = Executors.newScheduledThreadPool(1, new DaemonThreadFactory(WORKER_THREAD_NAME));
Expand Down Expand Up @@ -174,6 +176,11 @@ Sampler getSampler() {
return this.sampler;
}

// Visible for testing
int getPollingIntervalMs() {
return this.pollingIntervalMs;
}

public static JaegerRemoteSamplerBuilder builder() {
return new JaegerRemoteSamplerBuilder();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public Sampler create(DeclarativeConfigProperties config) {
}
builder.setInitialSampler(DeclarativeConfiguration.createSampler(initialSamplerModel));

Long pollingIntervalMs = config.getLong("internal");
Long pollingIntervalMs = config.getLong("interval");
if (pollingIntervalMs != null) {
builder.setPollingInterval(Duration.ofMillis(pollingIntervalMs));
}
Expand Down
Loading