Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove deprecated autoconfigure options #5098

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,10 @@
import java.util.Objects;
import java.util.Set;
import java.util.function.BiFunction;
import java.util.logging.Level;
import java.util.logging.Logger;
import java.util.stream.Collectors;

final class MeterProviderConfiguration {
private static final Logger LOGGER = Logger.getLogger(MeterProviderConfiguration.class.getName());

@SuppressWarnings("fallthrough")
static void configureMeterProvider(
SdkMeterProviderBuilder meterProviderBuilder,
ConfigProperties config,
Expand All @@ -38,24 +34,12 @@ static void configureMeterProvider(
String exemplarFilter =
config.getString("otel.metrics.exemplar.filter", "trace_based").toLowerCase(Locale.ROOT);
switch (exemplarFilter) {
case "none": // DEPRECATED: replaced by always_off
LOGGER.log(
Level.WARNING,
"otel.metrics.exemplar.filter option \"none\" is deprecated for removal. Use \"always_off\" instead.");
case "always_off":
SdkMeterProviderUtil.setExemplarFilter(meterProviderBuilder, ExemplarFilter.alwaysOff());
break;
case "all": // DEPRECATED: replaced by always_on
LOGGER.log(
Level.WARNING,
"otel.metrics.exemplar.filter option \"all\" is deprecated for removal. Use \"always_on\" instead.");
case "always_on":
SdkMeterProviderUtil.setExemplarFilter(meterProviderBuilder, ExemplarFilter.alwaysOn());
break;
case "with_sampled_trace": // DEPRECATED: replaced by trace_based
LOGGER.log(
Level.WARNING,
"otel.metrics.exemplar.filter option \"with_sampled_trace\" is deprecated for removal. Use \"trace_based\" instead.");
case "trace_based":
default:
SdkMeterProviderUtil.setExemplarFilter(meterProviderBuilder, ExemplarFilter.traceBased());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.BDDAssertions.as;

import io.opentelemetry.internal.testing.slf4j.SuppressLogger;
import io.opentelemetry.sdk.autoconfigure.spi.internal.DefaultConfigProperties;
import io.opentelemetry.sdk.metrics.SdkMeterProvider;
import io.opentelemetry.sdk.metrics.SdkMeterProviderBuilder;
Expand All @@ -26,8 +25,6 @@
class MeterProviderConfigurationTest {

@Test
// Suppress log warnings for deprecated exemplar filter options
@SuppressLogger(MeterProviderConfiguration.class)
void configureMeterProvider_ConfiguresExemplarFilter() {
assertExemplarFilter(Collections.emptyMap()).isInstanceOf(TraceBasedExemplarFilter.class);
assertExemplarFilter(Collections.singletonMap("otel.metrics.exemplar.filter", "foo"))
Expand All @@ -36,21 +33,14 @@ void configureMeterProvider_ConfiguresExemplarFilter() {
.isInstanceOf(TraceBasedExemplarFilter.class);
assertExemplarFilter(Collections.singletonMap("otel.metrics.exemplar.filter", "Trace_based"))
.isInstanceOf(TraceBasedExemplarFilter.class);
assertExemplarFilter(
Collections.singletonMap("otel.metrics.exemplar.filter", "with_sampled_trace"))
.isInstanceOf(TraceBasedExemplarFilter.class);
assertExemplarFilter(Collections.singletonMap("otel.metrics.exemplar.filter", "always_off"))
.isInstanceOf(AlwaysOffFilter.class);
assertExemplarFilter(Collections.singletonMap("otel.metrics.exemplar.filter", "always_Off"))
.isInstanceOf(AlwaysOffFilter.class);
assertExemplarFilter(Collections.singletonMap("otel.metrics.exemplar.filter", "none"))
.isInstanceOf(AlwaysOffFilter.class);
assertExemplarFilter(Collections.singletonMap("otel.metrics.exemplar.filter", "always_on"))
.isInstanceOf(AlwaysOnFilter.class);
assertExemplarFilter(Collections.singletonMap("otel.metrics.exemplar.filter", "ALWAYS_ON"))
.isInstanceOf(AlwaysOnFilter.class);
assertExemplarFilter(Collections.singletonMap("otel.metrics.exemplar.filter", "all"))
.isInstanceOf(AlwaysOnFilter.class);
}

private static ObjectAssert<ExemplarFilter> assertExemplarFilter(Map<String, String> config) {
Expand Down