Skip to content

Commit

Permalink
Merge branch '1.5.x'
Browse files Browse the repository at this point in the history
  • Loading branch information
shakuzen committed Jul 3, 2020
2 parents e89c110 + a44c720 commit 7eaeb78
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -325,7 +325,8 @@ static String getWavefrontReportingUri(WavefrontConfig wavefrontConfig) {
*/
public static WavefrontClient.Builder getDefaultSenderBuilder(WavefrontConfig config) {
return new WavefrontClient.Builder(getWavefrontReportingUri(config),
config.apiToken()).batchSize(config.batchSize());
config.apiToken()).batchSize(config.batchSize())
.flushIntervalSeconds((int) config.step().getSeconds());
}

public static Builder builder(WavefrontConfig config) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import com.wavefront.sdk.common.clients.WavefrontClient;
import com.wavefront.sdk.entities.histograms.HistogramGranularity;
import com.wavefront.sdk.entities.histograms.WavefrontHistogramImpl;
import io.micrometer.core.Issue;
import io.micrometer.core.instrument.Measurement;
import io.micrometer.core.instrument.Meter;
import io.micrometer.core.instrument.MockClock;
Expand All @@ -29,6 +30,7 @@

import java.io.IOException;
import java.net.URI;
import java.time.Duration;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
Expand Down Expand Up @@ -129,6 +131,13 @@ void publishDistribution() throws IOException {
verifyNoMoreInteractions(wavefrontSender);
}

@Test
@Issue("#2173")
void defaultStepConfigAffectsWavefrontBuilder() {
WavefrontClient.Builder defaultSenderBuilder = WavefrontMeterRegistry.getDefaultSenderBuilder(config);
assertThat(defaultSenderBuilder).hasFieldOrPropertyWithValue("flushIntervalSeconds", 60);
}

@Test
void configureDefaultSenderWithCustomConfig() {
WavefrontConfig customConfig = new WavefrontConfig() {
Expand All @@ -151,8 +160,15 @@ public String apiToken() {
public int batchSize() {
return 20;
}

@Override
public Duration step() {
return Duration.ofSeconds(15);
}
};
WavefrontClient sender = WavefrontMeterRegistry.getDefaultSenderBuilder(customConfig).build();
WavefrontClient.Builder builder = WavefrontMeterRegistry.getDefaultSenderBuilder(customConfig);
WavefrontClient sender = builder.build();
assertThat(builder).hasFieldOrPropertyWithValue("flushIntervalSeconds", 15);
assertThat(sender).extracting("reportingService").hasFieldOrPropertyWithValue("uri", URI.create("https://example.com"));
assertThat(sender).extracting("reportingService").hasFieldOrPropertyWithValue("token", "apiToken");
assertThat(sender).hasFieldOrPropertyWithValue("batchSize", 20);
Expand Down

0 comments on commit 7eaeb78

Please sign in to comment.