Skip to content

Commit 51885c9

Browse files
committed
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
1 parent 8eb8d3f commit 51885c9

File tree

3 files changed

+4
-58
lines changed

3 files changed

+4
-58
lines changed

spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/metrics/export/otlp/OtlpMetricsProperties.java

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@
2424

2525
import org.springframework.boot.actuate.autoconfigure.metrics.export.properties.StepRegistryProperties;
2626
import org.springframework.boot.context.properties.ConfigurationProperties;
27-
import org.springframework.boot.context.properties.DeprecatedConfigurationProperty;
2827

2928
/**
3029
* {@link ConfigurationProperties @ConfigurationProperties} for configuring OTLP metrics
@@ -48,11 +47,6 @@ public class OtlpMetricsProperties extends StepRegistryProperties {
4847
*/
4948
private AggregationTemporality aggregationTemporality = AggregationTemporality.CUMULATIVE;
5049

51-
/**
52-
* Monitored resource's attributes.
53-
*/
54-
private Map<String, String> resourceAttributes;
55-
5650
/**
5751
* Headers for the exported metrics.
5852
*/
@@ -95,17 +89,6 @@ public void setAggregationTemporality(AggregationTemporality aggregationTemporal
9589
this.aggregationTemporality = aggregationTemporality;
9690
}
9791

98-
@Deprecated(since = "3.2.0", forRemoval = true)
99-
@DeprecatedConfigurationProperty(replacement = "management.opentelemetry.resource-attributes", since = "3.2.0")
100-
public Map<String, String> getResourceAttributes() {
101-
return this.resourceAttributes;
102-
}
103-
104-
@Deprecated(since = "3.2.0", forRemoval = true)
105-
public void setResourceAttributes(Map<String, String> resourceAttributes) {
106-
this.resourceAttributes = resourceAttributes;
107-
}
108-
10992
public Map<String, String> getHeaders() {
11093
return this.headers;
11194
}

spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/metrics/export/otlp/OtlpMetricsPropertiesConfigAdapter.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,11 +77,10 @@ public AggregationTemporality aggregationTemporality() {
7777
}
7878

7979
@Override
80-
@SuppressWarnings("removal")
8180
public Map<String, String> resourceAttributes() {
8281
Map<String, String> resourceAttributes = this.openTelemetryProperties.getResourceAttributes();
8382
Map<String, String> result = new HashMap<>((!CollectionUtils.isEmpty(resourceAttributes)) ? resourceAttributes
84-
: get(OtlpMetricsProperties::getResourceAttributes, OtlpConfig.super::resourceAttributes));
83+
: OtlpConfig.super.resourceAttributes());
8584
result.computeIfAbsent("service.name", (key) -> getApplicationName());
8685
result.computeIfAbsent("service.group", (key) -> getApplicationGroup());
8786
return Collections.unmodifiableMap(result);

spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/metrics/export/otlp/OtlpMetricsPropertiesConfigAdapterTests.java

Lines changed: 3 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2012-2024 the original author or authors.
2+
* Copyright 2012-2025 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -16,7 +16,6 @@
1616

1717
package org.springframework.boot.actuate.autoconfigure.metrics.export.otlp;
1818

19-
import java.util.Collections;
2019
import java.util.Map;
2120
import java.util.concurrent.TimeUnit;
2221

@@ -30,7 +29,6 @@
3029
import org.springframework.mock.env.MockEnvironment;
3130

3231
import static org.assertj.core.api.Assertions.assertThat;
33-
import static org.assertj.core.api.Assertions.entry;
3432

3533
/**
3634
* Tests for {@link OtlpMetricsPropertiesConfigAdapter}.
@@ -74,9 +72,8 @@ void whenPropertiesAggregationTemporalityIsSetAdapterAggregationTemporalityRetur
7472
}
7573

7674
@Test
77-
@SuppressWarnings("removal")
78-
void whenPropertiesResourceAttributesIsSetAdapterResourceAttributesReturnsIt() {
79-
this.properties.setResourceAttributes(Map.of("service.name", "boot-service"));
75+
void whenOpenTelemetryPropertiesResourceAttributesIsSetAdapterResourceAttributesReturnsIt() {
76+
this.openTelemetryProperties.setResourceAttributes(Map.of("service.name", "boot-service"));
8077
assertThat(createAdapter().resourceAttributes()).containsEntry("service.name", "boot-service");
8178
}
8279

@@ -131,32 +128,7 @@ void whenPropertiesBaseTimeUnitIsSetAdapterBaseTimeUnitReturnsIt() {
131128
}
132129

133130
@Test
134-
@SuppressWarnings("removal")
135-
void openTelemetryPropertiesShouldOverrideOtlpPropertiesIfNotEmpty() {
136-
this.properties.setResourceAttributes(Map.of("a", "alpha"));
137-
this.openTelemetryProperties.setResourceAttributes(Map.of("b", "beta"));
138-
assertThat(createAdapter().resourceAttributes()).contains(entry("b", "beta"));
139-
assertThat(createAdapter().resourceAttributes()).doesNotContain(entry("a", "alpha"));
140-
}
141-
142-
@Test
143-
@SuppressWarnings("removal")
144-
void openTelemetryPropertiesShouldNotOverrideOtlpPropertiesIfEmpty() {
145-
this.properties.setResourceAttributes(Map.of("a", "alpha"));
146-
this.openTelemetryProperties.setResourceAttributes(Collections.emptyMap());
147-
assertThat(createAdapter().resourceAttributes()).contains(entry("a", "alpha"));
148-
}
149-
150-
@Test
151-
@SuppressWarnings("removal")
152131
void serviceNameOverridesApplicationName() {
153-
this.environment.setProperty("spring.application.name", "alpha");
154-
this.properties.setResourceAttributes(Map.of("service.name", "beta"));
155-
assertThat(createAdapter().resourceAttributes()).containsEntry("service.name", "beta");
156-
}
157-
158-
@Test
159-
void serviceNameOverridesApplicationNameWhenUsingOtelProperties() {
160132
this.environment.setProperty("spring.application.name", "alpha");
161133
this.openTelemetryProperties.setResourceAttributes(Map.of("service.name", "beta"));
162134
assertThat(createAdapter().resourceAttributes()).containsEntry("service.name", "beta");
@@ -174,15 +146,7 @@ void shouldUseDefaultApplicationNameIfApplicationNameIsNotSet() {
174146
}
175147

176148
@Test
177-
@SuppressWarnings("removal")
178149
void serviceGroupOverridesApplicationGroup() {
179-
this.environment.setProperty("spring.application.group", "alpha");
180-
this.properties.setResourceAttributes(Map.of("service.group", "beta"));
181-
assertThat(createAdapter().resourceAttributes()).containsEntry("service.group", "beta");
182-
}
183-
184-
@Test
185-
void serviceGroupOverridesApplicationGroupWhenUsingOtelProperties() {
186150
this.environment.setProperty("spring.application.group", "alpha");
187151
this.openTelemetryProperties.setResourceAttributes(Map.of("service.group", "beta"));
188152
assertThat(createAdapter().resourceAttributes()).containsEntry("service.group", "beta");

0 commit comments

Comments
 (0)