Skip to content

Commit a7df08f

Browse files
committed
Make EnvironmentResource.ATTRIBUTE_PROPERTY and createEnvironmentResource package-private
Both were public but only used within the autoconfigure module. ResourceFactory (different package, same module) now uses ResourceConfiguration.createEnvironmentResource and inlines the property name string instead. Signed-off-by: Gregor Zeitlinger <gregor.zeitlinger@grafana.com>
1 parent 292ad41 commit a7df08f

2 files changed

Lines changed: 5 additions & 16 deletions

File tree

sdk-extensions/autoconfigure/src/main/java/io/opentelemetry/sdk/autoconfigure/EnvironmentResource.java

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -23,20 +23,11 @@ public final class EnvironmentResource {
2323

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

26-
// Visible for testing
27-
public static final String ATTRIBUTE_PROPERTY = "otel.resource.attributes";
26+
static final String ATTRIBUTE_PROPERTY = "otel.resource.attributes";
2827
static final String SERVICE_NAME_PROPERTY = "otel.service.name";
2928

30-
/**
31-
* Create a {@link Resource} from the environment. The resource contains attributes parsed from
32-
* environment variables and system property keys {@code otel.resource.attributes} and {@code
33-
* otel.service.name}.
34-
*
35-
* @param config the {@link ConfigProperties} used to obtain resource properties
36-
* @return the resource.
37-
*/
3829
@SuppressWarnings("JdkObsolete") // Recommended alternative was introduced in java 10
39-
public static Resource createEnvironmentResource(ConfigProperties config) {
30+
static Resource createEnvironmentResource(ConfigProperties config) {
4031
AttributesBuilder resourceAttributes = Attributes.builder();
4132
for (Map.Entry<String, String> entry : config.getMap(ATTRIBUTE_PROPERTY).entrySet()) {
4233
resourceAttributes.put(

sdk-extensions/autoconfigure/src/main/java/io/opentelemetry/sdk/extension/incubator/fileconfig/ResourceFactory.java

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,8 @@
55

66
package io.opentelemetry.sdk.extension.incubator.fileconfig;
77

8-
import static io.opentelemetry.sdk.autoconfigure.EnvironmentResource.ATTRIBUTE_PROPERTY;
9-
import static io.opentelemetry.sdk.autoconfigure.EnvironmentResource.createEnvironmentResource;
10-
118
import io.opentelemetry.api.common.Attributes;
9+
import io.opentelemetry.sdk.autoconfigure.ResourceConfiguration;
1210
import io.opentelemetry.sdk.autoconfigure.spi.internal.DefaultConfigProperties;
1311
import io.opentelemetry.sdk.common.internal.IncludeExcludePredicate;
1412
import io.opentelemetry.sdk.extension.incubator.fileconfig.internal.model.AttributeNameValueModel;
@@ -62,9 +60,9 @@ public Resource create(ResourceModel model, DeclarativeConfigContext context) {
6260
String attributeList = model.getAttributesList();
6361
if (attributeList != null) {
6462
builder.putAll(
65-
createEnvironmentResource(
63+
ResourceConfiguration.createEnvironmentResource(
6664
DefaultConfigProperties.createFromMap(
67-
Collections.singletonMap(ATTRIBUTE_PROPERTY, attributeList))));
65+
Collections.singletonMap("otel.resource.attributes", attributeList))));
6866
}
6967

7068
List<AttributeNameValueModel> attributeNameValueModel = model.getAttributes();

0 commit comments

Comments
 (0)