mirror of
https://github.com/spring-projects/spring-boot.git
synced 2024-09-03 04:26:12 +08:00
Merge branch '3.1.x'
Closes gh-36554
This commit is contained in:
commit
346ebbc6f8
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2022 the original author or authors.
|
||||
* Copyright 2012-2023 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (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;
|
||||
|
||||
/**
|
||||
* Type of histogram to publish.
|
||||
*/
|
||||
private HistogramType publishedHistogramType = HistogramType.DEFAULT;
|
||||
|
||||
@Override
|
||||
public Duration getStep() {
|
||||
return this.step;
|
||||
@ -88,4 +93,31 @@ public class SignalFxProperties extends StepRegistryProperties {
|
||||
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,
|
||||
|
||||
/**
|
||||
* Delta histogram.
|
||||
*/
|
||||
DELTA;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2022 the original author or authors.
|
||||
* Copyright 2012-2023 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (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 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}.
|
||||
@ -54,4 +55,22 @@ public class SignalFxPropertiesConfigAdapter extends StepRegistryPropertiesConfi
|
||||
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();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean publishDeltaHistogram() {
|
||||
return get(this::isPublishDeltaHistogram, SignalFxConfig.super::publishDeltaHistogram);
|
||||
}
|
||||
|
||||
private boolean isPublishDeltaHistogram(SignalFxProperties properties) {
|
||||
return HistogramType.DELTA == properties.getPublishedHistogramType();
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -19,6 +19,7 @@ package org.springframework.boot.actuate.autoconfigure.metrics.export.signalfx;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
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;
|
||||
|
||||
@ -62,4 +63,20 @@ class SignalFxPropertiesConfigAdapterTests
|
||||
assertThat(createConfigAdapter(properties).source()).isEqualTo("DESKTOP-GA5");
|
||||
}
|
||||
|
||||
@Test
|
||||
void whenPropertiesPublishHistogramTypeIsCumulativePublishCumulativeHistogramReturnsIt() {
|
||||
SignalFxProperties properties = createProperties();
|
||||
properties.setPublishedHistogramType(HistogramType.CUMULATIVE);
|
||||
assertThat(createConfigAdapter(properties).publishCumulativeHistogram()).isTrue();
|
||||
assertThat(createConfigAdapter(properties).publishDeltaHistogram()).isFalse();
|
||||
}
|
||||
|
||||
@Test
|
||||
void whenPropertiesPublishHistogramTypeIsDeltaPublishDeltaHistogramReturnsIt() {
|
||||
SignalFxProperties properties = createProperties();
|
||||
properties.setPublishedHistogramType(HistogramType.DELTA);
|
||||
assertThat(createConfigAdapter(properties).publishDeltaHistogram()).isTrue();
|
||||
assertThat(createConfigAdapter(properties).publishCumulativeHistogram()).isFalse();
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -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");
|
||||
* 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.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;
|
||||
|
||||
@ -38,6 +39,11 @@ class SignalFxPropertiesTests extends StepRegistryPropertiesTests {
|
||||
// access token is mandatory
|
||||
assertThat(properties.getUri()).isEqualTo(config.uri());
|
||||
// source has no static default value
|
||||
// Not publishing cumulative or delta histograms implies that the default
|
||||
// histogram type should be published.
|
||||
assertThat(config.publishCumulativeHistogram()).isFalse();
|
||||
assertThat(config.publishDeltaHistogram()).isFalse();
|
||||
assertThat(properties.getPublishedHistogramType()).isEqualTo(HistogramType.DEFAULT);
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user