Remove deprecated management.otlp.metrics.export.resource-attributes
It was deprecated in 3.2 and should have been removed in 3.4 so its removal is overdue. Closes gh-44468
This commit is contained in:
@@ -24,7 +24,6 @@ import io.micrometer.registry.otlp.HistogramFlavor;
|
||||
|
||||
import org.springframework.boot.actuate.autoconfigure.metrics.export.properties.StepRegistryProperties;
|
||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
import org.springframework.boot.context.properties.DeprecatedConfigurationProperty;
|
||||
|
||||
/**
|
||||
* {@link ConfigurationProperties @ConfigurationProperties} for configuring OTLP metrics
|
||||
@@ -48,11 +47,6 @@ public class OtlpMetricsProperties extends StepRegistryProperties {
|
||||
*/
|
||||
private AggregationTemporality aggregationTemporality = AggregationTemporality.CUMULATIVE;
|
||||
|
||||
/**
|
||||
* Monitored resource's attributes.
|
||||
*/
|
||||
private Map<String, String> resourceAttributes;
|
||||
|
||||
/**
|
||||
* Headers for the exported metrics.
|
||||
*/
|
||||
@@ -95,17 +89,6 @@ public class OtlpMetricsProperties extends StepRegistryProperties {
|
||||
this.aggregationTemporality = aggregationTemporality;
|
||||
}
|
||||
|
||||
@Deprecated(since = "3.2.0", forRemoval = true)
|
||||
@DeprecatedConfigurationProperty(replacement = "management.opentelemetry.resource-attributes", since = "3.2.0")
|
||||
public Map<String, String> getResourceAttributes() {
|
||||
return this.resourceAttributes;
|
||||
}
|
||||
|
||||
@Deprecated(since = "3.2.0", forRemoval = true)
|
||||
public void setResourceAttributes(Map<String, String> resourceAttributes) {
|
||||
this.resourceAttributes = resourceAttributes;
|
||||
}
|
||||
|
||||
public Map<String, String> getHeaders() {
|
||||
return this.headers;
|
||||
}
|
||||
|
||||
@@ -77,11 +77,10 @@ class OtlpMetricsPropertiesConfigAdapter extends StepRegistryPropertiesConfigAda
|
||||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("removal")
|
||||
public Map<String, String> resourceAttributes() {
|
||||
Map<String, String> resourceAttributes = this.openTelemetryProperties.getResourceAttributes();
|
||||
Map<String, String> result = new HashMap<>((!CollectionUtils.isEmpty(resourceAttributes)) ? resourceAttributes
|
||||
: get(OtlpMetricsProperties::getResourceAttributes, OtlpConfig.super::resourceAttributes));
|
||||
: OtlpConfig.super.resourceAttributes());
|
||||
result.computeIfAbsent("service.name", (key) -> getApplicationName());
|
||||
result.computeIfAbsent("service.group", (key) -> getApplicationGroup());
|
||||
return Collections.unmodifiableMap(result);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2024 the original author or authors.
|
||||
* Copyright 2012-2025 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.
|
||||
@@ -16,7 +16,6 @@
|
||||
|
||||
package org.springframework.boot.actuate.autoconfigure.metrics.export.otlp;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
@@ -30,7 +29,6 @@ import org.springframework.boot.actuate.autoconfigure.opentelemetry.OpenTelemetr
|
||||
import org.springframework.mock.env.MockEnvironment;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.assertj.core.api.Assertions.entry;
|
||||
|
||||
/**
|
||||
* Tests for {@link OtlpMetricsPropertiesConfigAdapter}.
|
||||
@@ -74,9 +72,8 @@ class OtlpMetricsPropertiesConfigAdapterTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
@SuppressWarnings("removal")
|
||||
void whenPropertiesResourceAttributesIsSetAdapterResourceAttributesReturnsIt() {
|
||||
this.properties.setResourceAttributes(Map.of("service.name", "boot-service"));
|
||||
void whenOpenTelemetryPropertiesResourceAttributesIsSetAdapterResourceAttributesReturnsIt() {
|
||||
this.openTelemetryProperties.setResourceAttributes(Map.of("service.name", "boot-service"));
|
||||
assertThat(createAdapter().resourceAttributes()).containsEntry("service.name", "boot-service");
|
||||
}
|
||||
|
||||
@@ -131,32 +128,7 @@ class OtlpMetricsPropertiesConfigAdapterTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
@SuppressWarnings("removal")
|
||||
void openTelemetryPropertiesShouldOverrideOtlpPropertiesIfNotEmpty() {
|
||||
this.properties.setResourceAttributes(Map.of("a", "alpha"));
|
||||
this.openTelemetryProperties.setResourceAttributes(Map.of("b", "beta"));
|
||||
assertThat(createAdapter().resourceAttributes()).contains(entry("b", "beta"));
|
||||
assertThat(createAdapter().resourceAttributes()).doesNotContain(entry("a", "alpha"));
|
||||
}
|
||||
|
||||
@Test
|
||||
@SuppressWarnings("removal")
|
||||
void openTelemetryPropertiesShouldNotOverrideOtlpPropertiesIfEmpty() {
|
||||
this.properties.setResourceAttributes(Map.of("a", "alpha"));
|
||||
this.openTelemetryProperties.setResourceAttributes(Collections.emptyMap());
|
||||
assertThat(createAdapter().resourceAttributes()).contains(entry("a", "alpha"));
|
||||
}
|
||||
|
||||
@Test
|
||||
@SuppressWarnings("removal")
|
||||
void serviceNameOverridesApplicationName() {
|
||||
this.environment.setProperty("spring.application.name", "alpha");
|
||||
this.properties.setResourceAttributes(Map.of("service.name", "beta"));
|
||||
assertThat(createAdapter().resourceAttributes()).containsEntry("service.name", "beta");
|
||||
}
|
||||
|
||||
@Test
|
||||
void serviceNameOverridesApplicationNameWhenUsingOtelProperties() {
|
||||
this.environment.setProperty("spring.application.name", "alpha");
|
||||
this.openTelemetryProperties.setResourceAttributes(Map.of("service.name", "beta"));
|
||||
assertThat(createAdapter().resourceAttributes()).containsEntry("service.name", "beta");
|
||||
@@ -174,15 +146,7 @@ class OtlpMetricsPropertiesConfigAdapterTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
@SuppressWarnings("removal")
|
||||
void serviceGroupOverridesApplicationGroup() {
|
||||
this.environment.setProperty("spring.application.group", "alpha");
|
||||
this.properties.setResourceAttributes(Map.of("service.group", "beta"));
|
||||
assertThat(createAdapter().resourceAttributes()).containsEntry("service.group", "beta");
|
||||
}
|
||||
|
||||
@Test
|
||||
void serviceGroupOverridesApplicationGroupWhenUsingOtelProperties() {
|
||||
this.environment.setProperty("spring.application.group", "alpha");
|
||||
this.openTelemetryProperties.setResourceAttributes(Map.of("service.group", "beta"));
|
||||
assertThat(createAdapter().resourceAttributes()).containsEntry("service.group", "beta");
|
||||
|
||||
Reference in New Issue
Block a user