-
Notifications
You must be signed in to change notification settings - Fork 855
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Remove deprecations from autoconfigure module (#3923)
- Loading branch information
Showing
13 changed files
with
164 additions
and
342 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
58 changes: 0 additions & 58 deletions
58
...s/autoconfigure/src/main/java/io/opentelemetry/sdk/autoconfigure/EnvironmentResource.java
This file was deleted.
Oops, something went wrong.
64 changes: 64 additions & 0 deletions
64
...onfigure/src/main/java/io/opentelemetry/sdk/autoconfigure/MeterProviderConfiguration.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
/* | ||
* Copyright The OpenTelemetry Authors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
package io.opentelemetry.sdk.autoconfigure; | ||
|
||
import io.opentelemetry.api.metrics.MeterProvider; | ||
import io.opentelemetry.sdk.autoconfigure.spi.ConfigProperties; | ||
import io.opentelemetry.sdk.autoconfigure.spi.metrics.SdkMeterProviderConfigurer; | ||
import io.opentelemetry.sdk.metrics.SdkMeterProvider; | ||
import io.opentelemetry.sdk.metrics.SdkMeterProviderBuilder; | ||
import io.opentelemetry.sdk.metrics.exemplar.ExemplarFilter; | ||
import io.opentelemetry.sdk.resources.Resource; | ||
import java.util.ServiceLoader; | ||
|
||
final class MeterProviderConfiguration { | ||
|
||
@SuppressWarnings("deprecation") // Allow call to deprecated GlobalMeterProvider until removed | ||
static MeterProvider configureMeterProvider( | ||
Resource resource, ConfigProperties config, ClassLoader serviceClassLoader) { | ||
SdkMeterProviderBuilder meterProviderBuilder = SdkMeterProvider.builder().setResource(resource); | ||
|
||
// Configure default exemplar filters. | ||
String exemplarFilter = config.getString("otel.metrics.exemplar.filter"); | ||
if (exemplarFilter == null) { | ||
exemplarFilter = "with_sampled_trace"; | ||
} | ||
switch (exemplarFilter) { | ||
case "none": | ||
meterProviderBuilder.setExemplarFilter(ExemplarFilter.neverSample()); | ||
break; | ||
case "all": | ||
meterProviderBuilder.setExemplarFilter(ExemplarFilter.alwaysSample()); | ||
break; | ||
case "with_sampled_trace": | ||
default: | ||
meterProviderBuilder.setExemplarFilter(ExemplarFilter.sampleWithTraces()); | ||
break; | ||
} | ||
|
||
for (SdkMeterProviderConfigurer configurer : | ||
ServiceLoader.load(SdkMeterProviderConfigurer.class, serviceClassLoader)) { | ||
configurer.configure(meterProviderBuilder, config); | ||
} | ||
|
||
String exporterName = config.getString("otel.metrics.exporter"); | ||
if (exporterName == null || exporterName.equals("none")) { | ||
// In the event no exporters are configured set a noop exporter | ||
return MeterProvider.noop(); | ||
} | ||
MetricExporterConfiguration.configureExporter( | ||
exporterName, config, serviceClassLoader, meterProviderBuilder); | ||
|
||
SdkMeterProvider meterProvider = meterProviderBuilder.build(); | ||
|
||
// Make sure metrics shut down when JVM shuts down. | ||
Runtime.getRuntime().addShutdownHook(new Thread(meterProvider::close)); | ||
|
||
return meterProvider; | ||
} | ||
|
||
private MeterProviderConfiguration() {} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.