Skip to content

Commit bfcfd7e

Browse files
committed
getString methods only report non-null values to telemetry
1 parent bee84bf commit bfcfd7e

File tree

1 file changed

+21
-22
lines changed

1 file changed

+21
-22
lines changed

internal-api/src/main/java/datadog/trace/bootstrap/config/provider/ConfigProvider.java

Lines changed: 21 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -90,16 +90,14 @@ public String getString(String key, String defaultValue, String... aliases) {
9090
for (int i = sources.length - 1; i >= 0; i--) {
9191
ConfigProvider.Source source = sources[i];
9292
String candidate = source.get(key, aliases);
93-
94-
// Always report to telemetry
95-
if (collectConfig) {
96-
ConfigCollector.get()
97-
.put(key, candidate, source.origin(), seqId, getConfigIdFromSource(source));
98-
}
99-
10093
// Create resolver if we have a valid candidate
10194
if (candidate != null) {
10295
resolver = ConfigValueResolver.of(candidate);
96+
// And report to telemetry
97+
if (collectConfig) {
98+
ConfigCollector.get()
99+
.put(key, candidate, source.origin(), seqId, getConfigIdFromSource(source));
100+
}
103101
}
104102

105103
seqId++;
@@ -124,16 +122,18 @@ public String getStringNotEmpty(String key, String defaultValue, String... alias
124122
ConfigProvider.Source source = sources[i];
125123
String candidateValue = source.get(key, aliases);
126124

127-
// Always report to telemetry
128-
if (collectConfig) {
129-
ConfigCollector.get()
130-
.put(key, candidateValue, source.origin(), seqId, getConfigIdFromSource(source));
131-
}
132-
// Create resolver only if candidate is not empty or blank
133-
if (candidateValue != null && !candidateValue.trim().isEmpty()) {
134-
resolver =
135-
ConfigValueResolver.of(
136-
candidateValue, source.origin(), seqId, getConfigIdFromSource(source));
125+
// Report any non-null values to telemetry
126+
if (candidateValue != null) {
127+
if (collectConfig) {
128+
ConfigCollector.get()
129+
.put(key, candidateValue, source.origin(), seqId, getConfigIdFromSource(source));
130+
}
131+
// Create resolver only if candidate is not empty or blank
132+
if (!candidateValue.trim().isEmpty()) {
133+
resolver =
134+
ConfigValueResolver.of(
135+
candidateValue, source.origin(), seqId, getConfigIdFromSource(source));
136+
}
137137
}
138138

139139
seqId++;
@@ -163,11 +163,6 @@ public String getStringExcludingSource(
163163
ConfigProvider.Source source = sources[i];
164164
String candidate = source.get(key, aliases);
165165

166-
// Always report to telemetry
167-
if (collectConfig) {
168-
ConfigCollector.get()
169-
.put(key, candidate, source.origin(), seqId, getConfigIdFromSource(source));
170-
}
171166
// Skip excluded source types
172167
if (excludedSource.isAssignableFrom(source.getClass())) {
173168
seqId++;
@@ -176,6 +171,10 @@ public String getStringExcludingSource(
176171
// Create resolver if we have a valid candidate from non-excluded source
177172
if (candidate != null) {
178173
resolver = ConfigValueResolver.of(candidate);
174+
if (collectConfig) {
175+
ConfigCollector.get()
176+
.put(key, candidate, source.origin(), seqId, getConfigIdFromSource(source));
177+
}
179178
}
180179

181180
seqId++;

0 commit comments

Comments
 (0)