Adapt to Wavefront SDK 2.1

Closes gh-20854
pull/20911/head
Stephane Nicoll 5 years ago
parent 9752cd4b8c
commit 62ebe9c006

@ -19,7 +19,7 @@ package org.springframework.boot.actuate.autoconfigure.metrics.export.wavefront;
import java.time.Duration;
import com.wavefront.sdk.common.WavefrontSender;
import com.wavefront.sdk.direct.ingestion.WavefrontDirectIngestionClient.Builder;
import com.wavefront.sdk.common.clients.WavefrontClient.Builder;
import io.micrometer.core.instrument.Clock;
import io.micrometer.wavefront.WavefrontConfig;
import io.micrometer.wavefront.WavefrontMeterRegistry;
@ -89,7 +89,6 @@ public class WavefrontMetricsExportAutoConfiguration {
PropertyMapper mapper = PropertyMapper.get().alwaysApplyingWhenNonNull();
Sender sender = this.properties.getSender();
mapper.from(sender.getMaxQueueSize()).to(builder::maxQueueSize);
mapper.from(sender.getBatchSize()).to(builder::batchSize);
mapper.from(sender.getFlushInterval()).asInt(Duration::getSeconds).to(builder::flushIntervalSeconds);
mapper.from(sender.getMessageSize()).asInt(DataSize::toBytes).to(builder::messageSizeBytes);
return builder.build();

@ -99,8 +99,6 @@ public class WavefrontProperties extends PushRegistryProperties {
private int maxQueueSize = 50000;
private int batchSize = 10000;
private Duration flushInterval = Duration.ofSeconds(1);
private DataSize messageSize = DataSize.ofBytes(Integer.MAX_VALUE);
@ -113,14 +111,6 @@ public class WavefrontProperties extends PushRegistryProperties {
this.maxQueueSize = maxQueueSize;
}
public int getBatchSize() {
return this.batchSize;
}
public void setBatchSize(int batchSize) {
this.batchSize = batchSize;
}
public Duration getFlushInterval() {
return this.flushInterval;
}

@ -20,7 +20,6 @@ import com.wavefront.sdk.common.WavefrontSender;
import io.micrometer.core.instrument.Clock;
import io.micrometer.wavefront.WavefrontConfig;
import io.micrometer.wavefront.WavefrontMeterRegistry;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;
import org.springframework.boot.autoconfigure.AutoConfigurations;
@ -36,6 +35,7 @@ import static org.mockito.Mockito.mock;
* Tests for {@link WavefrontMetricsExportAutoConfiguration}.
*
* @author Jon Schneider
* @author Stephane Nicoll
*/
class WavefrontMetricsExportAutoConfigurationTests {
@ -70,23 +70,36 @@ class WavefrontMetricsExportAutoConfigurationTests {
.hasSingleBean(WavefrontSender.class).hasBean("customConfig"));
}
@Test
void defaultWavefrontSenderSettingsAreConsistent() {
this.contextRunner.withUserConfiguration(BaseConfiguration.class)
.withPropertyValues("management.metrics.export.wavefront.api-token=abcde").run((context) -> {
WavefrontProperties properties = new WavefrontProperties();
WavefrontSender sender = context.getBean(WavefrontSender.class);
assertThat(sender).extracting("metricsBuffer").hasFieldOrPropertyWithValue("capacity",
properties.getSender().getMaxQueueSize());
assertThat(sender).hasFieldOrPropertyWithValue("batchSize", properties.getBatchSize());
assertThat(sender).hasFieldOrPropertyWithValue("messageSizeBytes",
(int) properties.getSender().getMessageSize().toBytes());
});
}
@Test
void configureWavefrontSender() {
this.contextRunner.withUserConfiguration(BaseConfiguration.class)
.withPropertyValues("management.metrics.export.wavefront.api-token=abcde",
"management.metrics.export.wavefront.batch-size=50",
"management.metrics.export.wavefront.sender.max-queue-size=100",
"management.metrics.export.wavefront.sender.batch-size=200",
"management.metrics.export.wavefront.sender.message-size=1KB")
.run((context) -> {
WavefrontSender sender = context.getBean(WavefrontSender.class);
assertThat(sender).hasFieldOrPropertyWithValue("batchSize", 50);
assertThat(sender).extracting("metricsBuffer").hasFieldOrPropertyWithValue("capacity", 100);
assertThat(sender).hasFieldOrPropertyWithValue("batchSize", 200);
assertThat(sender).hasFieldOrPropertyWithValue("messageSizeBytes", 1024);
});
}
@Test
@Disabled("see https://github.com/micrometer-metrics/micrometer/issues/1964")
void allowsWavefrontSenderToBeCustomized() {
this.contextRunner.withUserConfiguration(CustomSenderConfiguration.class)
.run((context) -> assertThat(context).hasSingleBean(Clock.class)

Loading…
Cancel
Save