Skip to content

Commit

Permalink
Remove code deprecated in 2.x and add since and forRemoval attributes
Browse files Browse the repository at this point in the history
Closes gh-32548
Closes gh-32549
  • Loading branch information
wilkinsona committed Sep 30, 2022
1 parent 03b3a77 commit 51df781
Show file tree
Hide file tree
Showing 52 changed files with 85 additions and 560 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -149,12 +149,13 @@ public static class ClientRequest {
*/
private String metricName = "http.client.requests";

@Deprecated
@Deprecated(since = "3.0.0", forRemoval = true)
@DeprecatedConfigurationProperty(replacement = "management.observations.http.client.requests.name")
public String getMetricName() {
return this.metricName;
}

@Deprecated(since = "3.0.0", forRemoval = true)
public void setMetricName(String metricName) {
this.metricName = metricName;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@

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 Dynatrace
Expand Down Expand Up @@ -56,28 +55,6 @@ public void setApiToken(String apiToken) {
this.apiToken = apiToken;
}

@Deprecated
@DeprecatedConfigurationProperty(replacement = "management.dynatrace.metrics.export.v1.device-id")
public String getDeviceId() {
return this.v1.getDeviceId();
}

@Deprecated
public void setDeviceId(String deviceId) {
this.v1.setDeviceId(deviceId);
}

@Deprecated
@DeprecatedConfigurationProperty(replacement = "management.dynatrace.metrics.export.v1.technology-type")
public String getTechnologyType() {
return this.v1.getTechnologyType();
}

@Deprecated
public void setTechnologyType(String technologyType) {
this.v1.setTechnologyType(technologyType);
}

public String getUri() {
return this.uri;
}
Expand All @@ -86,17 +63,6 @@ public void setUri(String uri) {
this.uri = uri;
}

@Deprecated
@DeprecatedConfigurationProperty(replacement = "management.dynatrace.metrics.export.v1.group")
public String getGroup() {
return this.v1.getGroup();
}

@Deprecated
public void setGroup(String group) {
this.v1.setGroup(group);
}

public V1 getV1() {
return this.v1;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,6 @@
import io.prometheus.client.exemplars.tracer.common.SpanContextSupplier;
import io.prometheus.client.exporter.BasicAuthHttpConnectionFactory;
import io.prometheus.client.exporter.PushGateway;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

import org.springframework.beans.factory.ObjectProvider;
import org.springframework.boot.actuate.autoconfigure.endpoint.condition.ConditionalOnAvailableEndpoint;
Expand All @@ -52,7 +50,6 @@
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.env.Environment;
import org.springframework.core.log.LogMessage;
import org.springframework.util.StringUtils;

/**
Expand Down Expand Up @@ -120,8 +117,6 @@ public PrometheusScrapeEndpoint prometheusEndpoint(CollectorRegistry collectorRe
@ConditionalOnProperty(prefix = "management.prometheus.metrics.export.pushgateway", name = "enabled")
public static class PrometheusPushGatewayConfiguration {

private static final Log logger = LogFactory.getLog(PrometheusPushGatewayConfiguration.class);

/**
* The fallback job name. We use 'spring' since there's a history of Prometheus
* spring integration defaulting to that name from when Prometheus integration
Expand All @@ -132,7 +127,7 @@ public static class PrometheusPushGatewayConfiguration {
@Bean
@ConditionalOnMissingBean
public PrometheusPushGatewayManager prometheusPushGatewayManager(CollectorRegistry collectorRegistry,
PrometheusProperties prometheusProperties, Environment environment) {
PrometheusProperties prometheusProperties, Environment environment) throws MalformedURLException {
PrometheusProperties.Pushgateway properties = prometheusProperties.getPushgateway();
Duration pushRate = properties.getPushRate();
String job = getJob(properties, environment);
Expand All @@ -147,15 +142,8 @@ public PrometheusPushGatewayManager prometheusPushGatewayManager(CollectorRegist
shutdownOperation);
}

private PushGateway initializePushGateway(String url) {
try {
return new PushGateway(new URL(url));
}
catch (MalformedURLException ex) {
logger.warn(LogMessage
.format("Invalid PushGateway base url '%s': update your configuration to a valid URL", url));
return new PushGateway(url);
}
private PushGateway initializePushGateway(String url) throws MalformedURLException {
return new PushGateway(new URL(url));
}

private String getJob(PrometheusProperties.Pushgateway properties, Environment environment) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
*
* @author Brian Clozel
*/
@SuppressWarnings("deprecation")
@SuppressWarnings({ "removal" })
class ClientHttpObservationConventionAdapter implements ClientHttpObservationConvention {

private final String metricName;
Expand All @@ -48,6 +48,7 @@ public boolean supportsContext(Observation.Context context) {
}

@Override
@SuppressWarnings("deprecation")
public KeyValues getLowCardinalityKeyValues(ClientHttpObservationContext context) {
KeyValues keyValues = KeyValues.empty();
Iterable<Tag> tags = this.tagsProvider.getTags(context.getUriTemplate(), context.getCarrier(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
*
* @author Brian Clozel
*/
@SuppressWarnings("deprecation")
@SuppressWarnings({ "deprecation", "removal" })
class ClientObservationConventionAdapter implements ClientObservationConvention {

private static final String URI_TEMPLATE_ATTRIBUTE = WebClient.class.getName() + ".uriTemplate";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ class MeterFilterConfiguration {

@Bean
@Order(0)
@SuppressWarnings("deprecation")
@SuppressWarnings("removal")
MeterFilter metricsHttpClientUriTagFilter(ObservationProperties observationProperties,
MetricsProperties metricsProperties) {
String metricName = metricsProperties.getWeb().getClient().getRequest().getMetricName();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
@Configuration(proxyBeanMethods = false)
@ConditionalOnClass(RestTemplate.class)
@ConditionalOnBean(RestTemplateBuilder.class)
@SuppressWarnings("deprecation")
@SuppressWarnings("removal")
class RestTemplateObservationConfiguration {

@Bean
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
*/
@Configuration(proxyBeanMethods = false)
@ConditionalOnClass(WebClient.class)
@SuppressWarnings("deprecation")
@SuppressWarnings("removal")
class WebClientObservationConfiguration {

@Bean
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ public ModelAndView handle(HttpServletRequest request, HttpServletResponse respo
}

@Override
@Deprecated
@Deprecated(since = "2.4.9", forRemoval = false)
@SuppressWarnings("deprecation")
public long getLastModified(HttpServletRequest request, Object handler) {
Optional<HandlerAdapter> adapter = getAdapter(handler);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ void backsOffWithoutAClock() {
@Test
void failsWithADeviceIdWithoutAUri() {
this.contextRunner.withUserConfiguration(BaseConfiguration.class)
.withPropertyValues("management.dynatrace.metrics.export.device-id:dev-1")
.withPropertyValues("management.dynatrace.metrics.export.v1.device-id:dev-1")
.run((context) -> assertThat(context).hasFailed());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,59 +45,27 @@ void whenPropertiesApiTokenIsSetAdapterApiTokenReturnsIt() {
assertThat(new DynatracePropertiesConfigAdapter(properties).apiToken()).isEqualTo("123ABC");
}

@Test
@Deprecated
void whenPropertiesDeviceIdIsSetAdapterDeviceIdReturnsIt() {
DynatraceProperties properties = new DynatraceProperties();
properties.setDeviceId("dev-1");
assertThat(new DynatracePropertiesConfigAdapter(properties).deviceId()).isEqualTo("dev-1");
}

@Test
void whenPropertiesV1DeviceIdIsSetAdapterDeviceIdReturnsIt() {
DynatraceProperties properties = new DynatraceProperties();
properties.getV1().setDeviceId("dev-1");
assertThat(new DynatracePropertiesConfigAdapter(properties).deviceId()).isEqualTo("dev-1");
}

@Test
@Deprecated
void whenPropertiesTechnologyTypeIsSetAdapterTechnologyTypeReturnsIt() {
DynatraceProperties properties = new DynatraceProperties();
properties.setTechnologyType("tech-1");
assertThat(new DynatracePropertiesConfigAdapter(properties).technologyType()).isEqualTo("tech-1");
}

@Test
void whenPropertiesV1TechnologyTypeIsSetAdapterTechnologyTypeReturnsIt() {
DynatraceProperties properties = new DynatraceProperties();
properties.getV1().setTechnologyType("tech-1");
assertThat(new DynatracePropertiesConfigAdapter(properties).technologyType()).isEqualTo("tech-1");
}

@Test
@Deprecated
void whenPropertiesGroupIsSetAdapterGroupReturnsIt() {
DynatraceProperties properties = new DynatraceProperties();
properties.setGroup("group-1");
assertThat(new DynatracePropertiesConfigAdapter(properties).group()).isEqualTo("group-1");
}

@Test
void whenPropertiesV1GroupIsSetAdapterGroupReturnsIt() {
DynatraceProperties properties = new DynatraceProperties();
properties.getV1().setGroup("group-1");
assertThat(new DynatracePropertiesConfigAdapter(properties).group()).isEqualTo("group-1");
}

@Test
@SuppressWarnings("deprecation")
void whenDeviceIdIsSetThenAdapterApiVersionIsV1() {
DynatraceProperties properties = new DynatraceProperties();
properties.setDeviceId("dev-1");
assertThat(new DynatracePropertiesConfigAdapter(properties).apiVersion()).isSameAs(DynatraceApiVersion.V1);
}

@Test
void whenV1DeviceIdIsSetThenAdapterApiVersionIsV1() {
DynatraceProperties properties = new DynatraceProperties();
Expand Down Expand Up @@ -144,7 +112,6 @@ void whenPropertiesDefaultDimensionsIsSetAdapterDefaultDimensionsReturnsIt() {
}

@Test
@SuppressWarnings("deprecation")
void defaultValues() {
DynatraceProperties properties = new DynatraceProperties();
assertThat(properties.getApiToken()).isNull();
Expand All @@ -156,9 +123,6 @@ void defaultValues() {
assertThat(properties.getV2().isEnrichWithDynatraceMetadata()).isTrue();
assertThat(properties.getV2().getDefaultDimensions()).isNull();
assertThat(properties.getV2().isUseDynatraceSummaryInstruments()).isTrue();
assertThat(properties.getDeviceId()).isNull();
assertThat(properties.getTechnologyType()).isEqualTo("java");
assertThat(properties.getGroup()).isNull();
}

}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2012-2021 the original author or authors.
* Copyright 2012-2022 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.
Expand Down Expand Up @@ -30,13 +30,11 @@
*/
class DynatracePropertiesTests extends StepRegistryPropertiesTests {

@SuppressWarnings("deprecation")
@Test
void defaultValuesAreConsistent() {
DynatraceProperties properties = new DynatraceProperties();
DynatraceConfig config = (key) -> null;
assertStepRegistryDefaultValues(properties, config);
assertThat(properties.getTechnologyType()).isEqualTo(config.technologyType());
assertThat(properties.getV1().getTechnologyType()).isEqualTo(config.technologyType());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -181,18 +181,6 @@ void withPushGatewayNoBasicAuth() {
.isInstanceOf(DefaultHttpConnectionFactory.class)));
}

@Test
@Deprecated
void withCustomLegacyPushGatewayURL(CapturedOutput output) {
this.contextRunner.withConfiguration(AutoConfigurations.of(ManagementContextAutoConfiguration.class))
.withPropertyValues("management.prometheus.metrics.export.pushgateway.enabled=true",
"management.prometheus.metrics.export.pushgateway.base-url=localhost:9090")
.withUserConfiguration(BaseConfiguration.class).run((context) -> {
assertThat(output).contains("Invalid PushGateway base url").contains("localhost:9090");
hasGatewayURL(context, "http://localhost:9090/metrics/");
});
}

@Test
void withCustomPushGatewayURL() {
this.contextRunner.withConfiguration(AutoConfigurations.of(ManagementContextAutoConfiguration.class))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,17 +114,6 @@ void autoConfiguredHikariDataSourceIsInstrumented() {
});
}

@Test
@Deprecated
void autoConfiguredHikariDataSourceIsInstrumentedWhenUsingDeprecatedDataSourceInitialization() {
this.contextRunner.withPropertyValues("spring.datasource.schema:db/create-custom-schema.sql")
.withConfiguration(AutoConfigurations.of(DataSourceAutoConfiguration.class)).run((context) -> {
context.getBean(DataSource.class).getConnection();
MeterRegistry registry = context.getBean(MeterRegistry.class);
registry.get("hikaricp.connections").meter();
});
}

@Test
void autoConfiguredHikariDataSourceIsInstrumentedWhenUsingDataSourceInitialization() {
this.contextRunner.withPropertyValues("spring.sql.init.schema:db/create-custom-schema.sql").withConfiguration(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
*
* @author Brian Clozel
*/
@SuppressWarnings("deprecation")
@SuppressWarnings({ "deprecation", "removal" })
class ClientHttpObservationConventionAdapterTests {

private static final String TEST_METRIC_NAME = "test.metric.name";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@
* @author Brian Clozel
*/
@ExtendWith(OutputCaptureExtension.class)
@SuppressWarnings("deprecation")
@SuppressWarnings({ "deprecation", "removal" })
class RestTemplateObservationConfigurationTests {

private final ApplicationContextRunner contextRunner = new ApplicationContextRunner().with(MetricsRun.simple())
Expand Down Expand Up @@ -161,6 +161,7 @@ CustomTagsProvider customTagsProvider() {

}

@Deprecated(since = "3.0.0", forRemoval = true)
static class CustomTagsProvider implements RestTemplateExchangeTagsProvider {

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,18 +48,6 @@ public class HealthEndpoint extends HealthEndpointSupport<HealthContributor, Hea

private static final String[] EMPTY_PATH = {};

/**
* Create a new {@link HealthEndpoint} instance.
* @param registry the health contributor registry
* @param groups the health endpoint groups
* @deprecated since 2.6.9 for removal in 3.0.0 in favor of
* {@link #HealthEndpoint(HealthContributorRegistry, HealthEndpointGroups, Duration)}
*/
@Deprecated
public HealthEndpoint(HealthContributorRegistry registry, HealthEndpointGroups groups) {
super(registry, groups, null);
}

/**
* Create a new {@link HealthEndpoint} instance.
* @param registry the health contributor registry
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,18 +50,6 @@ public class HealthEndpointWebExtension extends HealthEndpointSupport<HealthCont

private static final String[] NO_PATH = {};

/**
* Create a new {@link HealthEndpointWebExtension} instance.
* @param registry the health contributor registry
* @param groups the health endpoint groups
* @deprecated since 2.6.9 for removal in 3.0.0 in favor of
* {@link #HealthEndpointWebExtension(HealthContributorRegistry, HealthEndpointGroups, Duration)}
*/
@Deprecated
public HealthEndpointWebExtension(HealthContributorRegistry registry, HealthEndpointGroups groups) {
super(registry, groups, null);
}

/**
* Create a new {@link HealthEndpointWebExtension} instance.
* @param registry the health contributor registry
Expand Down
Loading

0 comments on commit 51df781

Please sign in to comment.