Skip to content

Commit 5f5f6d0

Browse files
committed
Fix
1 parent a28b1d7 commit 5f5f6d0

File tree

3 files changed

+15
-9
lines changed

3 files changed

+15
-9
lines changed

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

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ public static ConfigProperties create(
6666
@Nullable
6767
@Override
6868
public String getString(String name) {
69-
String normalizedName = ConfigUtil.normalizePropertyKey(name);
69+
String normalizedName = ConfigUtil.normalizeEnvironmentVariableKey(name);
7070
String value = environment.getProperty(normalizedName, String.class);
7171
if (value == null && normalizedName.equals("otel.exporter.otlp.protocol")) {
7272
// SDK autoconfigure module defaults to `grpc`, but this module aligns with recommendation
@@ -80,38 +80,39 @@ public String getString(String name) {
8080
@Override
8181
public Boolean getBoolean(String name) {
8282
return or(
83-
environment.getProperty(ConfigUtil.normalizePropertyKey(name), Boolean.class),
83+
environment.getProperty(ConfigUtil.normalizeEnvironmentVariableKey(name), Boolean.class),
8484
otelSdkProperties.getBoolean(name));
8585
}
8686

8787
@Nullable
8888
@Override
8989
public Integer getInt(String name) {
9090
return or(
91-
environment.getProperty(ConfigUtil.normalizePropertyKey(name), Integer.class),
91+
environment.getProperty(ConfigUtil.normalizeEnvironmentVariableKey(name), Integer.class),
9292
otelSdkProperties.getInt(name));
9393
}
9494

9595
@Nullable
9696
@Override
9797
public Long getLong(String name) {
9898
return or(
99-
environment.getProperty(ConfigUtil.normalizePropertyKey(name), Long.class),
99+
environment.getProperty(ConfigUtil.normalizeEnvironmentVariableKey(name), Long.class),
100100
otelSdkProperties.getLong(name));
101101
}
102102

103103
@Nullable
104104
@Override
105105
public Double getDouble(String name) {
106106
return or(
107-
environment.getProperty(ConfigUtil.normalizePropertyKey(name), Double.class),
107+
environment.getProperty(ConfigUtil.normalizeEnvironmentVariableKey(name), Double.class),
108108
otelSdkProperties.getDouble(name));
109109
}
110110

111111
@SuppressWarnings("unchecked")
112112
@Override
113113
public List<String> getList(String name) {
114-
String normalizedName = ConfigUtil.normalizePropertyKey(name);
114+
115+
String normalizedName = ConfigUtil.normalizeEnvironmentVariableKey(name);
115116

116117
if (normalizedName.equals("otel.propagators")) {
117118
return propagationProperties.getPropagators();
@@ -136,7 +137,7 @@ public Duration getDuration(String name) {
136137
public Map<String, String> getMap(String name) {
137138
Map<String, String> otelSdkMap = otelSdkProperties.getMap(name);
138139

139-
String normalizedName = ConfigUtil.normalizePropertyKey(name);
140+
String normalizedName = ConfigUtil.normalizeEnvironmentVariableKey(name);
140141
// maps from config properties are not supported by Environment, so we have to fake it
141142
switch (normalizedName) {
142143
case "otel.resource.attributes":

smoke-tests-otel-starter/spring-boot-common/src/main/java/io/opentelemetry/spring/smoketest/AbstractOtelSpringStarterSmokeTest.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -110,8 +110,12 @@ AutoConfigurationCustomizerProvider customizerUsingPropertyDefinedInaSpringFile(
110110
return customizer ->
111111
customizer.addResourceCustomizer(
112112
(resource, config) -> {
113-
String propValue = config.getString("APPLICATION-PROP");
114-
assertThat(propValue).isNotEmpty();
113+
String valueForKeyDeclaredZsEnvVariable = config.getString("APPLICATION_PROP");
114+
assertThat(valueForKeyDeclaredZsEnvVariable).isNotEmpty();
115+
116+
String valueForKeyWithDash = config.getString("application.prop-with-dash");
117+
assertThat(valueForKeyWithDash).isNotEmpty();
118+
115119
return resource;
116120
});
117121
}

smoke-tests-otel-starter/spring-boot-common/src/main/resources/application.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ otel:
2121

2222
application:
2323
prop: propValue
24+
prop-with-dash: provWithDashValue
2425

2526
spring:
2627
kafka:

0 commit comments

Comments
 (0)