Skip to content

Commit

Permalink
Configure Wavefront flush interval in milliseconds
Browse files Browse the repository at this point in the history
This will allow step interval values at a finer granularity than whole seconds.

Resolves #2175
  • Loading branch information
shakuzen committed Jul 3, 2020
1 parent 7eaeb78 commit 4d7dc4f
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -326,7 +326,7 @@ static String getWavefrontReportingUri(WavefrontConfig wavefrontConfig) {
public static WavefrontClient.Builder getDefaultSenderBuilder(WavefrontConfig config) {
return new WavefrontClient.Builder(getWavefrontReportingUri(config),
config.apiToken()).batchSize(config.batchSize())
.flushIntervalSeconds((int) config.step().getSeconds());
.flushInterval((int) config.step().toMillis(), TimeUnit.MILLISECONDS);
}

public static Builder builder(WavefrontConfig config) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.concurrent.TimeUnit;

import static org.assertj.core.api.Assertions.*;
import static org.mockito.Mockito.*;
Expand Down Expand Up @@ -135,7 +136,8 @@ void publishDistribution() throws IOException {
@Issue("#2173")
void defaultStepConfigAffectsWavefrontBuilder() {
WavefrontClient.Builder defaultSenderBuilder = WavefrontMeterRegistry.getDefaultSenderBuilder(config);
assertThat(defaultSenderBuilder).hasFieldOrPropertyWithValue("flushIntervalSeconds", 60);
assertThat(defaultSenderBuilder).hasFieldOrPropertyWithValue("flushInterval", 60_000L);
assertThat(defaultSenderBuilder).hasFieldOrPropertyWithValue("flushIntervalTimeUnit", TimeUnit.MILLISECONDS);
}

@Test
Expand Down Expand Up @@ -168,7 +170,8 @@ public Duration step() {
};
WavefrontClient.Builder builder = WavefrontMeterRegistry.getDefaultSenderBuilder(customConfig);
WavefrontClient sender = builder.build();
assertThat(builder).hasFieldOrPropertyWithValue("flushIntervalSeconds", 15);
assertThat(builder).hasFieldOrPropertyWithValue("flushInterval", 15_000L);
assertThat(builder).hasFieldOrPropertyWithValue("flushIntervalTimeUnit", TimeUnit.MILLISECONDS);
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 4d7dc4f

Please sign in to comment.