Rename OtlpProperties to OtlpMetricsProperties
See gh-41460
This commit is contained in:
parent
9ef82dc864
commit
fdcc8d9d1f
|
@ -50,12 +50,12 @@ import org.springframework.core.task.VirtualThreadTaskExecutor;
|
||||||
@ConditionalOnBean(Clock.class)
|
@ConditionalOnBean(Clock.class)
|
||||||
@ConditionalOnClass(OtlpMeterRegistry.class)
|
@ConditionalOnClass(OtlpMeterRegistry.class)
|
||||||
@ConditionalOnEnabledMetricsExport("otlp")
|
@ConditionalOnEnabledMetricsExport("otlp")
|
||||||
@EnableConfigurationProperties({ OtlpProperties.class, OpenTelemetryProperties.class })
|
@EnableConfigurationProperties({ OtlpMetricsProperties.class, OpenTelemetryProperties.class })
|
||||||
public class OtlpMetricsExportAutoConfiguration {
|
public class OtlpMetricsExportAutoConfiguration {
|
||||||
|
|
||||||
private final OtlpProperties properties;
|
private final OtlpMetricsProperties properties;
|
||||||
|
|
||||||
OtlpMetricsExportAutoConfiguration(OtlpProperties properties) {
|
OtlpMetricsExportAutoConfiguration(OtlpMetricsProperties properties) {
|
||||||
this.properties = properties;
|
this.properties = properties;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -69,7 +69,7 @@ public class OtlpMetricsExportAutoConfiguration {
|
||||||
@ConditionalOnMissingBean
|
@ConditionalOnMissingBean
|
||||||
OtlpConfig otlpConfig(OpenTelemetryProperties openTelemetryProperties,
|
OtlpConfig otlpConfig(OpenTelemetryProperties openTelemetryProperties,
|
||||||
OtlpMetricsConnectionDetails connectionDetails, Environment environment) {
|
OtlpMetricsConnectionDetails connectionDetails, Environment environment) {
|
||||||
return new OtlpPropertiesConfigAdapter(this.properties, openTelemetryProperties, connectionDetails,
|
return new OtlpMetricsPropertiesConfigAdapter(this.properties, openTelemetryProperties, connectionDetails,
|
||||||
environment);
|
environment);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -89,13 +89,13 @@ public class OtlpMetricsExportAutoConfiguration {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Adapts {@link OtlpProperties} to {@link OtlpMetricsConnectionDetails}.
|
* Adapts {@link OtlpMetricsProperties} to {@link OtlpMetricsConnectionDetails}.
|
||||||
*/
|
*/
|
||||||
static class PropertiesOtlpMetricsConnectionDetails implements OtlpMetricsConnectionDetails {
|
static class PropertiesOtlpMetricsConnectionDetails implements OtlpMetricsConnectionDetails {
|
||||||
|
|
||||||
private final OtlpProperties properties;
|
private final OtlpMetricsProperties properties;
|
||||||
|
|
||||||
PropertiesOtlpMetricsConnectionDetails(OtlpProperties properties) {
|
PropertiesOtlpMetricsConnectionDetails(OtlpMetricsProperties properties) {
|
||||||
this.properties = properties;
|
this.properties = properties;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -35,10 +35,10 @@ import org.springframework.boot.context.properties.DeprecatedConfigurationProper
|
||||||
* @since 3.0.0
|
* @since 3.0.0
|
||||||
*/
|
*/
|
||||||
@ConfigurationProperties(prefix = "management.otlp.metrics.export")
|
@ConfigurationProperties(prefix = "management.otlp.metrics.export")
|
||||||
public class OtlpProperties extends StepRegistryProperties {
|
public class OtlpMetricsProperties extends StepRegistryProperties {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* URI of the OLTP server.
|
* URI of the OTLP server.
|
||||||
*/
|
*/
|
||||||
private String url = "http://localhost:4318/v1/metrics";
|
private String url = "http://localhost:4318/v1/metrics";
|
||||||
|
|
|
@ -32,13 +32,14 @@ import org.springframework.util.CollectionUtils;
|
||||||
import org.springframework.util.StringUtils;
|
import org.springframework.util.StringUtils;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Adapter to convert {@link OtlpProperties} to an {@link OtlpConfig}.
|
* Adapter to convert {@link OtlpMetricsProperties} to an {@link OtlpConfig}.
|
||||||
*
|
*
|
||||||
* @author Eddú Meléndez
|
* @author Eddú Meléndez
|
||||||
* @author Jonatan Ivanov
|
* @author Jonatan Ivanov
|
||||||
* @author Moritz Halbritter
|
* @author Moritz Halbritter
|
||||||
*/
|
*/
|
||||||
class OtlpPropertiesConfigAdapter extends StepRegistryPropertiesConfigAdapter<OtlpProperties> implements OtlpConfig {
|
class OtlpMetricsPropertiesConfigAdapter extends StepRegistryPropertiesConfigAdapter<OtlpMetricsProperties>
|
||||||
|
implements OtlpConfig {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Default value for application name if {@code spring.application.name} is not set.
|
* Default value for application name if {@code spring.application.name} is not set.
|
||||||
|
@ -51,8 +52,9 @@ class OtlpPropertiesConfigAdapter extends StepRegistryPropertiesConfigAdapter<Ot
|
||||||
|
|
||||||
private final Environment environment;
|
private final Environment environment;
|
||||||
|
|
||||||
OtlpPropertiesConfigAdapter(OtlpProperties properties, OpenTelemetryProperties openTelemetryProperties,
|
OtlpMetricsPropertiesConfigAdapter(OtlpMetricsProperties properties,
|
||||||
OtlpMetricsConnectionDetails connectionDetails, Environment environment) {
|
OpenTelemetryProperties openTelemetryProperties, OtlpMetricsConnectionDetails connectionDetails,
|
||||||
|
Environment environment) {
|
||||||
super(properties);
|
super(properties);
|
||||||
this.connectionDetails = connectionDetails;
|
this.connectionDetails = connectionDetails;
|
||||||
this.openTelemetryProperties = openTelemetryProperties;
|
this.openTelemetryProperties = openTelemetryProperties;
|
||||||
|
@ -71,7 +73,7 @@ class OtlpPropertiesConfigAdapter extends StepRegistryPropertiesConfigAdapter<Ot
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public AggregationTemporality aggregationTemporality() {
|
public AggregationTemporality aggregationTemporality() {
|
||||||
return get(OtlpProperties::getAggregationTemporality, OtlpConfig.super::aggregationTemporality);
|
return get(OtlpMetricsProperties::getAggregationTemporality, OtlpConfig.super::aggregationTemporality);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -79,7 +81,7 @@ class OtlpPropertiesConfigAdapter extends StepRegistryPropertiesConfigAdapter<Ot
|
||||||
public Map<String, String> resourceAttributes() {
|
public Map<String, String> resourceAttributes() {
|
||||||
Map<String, String> resourceAttributes = this.openTelemetryProperties.getResourceAttributes();
|
Map<String, String> resourceAttributes = this.openTelemetryProperties.getResourceAttributes();
|
||||||
Map<String, String> result = new HashMap<>((!CollectionUtils.isEmpty(resourceAttributes)) ? resourceAttributes
|
Map<String, String> result = new HashMap<>((!CollectionUtils.isEmpty(resourceAttributes)) ? resourceAttributes
|
||||||
: get(OtlpProperties::getResourceAttributes, OtlpConfig.super::resourceAttributes));
|
: get(OtlpMetricsProperties::getResourceAttributes, OtlpConfig.super::resourceAttributes));
|
||||||
result.computeIfAbsent("service.name", (key) -> getApplicationName());
|
result.computeIfAbsent("service.name", (key) -> getApplicationName());
|
||||||
result.computeIfAbsent("service.group", (key) -> getApplicationGroup());
|
result.computeIfAbsent("service.group", (key) -> getApplicationGroup());
|
||||||
return Collections.unmodifiableMap(result);
|
return Collections.unmodifiableMap(result);
|
||||||
|
@ -96,27 +98,27 @@ class OtlpPropertiesConfigAdapter extends StepRegistryPropertiesConfigAdapter<Ot
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Map<String, String> headers() {
|
public Map<String, String> headers() {
|
||||||
return get(OtlpProperties::getHeaders, OtlpConfig.super::headers);
|
return get(OtlpMetricsProperties::getHeaders, OtlpConfig.super::headers);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public HistogramFlavor histogramFlavor() {
|
public HistogramFlavor histogramFlavor() {
|
||||||
return get(OtlpProperties::getHistogramFlavor, OtlpConfig.super::histogramFlavor);
|
return get(OtlpMetricsProperties::getHistogramFlavor, OtlpConfig.super::histogramFlavor);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int maxScale() {
|
public int maxScale() {
|
||||||
return get(OtlpProperties::getMaxScale, OtlpConfig.super::maxScale);
|
return get(OtlpMetricsProperties::getMaxScale, OtlpConfig.super::maxScale);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int maxBucketCount() {
|
public int maxBucketCount() {
|
||||||
return get(OtlpProperties::getMaxBucketCount, OtlpConfig.super::maxBucketCount);
|
return get(OtlpMetricsProperties::getMaxBucketCount, OtlpConfig.super::maxBucketCount);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public TimeUnit baseTimeUnit() {
|
public TimeUnit baseTimeUnit() {
|
||||||
return get(OtlpProperties::getBaseTimeUnit, OtlpConfig.super::baseTimeUnit);
|
return get(OtlpMetricsProperties::getBaseTimeUnit, OtlpConfig.super::baseTimeUnit);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
|
@ -33,14 +33,14 @@ import static org.assertj.core.api.Assertions.assertThat;
|
||||||
import static org.assertj.core.api.Assertions.entry;
|
import static org.assertj.core.api.Assertions.entry;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Tests for {@link OtlpPropertiesConfigAdapter}.
|
* Tests for {@link OtlpMetricsPropertiesConfigAdapter}.
|
||||||
*
|
*
|
||||||
* @author Eddú Meléndez
|
* @author Eddú Meléndez
|
||||||
* @author Moritz Halbritter
|
* @author Moritz Halbritter
|
||||||
*/
|
*/
|
||||||
class OtlpPropertiesConfigAdapterTests {
|
class OtlpMetricsPropertiesConfigAdapterTests {
|
||||||
|
|
||||||
private OtlpProperties properties;
|
private OtlpMetricsProperties properties;
|
||||||
|
|
||||||
private OpenTelemetryProperties openTelemetryProperties;
|
private OpenTelemetryProperties openTelemetryProperties;
|
||||||
|
|
||||||
|
@ -50,7 +50,7 @@ class OtlpPropertiesConfigAdapterTests {
|
||||||
|
|
||||||
@BeforeEach
|
@BeforeEach
|
||||||
void setUp() {
|
void setUp() {
|
||||||
this.properties = new OtlpProperties();
|
this.properties = new OtlpMetricsProperties();
|
||||||
this.openTelemetryProperties = new OpenTelemetryProperties();
|
this.openTelemetryProperties = new OpenTelemetryProperties();
|
||||||
this.environment = new MockEnvironment();
|
this.environment = new MockEnvironment();
|
||||||
this.connectionDetails = new PropertiesOtlpMetricsConnectionDetails(this.properties);
|
this.connectionDetails = new PropertiesOtlpMetricsConnectionDetails(this.properties);
|
||||||
|
@ -199,9 +199,9 @@ class OtlpPropertiesConfigAdapterTests {
|
||||||
assertThat(createAdapter().resourceAttributes()).doesNotContainKey("service.group");
|
assertThat(createAdapter().resourceAttributes()).doesNotContainKey("service.group");
|
||||||
}
|
}
|
||||||
|
|
||||||
private OtlpPropertiesConfigAdapter createAdapter() {
|
private OtlpMetricsPropertiesConfigAdapter createAdapter() {
|
||||||
return new OtlpPropertiesConfigAdapter(this.properties, this.openTelemetryProperties, this.connectionDetails,
|
return new OtlpMetricsPropertiesConfigAdapter(this.properties, this.openTelemetryProperties,
|
||||||
this.environment);
|
this.connectionDetails, this.environment);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
|
@ -24,15 +24,15 @@ import org.springframework.boot.actuate.autoconfigure.metrics.export.properties.
|
||||||
import static org.assertj.core.api.Assertions.assertThat;
|
import static org.assertj.core.api.Assertions.assertThat;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Tests for {@link OtlpProperties}.
|
* Tests for {@link OtlpMetricsProperties}.
|
||||||
*
|
*
|
||||||
* @author Eddú Meléndez
|
* @author Eddú Meléndez
|
||||||
*/
|
*/
|
||||||
class OtlpPropertiesTests extends StepRegistryPropertiesTests {
|
class OtlpMetricsPropertiesTests extends StepRegistryPropertiesTests {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void defaultValuesAreConsistent() {
|
void defaultValuesAreConsistent() {
|
||||||
OtlpProperties properties = new OtlpProperties();
|
OtlpMetricsProperties properties = new OtlpMetricsProperties();
|
||||||
OtlpConfig config = OtlpConfig.DEFAULT;
|
OtlpConfig config = OtlpConfig.DEFAULT;
|
||||||
assertStepRegistryDefaultValues(properties, config);
|
assertStepRegistryDefaultValues(properties, config);
|
||||||
assertThat(properties.getUrl()).isEqualTo(config.url());
|
assertThat(properties.getUrl()).isEqualTo(config.url());
|
Loading…
Reference in New Issue