Drop deprecations (#4158)
* Drop OBSERVABLE_SUM and OBSERVABLE_UP_DOWN_SUM * Drop SdkMeterProviderConfigurer
This commit is contained in:
parent
6d9cbc3f3d
commit
b9074f1d8b
|
|
@ -296,7 +296,6 @@ public final class AutoConfiguredOpenTelemetrySdkBuilder implements AutoConfigur
|
|||
if (!customized) {
|
||||
customized = true;
|
||||
mergeSdkTracerProviderConfigurer();
|
||||
mergeSdkMeterProviderConfigurer();
|
||||
for (AutoConfigurationCustomizerProvider customizer :
|
||||
ServiceLoader.load(AutoConfigurationCustomizerProvider.class, serviceClassLoader)) {
|
||||
customizer.customize(this);
|
||||
|
|
@ -384,20 +383,6 @@ public final class AutoConfiguredOpenTelemetrySdkBuilder implements AutoConfigur
|
|||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation") // Remove once SdkMeterProviderConfigurer is removed
|
||||
private void mergeSdkMeterProviderConfigurer() {
|
||||
for (io.opentelemetry.sdk.autoconfigure.spi.metrics.SdkMeterProviderConfigurer configurer :
|
||||
ServiceLoader.load(
|
||||
io.opentelemetry.sdk.autoconfigure.spi.metrics.SdkMeterProviderConfigurer.class,
|
||||
serviceClassLoader)) {
|
||||
addMeterProviderCustomizer(
|
||||
(builder, config) -> {
|
||||
configurer.configure(builder, config);
|
||||
return builder;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
private ConfigProperties getConfig() {
|
||||
ConfigProperties config = this.config;
|
||||
if (config == null) {
|
||||
|
|
|
|||
|
|
@ -1,25 +0,0 @@
|
|||
/*
|
||||
* Copyright The OpenTelemetry Authors
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
package io.opentelemetry.sdk.autoconfigure.spi.metrics;
|
||||
|
||||
import io.opentelemetry.sdk.autoconfigure.spi.AutoConfigurationCustomizer;
|
||||
import io.opentelemetry.sdk.autoconfigure.spi.ConfigProperties;
|
||||
import io.opentelemetry.sdk.metrics.SdkMeterProviderBuilder;
|
||||
import java.util.function.BiFunction;
|
||||
|
||||
/**
|
||||
* A service provider interface (SPI) for performing additional programmatic configuration of a
|
||||
* {@link SdkMeterProviderBuilder} during initialization. When using auto-configuration, you should
|
||||
* prefer to use system properties or environment variables for configuration, but this may be
|
||||
* useful to register components that are not part of the SDK such as registering views.
|
||||
*
|
||||
* @deprecated Use {@link AutoConfigurationCustomizer#addMeterProviderCustomizer(BiFunction)}.
|
||||
*/
|
||||
@Deprecated
|
||||
public interface SdkMeterProviderConfigurer {
|
||||
/** Configures the {@link SdkMeterProviderBuilder}. */
|
||||
void configure(SdkMeterProviderBuilder meterProviderBuilder, ConfigProperties config);
|
||||
}
|
||||
|
|
@ -0,0 +1,66 @@
|
|||
/*
|
||||
* Copyright The OpenTelemetry Authors
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
package io.opentelemetry.sdk.autoconfigure;
|
||||
|
||||
import static io.opentelemetry.api.common.AttributeKey.booleanKey;
|
||||
|
||||
import io.opentelemetry.api.common.Attributes;
|
||||
import io.opentelemetry.sdk.autoconfigure.spi.AutoConfigurationCustomizer;
|
||||
import io.opentelemetry.sdk.autoconfigure.spi.AutoConfigurationCustomizerProvider;
|
||||
import io.opentelemetry.sdk.autoconfigure.spi.ConfigProperties;
|
||||
import io.opentelemetry.sdk.common.CompletableResultCode;
|
||||
import io.opentelemetry.sdk.metrics.SdkMeterProviderBuilder;
|
||||
import io.opentelemetry.sdk.metrics.common.InstrumentType;
|
||||
import io.opentelemetry.sdk.metrics.data.MetricData;
|
||||
import io.opentelemetry.sdk.metrics.export.MetricExporter;
|
||||
import io.opentelemetry.sdk.metrics.view.InstrumentSelector;
|
||||
import io.opentelemetry.sdk.metrics.view.View;
|
||||
import java.util.Collection;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class MetricCustomizer implements AutoConfigurationCustomizerProvider {
|
||||
@Override
|
||||
public void customize(AutoConfigurationCustomizer autoConfiguration) {
|
||||
autoConfiguration.addMeterProviderCustomizer(MetricCustomizer::sdkMeterProviderCustomizer);
|
||||
autoConfiguration.addMetricExporterCustomizer(MetricCustomizer::exporterCustomizer);
|
||||
}
|
||||
|
||||
private static SdkMeterProviderBuilder sdkMeterProviderCustomizer(
|
||||
SdkMeterProviderBuilder meterProviderBuilder, ConfigProperties configProperties) {
|
||||
for (InstrumentType instrumentType : InstrumentType.values()) {
|
||||
meterProviderBuilder.registerView(
|
||||
InstrumentSelector.builder().setInstrumentType(instrumentType).build(),
|
||||
View.builder().appendAttributes(Attributes.of(booleanKey("configured"), true)).build());
|
||||
}
|
||||
return meterProviderBuilder;
|
||||
}
|
||||
|
||||
private static MetricExporter exporterCustomizer(
|
||||
MetricExporter delegate, ConfigProperties config) {
|
||||
return new MetricExporter() {
|
||||
@Override
|
||||
public CompletableResultCode export(Collection<MetricData> metrics) {
|
||||
// Note: this is for testing purposes only. If you wish to filter metrics by name
|
||||
// please configure the SdkMeterProvider with the appropriate view.
|
||||
Collection<MetricData> filtered =
|
||||
metrics.stream()
|
||||
.filter(metricData -> metricData.getName().equals("my-metric"))
|
||||
.collect(Collectors.toList());
|
||||
return delegate.export(filtered);
|
||||
}
|
||||
|
||||
@Override
|
||||
public CompletableResultCode flush() {
|
||||
return delegate.flush();
|
||||
}
|
||||
|
||||
@Override
|
||||
public CompletableResultCode shutdown() {
|
||||
return delegate.shutdown();
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
|
@ -1,44 +0,0 @@
|
|||
/*
|
||||
* Copyright The OpenTelemetry Authors
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
package io.opentelemetry.sdk.autoconfigure;
|
||||
|
||||
import io.opentelemetry.sdk.autoconfigure.spi.AutoConfigurationCustomizer;
|
||||
import io.opentelemetry.sdk.autoconfigure.spi.AutoConfigurationCustomizerProvider;
|
||||
import io.opentelemetry.sdk.common.CompletableResultCode;
|
||||
import io.opentelemetry.sdk.metrics.data.MetricData;
|
||||
import io.opentelemetry.sdk.metrics.export.MetricExporter;
|
||||
import java.util.Collection;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class MetricExporterCustomizer implements AutoConfigurationCustomizerProvider {
|
||||
@Override
|
||||
public void customize(AutoConfigurationCustomizer autoConfiguration) {
|
||||
autoConfiguration.addMetricExporterCustomizer(
|
||||
(delegate, config) ->
|
||||
new MetricExporter() {
|
||||
@Override
|
||||
public CompletableResultCode export(Collection<MetricData> metrics) {
|
||||
// Note: this is for testing purposes only. If you wish to filter metrics by name
|
||||
// please configure the SdkMeterProvider with the appropriate view.
|
||||
Collection<MetricData> filtered =
|
||||
metrics.stream()
|
||||
.filter(metricData -> metricData.getName().equals("my-metric"))
|
||||
.collect(Collectors.toList());
|
||||
return delegate.export(filtered);
|
||||
}
|
||||
|
||||
@Override
|
||||
public CompletableResultCode flush() {
|
||||
return delegate.flush();
|
||||
}
|
||||
|
||||
@Override
|
||||
public CompletableResultCode shutdown() {
|
||||
return delegate.shutdown();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
@ -1,29 +0,0 @@
|
|||
/*
|
||||
* Copyright The OpenTelemetry Authors
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
package io.opentelemetry.sdk.autoconfigure;
|
||||
|
||||
import static io.opentelemetry.api.common.AttributeKey.booleanKey;
|
||||
|
||||
import io.opentelemetry.api.common.Attributes;
|
||||
import io.opentelemetry.sdk.autoconfigure.spi.ConfigProperties;
|
||||
import io.opentelemetry.sdk.metrics.SdkMeterProviderBuilder;
|
||||
import io.opentelemetry.sdk.metrics.common.InstrumentType;
|
||||
import io.opentelemetry.sdk.metrics.view.InstrumentSelector;
|
||||
import io.opentelemetry.sdk.metrics.view.View;
|
||||
|
||||
@SuppressWarnings("deprecation") // Remove once SdkMeterProviderConfigurer is removed
|
||||
public class TestMeterProviderConfigurer
|
||||
implements io.opentelemetry.sdk.autoconfigure.spi.metrics.SdkMeterProviderConfigurer {
|
||||
|
||||
@Override
|
||||
public void configure(SdkMeterProviderBuilder meterProviderBuilder, ConfigProperties config) {
|
||||
for (InstrumentType instrumentType : InstrumentType.values()) {
|
||||
meterProviderBuilder.registerView(
|
||||
InstrumentSelector.builder().setInstrumentType(instrumentType).build(),
|
||||
View.builder().appendAttributes(Attributes.of(booleanKey("configured"), true)).build());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,3 +1,3 @@
|
|||
io.opentelemetry.sdk.autoconfigure.SpanExporterCustomizer
|
||||
io.opentelemetry.sdk.autoconfigure.MetricExporterCustomizer
|
||||
io.opentelemetry.sdk.autoconfigure.MetricCustomizer
|
||||
io.opentelemetry.sdk.autoconfigure.LogExporterCustomizer
|
||||
|
|
@ -1 +0,0 @@
|
|||
io.opentelemetry.sdk.autoconfigure.TestMeterProviderConfigurer
|
||||
|
|
@ -6,16 +6,11 @@
|
|||
package io.opentelemetry.sdk.metrics.common;
|
||||
|
||||
/** All instrument types available in the metric package. */
|
||||
@SuppressWarnings("checkstyle")
|
||||
public enum InstrumentType {
|
||||
COUNTER,
|
||||
UP_DOWN_COUNTER,
|
||||
HISTOGRAM,
|
||||
@Deprecated
|
||||
OBSERVABLE_SUM,
|
||||
OBSERVABLE_COUNTER,
|
||||
@Deprecated
|
||||
OBSERVABLE_UP_DOWN_SUM,
|
||||
OBSERVABLE_UP_DOWN_COUNTER,
|
||||
OBSERVABLE_GAUGE,
|
||||
}
|
||||
|
|
|
|||
|
|
@ -26,7 +26,6 @@ final class MetricDataUtils {
|
|||
InstrumentType type = descriptor.getType();
|
||||
return type == InstrumentType.HISTOGRAM
|
||||
|| type == InstrumentType.COUNTER
|
||||
|| type == InstrumentType.OBSERVABLE_SUM
|
||||
|| type == InstrumentType.OBSERVABLE_COUNTER;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -90,10 +90,8 @@ public abstract class MetricDescriptor {
|
|||
/** Returns whether the descriptor describes an async {@link InstrumentType}. */
|
||||
public boolean isAsync() {
|
||||
switch (getSourceInstrument().getType()) {
|
||||
case OBSERVABLE_UP_DOWN_SUM:
|
||||
case OBSERVABLE_UP_DOWN_COUNTER:
|
||||
case OBSERVABLE_GAUGE:
|
||||
case OBSERVABLE_SUM:
|
||||
case OBSERVABLE_COUNTER:
|
||||
return true;
|
||||
case HISTOGRAM:
|
||||
|
|
|
|||
|
|
@ -26,9 +26,7 @@ class DefaultAggregation extends Aggregation {
|
|||
switch (instrument.getType()) {
|
||||
case COUNTER:
|
||||
case UP_DOWN_COUNTER:
|
||||
case OBSERVABLE_SUM:
|
||||
case OBSERVABLE_COUNTER:
|
||||
case OBSERVABLE_UP_DOWN_SUM:
|
||||
case OBSERVABLE_UP_DOWN_COUNTER:
|
||||
return SumAggregation.DEFAULT;
|
||||
case HISTOGRAM:
|
||||
|
|
|
|||
|
|
@ -125,13 +125,10 @@ class MetricDescriptorTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
@SuppressWarnings("deprecation") // Test deprecated code until removed
|
||||
void isAsync() {
|
||||
assertThat(descriptorForInstrument(InstrumentType.OBSERVABLE_UP_DOWN_SUM).isAsync()).isTrue();
|
||||
assertThat(descriptorForInstrument(InstrumentType.OBSERVABLE_UP_DOWN_COUNTER).isAsync())
|
||||
.isTrue();
|
||||
assertThat(descriptorForInstrument(InstrumentType.OBSERVABLE_GAUGE).isAsync()).isTrue();
|
||||
assertThat(descriptorForInstrument(InstrumentType.OBSERVABLE_SUM).isAsync()).isTrue();
|
||||
assertThat(descriptorForInstrument(InstrumentType.OBSERVABLE_COUNTER).isAsync()).isTrue();
|
||||
assertThat(descriptorForInstrument(InstrumentType.HISTOGRAM).isAsync()).isFalse();
|
||||
assertThat(descriptorForInstrument(InstrumentType.COUNTER).isAsync()).isFalse();
|
||||
|
|
|
|||
|
|
@ -188,7 +188,6 @@ class ViewRegistryTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
@SuppressWarnings("deprecation") // Test deprecated code until removed
|
||||
void defaults() {
|
||||
ViewRegistry viewRegistry = ViewRegistry.builder().build();
|
||||
assertThat(
|
||||
|
|
@ -215,14 +214,6 @@ class ViewRegistryTest {
|
|||
.hasSize(1)
|
||||
.element(0)
|
||||
.isSameAs(ViewRegistry.DEFAULT_VIEW);
|
||||
assertThat(
|
||||
viewRegistry.findViews(
|
||||
InstrumentDescriptor.create(
|
||||
"", "", "", InstrumentType.OBSERVABLE_SUM, InstrumentValueType.LONG),
|
||||
INSTRUMENTATION_LIBRARY_INFO))
|
||||
.hasSize(1)
|
||||
.element(0)
|
||||
.isSameAs(ViewRegistry.DEFAULT_VIEW);
|
||||
assertThat(
|
||||
viewRegistry.findViews(
|
||||
InstrumentDescriptor.create(
|
||||
|
|
@ -239,14 +230,6 @@ class ViewRegistryTest {
|
|||
.hasSize(1)
|
||||
.element(0)
|
||||
.isSameAs(ViewRegistry.DEFAULT_VIEW);
|
||||
assertThat(
|
||||
viewRegistry.findViews(
|
||||
InstrumentDescriptor.create(
|
||||
"", "", "", InstrumentType.OBSERVABLE_UP_DOWN_SUM, InstrumentValueType.LONG),
|
||||
INSTRUMENTATION_LIBRARY_INFO))
|
||||
.hasSize(1)
|
||||
.element(0)
|
||||
.isSameAs(ViewRegistry.DEFAULT_VIEW);
|
||||
assertThat(
|
||||
viewRegistry.findViews(
|
||||
InstrumentDescriptor.create(
|
||||
|
|
|
|||
Loading…
Reference in New Issue