Search in sources :

Example 1 with WavefrontSender

use of com.wavefront.sdk.common.WavefrontSender in project spring-boot by spring-projects.

the class WavefrontMetricsExportAutoConfigurationTests method configureWavefrontSender.

@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.message-size=1KB").run((context) -> {
        WavefrontSender sender = context.getBean(WavefrontSender.class);
        assertThat(sender).hasFieldOrPropertyWithValue("batchSize", 50);
        assertThat(sender).extracting("metricsBuffer", as(InstanceOfAssertFactories.type(LinkedBlockingQueue.class))).satisfies((queue) -> assertThat(queue.remainingCapacity() + queue.size()).isEqualTo(100));
        assertThat(sender).hasFieldOrPropertyWithValue("messageSizeBytes", 1024);
    });
}
Also used : WavefrontSender(com.wavefront.sdk.common.WavefrontSender) LinkedBlockingQueue(java.util.concurrent.LinkedBlockingQueue) Test(org.junit.jupiter.api.Test)

Example 2 with WavefrontSender

use of com.wavefront.sdk.common.WavefrontSender in project spring-boot by spring-projects.

the class WavefrontMetricsExportAutoConfigurationTests method defaultWavefrontSenderSettingsAreConsistent.

@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", as(InstanceOfAssertFactories.type(LinkedBlockingQueue.class))).satisfies((queue) -> assertThat(queue.remainingCapacity() + queue.size()).isEqualTo(properties.getSender().getMaxQueueSize()));
        assertThat(sender).hasFieldOrPropertyWithValue("batchSize", properties.getBatchSize());
        assertThat(sender).hasFieldOrPropertyWithValue("messageSizeBytes", (int) properties.getSender().getMessageSize().toBytes());
    });
}
Also used : WavefrontSender(com.wavefront.sdk.common.WavefrontSender) LinkedBlockingQueue(java.util.concurrent.LinkedBlockingQueue) Test(org.junit.jupiter.api.Test)

Example 3 with WavefrontSender

use of com.wavefront.sdk.common.WavefrontSender in project spring-boot by spring-projects.

the class WavefrontMetricsExportAutoConfiguration method createWavefrontSender.

private WavefrontSender createWavefrontSender(WavefrontConfig wavefrontConfig) {
    Builder builder = WavefrontMeterRegistry.getDefaultSenderBuilder(wavefrontConfig);
    PropertyMapper mapper = PropertyMapper.get().alwaysApplyingWhenNonNull();
    Sender sender = this.properties.getSender();
    mapper.from(sender.getMaxQueueSize()).to(builder::maxQueueSize);
    mapper.from(sender.getFlushInterval()).asInt(Duration::getSeconds).to(builder::flushIntervalSeconds);
    mapper.from(sender.getMessageSize()).asInt(DataSize::toBytes).to(builder::messageSizeBytes);
    return builder.build();
}
Also used : WavefrontSender(com.wavefront.sdk.common.WavefrontSender) Sender(org.springframework.boot.actuate.autoconfigure.metrics.export.wavefront.WavefrontProperties.Sender) Builder(com.wavefront.sdk.common.clients.WavefrontClient.Builder) PropertyMapper(org.springframework.boot.context.properties.PropertyMapper)

Aggregations

WavefrontSender (com.wavefront.sdk.common.WavefrontSender)3 LinkedBlockingQueue (java.util.concurrent.LinkedBlockingQueue)2 Test (org.junit.jupiter.api.Test)2 Builder (com.wavefront.sdk.common.clients.WavefrontClient.Builder)1 Sender (org.springframework.boot.actuate.autoconfigure.metrics.export.wavefront.WavefrontProperties.Sender)1 PropertyMapper (org.springframework.boot.context.properties.PropertyMapper)1