Skip to content

Commit 48d3e6e

Browse files
committed
pr review
1 parent 6677165 commit 48d3e6e

File tree

1 file changed

+14
-19
lines changed
  • instrumentation/spring/spring-boot-autoconfigure/src/main/java/io/opentelemetry/instrumentation/spring/autoconfigure/internal/properties

1 file changed

+14
-19
lines changed

instrumentation/spring/spring-boot-autoconfigure/src/main/java/io/opentelemetry/instrumentation/spring/autoconfigure/internal/properties/SpringConfigProperties.java

Lines changed: 14 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
import java.util.HashMap;
1616
import java.util.List;
1717
import java.util.Map;
18-
import java.util.function.Function;
1918
import javax.annotation.Nullable;
2019
import org.springframework.core.env.Environment;
2120
import org.springframework.expression.ExpressionParser;
@@ -34,25 +33,11 @@ public class SpringConfigProperties implements ConfigProperties {
3433
private final OtelSpringProperties otelSpringProperties;
3534
private final ConfigProperties otelSdkProperties;
3635
private final ConfigProperties customizedListProperties;
37-
38-
private static final Map<String, Function<OtelSpringProperties, List<String>>> LIST_PROPERTIES =
39-
new HashMap<>();
36+
private final Map<String, List<String>> listPropertyValues = new HashMap<>();
4037

4138
static final String DISABLED_KEY = "otel.java.disabled.resource.providers";
4239
static final String ENABLED_KEY = "otel.java.enabled.resource.providers";
4340

44-
static {
45-
LIST_PROPERTIES.put(ENABLED_KEY, OtelSpringProperties::getJavaEnabledResourceProviders);
46-
LIST_PROPERTIES.put(DISABLED_KEY, OtelSpringProperties::getJavaDisabledResourceProviders);
47-
LIST_PROPERTIES.put(
48-
"otel.experimental.metrics.view.config",
49-
OtelSpringProperties::getExperimentalMetricsViewConfig);
50-
LIST_PROPERTIES.put(
51-
"otel.experimental.resource.disabled.keys",
52-
OtelSpringProperties::getExperimentalResourceDisabledKeys);
53-
LIST_PROPERTIES.put("otel.propagators", OtelSpringProperties::getPropagators);
54-
}
55-
5641
public SpringConfigProperties(
5742
Environment environment,
5843
ExpressionParser parser,
@@ -68,6 +53,16 @@ public SpringConfigProperties(
6853
this.otelSdkProperties = otelSdkProperties;
6954
this.customizedListProperties =
7055
createCustomizedListProperties(otelSdkProperties, otelSpringProperties);
56+
57+
listPropertyValues.put(ENABLED_KEY, otelSpringProperties.getJavaEnabledResourceProviders());
58+
listPropertyValues.put(DISABLED_KEY, otelSpringProperties.getJavaDisabledResourceProviders());
59+
listPropertyValues.put(
60+
"otel.experimental.metrics.view.config",
61+
otelSpringProperties.getExperimentalMetricsViewConfig());
62+
listPropertyValues.put(
63+
"otel.experimental.resource.disabled.keys",
64+
otelSpringProperties.getExperimentalResourceDisabledKeys());
65+
listPropertyValues.put("otel.propagators", otelSpringProperties.getPropagators());
7166
}
7267

7368
private static Map<String, String> addList(
@@ -171,13 +166,13 @@ public List<String> getList(String name) {
171166

172167
String normalizedName = ConfigUtil.normalizeEnvironmentVariableKey(name);
173168

174-
Function<OtelSpringProperties, List<String>> getList = LIST_PROPERTIES.get(normalizedName);
175-
if (getList != null) {
169+
List<String> list = listPropertyValues.get(normalizedName);
170+
if (list != null) {
176171
List<String> c = customizedListProperties.getList(name);
177172
if (!c.isEmpty()) {
178173
return c;
179174
}
180-
return getList.apply(otelSpringProperties);
175+
return list;
181176
}
182177

183178
return or(environment.getProperty(normalizedName, List.class), otelSdkProperties.getList(name));

0 commit comments

Comments
 (0)