Skip to content
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 @@ -26,8 +26,6 @@
import java.util.Map;
import java.util.Set;
import java.util.function.BiFunction;
import java.util.logging.Level;
import java.util.logging.Logger;

/**
* Auto-configuration for the OpenTelemetry {@link Resource}.
Expand All @@ -36,8 +34,6 @@
*/
public final class ResourceConfiguration {

private static final Logger logger = Logger.getLogger(ResourceConfiguration.class.getName());

private static final AttributeKey<String> SERVICE_NAME = AttributeKey.stringKey("service.name");

// Visible for testing
Expand All @@ -47,11 +43,6 @@ public final class ResourceConfiguration {
static final String ENABLED_RESOURCE_PROVIDERS = "otel.java.enabled.resource.providers";
static final String DISABLED_RESOURCE_PROVIDERS = "otel.java.disabled.resource.providers";

private static final String OLD_ENVIRONMENT_DETECTOR_FQCN =
"io.opentelemetry.sdk.autoconfigure.internal.EnvironmentResourceProvider";
private static final String NEW_ENVIRONMENT_DETECT_FQCN =
EnvironmentResourceProvider.class.getName();

/**
* Create a {@link Resource} from the environment. The resource contains attributes parsed from
* environment variables and system property keys {@code otel.resource.attributes} and {@code
Expand Down Expand Up @@ -104,32 +95,7 @@ static Resource configureResource(
Resource result = Resource.getDefault();

Set<String> enabledProviders = new HashSet<>(config.getList(ENABLED_RESOURCE_PROVIDERS));
if (enabledProviders.remove(OLD_ENVIRONMENT_DETECTOR_FQCN)) {
logger.log(
Level.WARNING,
"Found reference to "
+ OLD_ENVIRONMENT_DETECTOR_FQCN
+ " in "
+ ENABLED_RESOURCE_PROVIDERS
+ ". Please update to "
+ NEW_ENVIRONMENT_DETECT_FQCN
+ ". Support for the old provider name will be removed after 1.49.0.");
enabledProviders.add(NEW_ENVIRONMENT_DETECT_FQCN);
}

Set<String> disabledProviders = new HashSet<>(config.getList(DISABLED_RESOURCE_PROVIDERS));
if (disabledProviders.remove(OLD_ENVIRONMENT_DETECTOR_FQCN)) {
logger.log(
Level.WARNING,
"Found reference to "
+ OLD_ENVIRONMENT_DETECTOR_FQCN
+ " in "
+ DISABLED_RESOURCE_PROVIDERS
+ ". Please update to "
+ NEW_ENVIRONMENT_DETECT_FQCN
+ ". Support for the old provider name will be removed after 1.49.0.");
disabledProviders.add(NEW_ENVIRONMENT_DETECT_FQCN);
}

for (ResourceProvider resourceProvider : spiHelper.loadOrdered(ResourceProvider.class)) {
if (!enabledProviders.isEmpty()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -134,25 +134,6 @@ private static Stream<Arguments> configureResourceArgs() {
Arguments.of(
null,
"io.opentelemetry.sdk.autoconfigure.EnvironmentResourceProvider",
attributeConsumer(
attr ->
attr.containsEntry("service.name", "unknown_service:java")
.doesNotContainKey("cat")
.containsEntry("animal", "cat")
.containsEntry("color", "blue"))),
// old environment resource provider FQCN
Arguments.of(
"io.opentelemetry.sdk.autoconfigure.internal.EnvironmentResourceProvider",
null,
attributeConsumer(
attr ->
attr.containsEntry("service.name", "test")
.containsEntry("cat", "meow")
.doesNotContainKey("animal")
.doesNotContainKey("color"))),
Arguments.of(
null,
"io.opentelemetry.sdk.autoconfigure.internal.EnvironmentResourceProvider",
attributeConsumer(
attr ->
attr.containsEntry("service.name", "unknown_service:java")
Expand Down
Loading