Add missing management.metrics.export.signalfx properties

Closes gh-36497
pull/36620/head
Andy Wilkinson 1 year ago
parent 4d708641b3
commit a6c19dae07

@ -1,5 +1,5 @@
/* /*
* Copyright 2012-2019 the original author or authors. * Copyright 2012-2023 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -54,6 +54,11 @@ public class SignalFxProperties extends StepRegistryProperties {
*/ */
private String source; private String source;
/**
* Type of histogram to publish.
*/
private HistogramType publishedHistogramType = HistogramType.DEFAULT;
@Override @Override
public Duration getStep() { public Duration getStep() {
return this.step; return this.step;
@ -88,4 +93,26 @@ public class SignalFxProperties extends StepRegistryProperties {
this.source = source; this.source = source;
} }
public HistogramType getPublishedHistogramType() {
return this.publishedHistogramType;
}
public void setPublishedHistogramType(HistogramType publishedHistogramType) {
this.publishedHistogramType = publishedHistogramType;
}
public enum HistogramType {
/**
* Default, time-based histogram.
*/
DEFAULT,
/**
* Cumulative histogram.
*/
CUMULATIVE;
}
} }

@ -1,5 +1,5 @@
/* /*
* Copyright 2012-2020 the original author or authors. * Copyright 2012-2023 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -19,6 +19,7 @@ package org.springframework.boot.actuate.autoconfigure.metrics.export.signalfx;
import io.micrometer.signalfx.SignalFxConfig; import io.micrometer.signalfx.SignalFxConfig;
import org.springframework.boot.actuate.autoconfigure.metrics.export.properties.StepRegistryPropertiesConfigAdapter; import org.springframework.boot.actuate.autoconfigure.metrics.export.properties.StepRegistryPropertiesConfigAdapter;
import org.springframework.boot.actuate.autoconfigure.metrics.export.signalfx.SignalFxProperties.HistogramType;
/** /**
* Adapter to convert {@link SignalFxProperties} to a {@link SignalFxConfig}. * Adapter to convert {@link SignalFxProperties} to a {@link SignalFxConfig}.
@ -54,4 +55,13 @@ public class SignalFxPropertiesConfigAdapter extends StepRegistryPropertiesConfi
return get(SignalFxProperties::getSource, SignalFxConfig.super::source); return get(SignalFxProperties::getSource, SignalFxConfig.super::source);
} }
@Override
public boolean publishCumulativeHistogram() {
return get(this::isPublishCumulativeHistogram, SignalFxConfig.super::publishCumulativeHistogram);
}
private boolean isPublishCumulativeHistogram(SignalFxProperties properties) {
return HistogramType.CUMULATIVE == properties.getPublishedHistogramType();
}
} }

@ -19,6 +19,7 @@ package org.springframework.boot.actuate.autoconfigure.metrics.export.signalfx;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
import org.springframework.boot.actuate.autoconfigure.metrics.export.properties.StepRegistryPropertiesConfigAdapterTests; import org.springframework.boot.actuate.autoconfigure.metrics.export.properties.StepRegistryPropertiesConfigAdapterTests;
import org.springframework.boot.actuate.autoconfigure.metrics.export.signalfx.SignalFxProperties.HistogramType;
import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThat;
@ -62,4 +63,11 @@ class SignalFxPropertiesConfigAdapterTests
assertThat(createConfigAdapter(properties).source()).isEqualTo("DESKTOP-GA5"); assertThat(createConfigAdapter(properties).source()).isEqualTo("DESKTOP-GA5");
} }
@Test
void whenPropertiesPublishHistogramTypeIsCumulativePublishCumulativeHistogramReturnsIt() {
SignalFxProperties properties = createProperties();
properties.setPublishedHistogramType(HistogramType.CUMULATIVE);
assertThat(createConfigAdapter(properties).publishCumulativeHistogram()).isTrue();
}
} }

@ -1,5 +1,5 @@
/* /*
* Copyright 2012-2019 the original author or authors. * Copyright 2012-2023 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -20,6 +20,7 @@ import io.micrometer.signalfx.SignalFxConfig;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
import org.springframework.boot.actuate.autoconfigure.metrics.export.properties.StepRegistryPropertiesTests; import org.springframework.boot.actuate.autoconfigure.metrics.export.properties.StepRegistryPropertiesTests;
import org.springframework.boot.actuate.autoconfigure.metrics.export.signalfx.SignalFxProperties.HistogramType;
import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThat;
@ -38,6 +39,10 @@ class SignalFxPropertiesTests extends StepRegistryPropertiesTests {
// access token is mandatory // access token is mandatory
assertThat(properties.getUri()).isEqualTo(config.uri()); assertThat(properties.getUri()).isEqualTo(config.uri());
// source has no static default value // source has no static default value
// Not publishing cumulative histograms implies that the default histogram type
// should be published.
assertThat(config.publishCumulativeHistogram()).isFalse();
assertThat(properties.getPublishedHistogramType()).isEqualTo(HistogramType.DEFAULT);
} }
} }

Loading…
Cancel
Save