Skip to content

Commit 53b46a3

Browse files
committed
initial introduction of config_id
1 parent 6168591 commit 53b46a3

File tree

3 files changed

+26
-5
lines changed

3 files changed

+26
-5
lines changed

internal-api/src/main/java/datadog/trace/api/ConfigCollector.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,11 @@ public void put(String key, Object value, ConfigOrigin origin) {
2727
collected.put(key, setting);
2828
}
2929

30+
public void put(String key, Object value, ConfigOrigin origin, String configId) {
31+
ConfigSetting setting = ConfigSetting.of(key, value, origin);
32+
collected.put(key, setting);
33+
}
34+
3035
public void putAll(Map<String, Object> keysAndValues, ConfigOrigin origin) {
3136
// attempt merge+replace to avoid collector seeing partial update
3237
Map<String, ConfigSetting> merged =

internal-api/src/main/java/datadog/trace/api/ConfigSetting.java

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,19 +11,25 @@ public final class ConfigSetting {
1111
public final String key;
1212
public final Object value;
1313
public final ConfigOrigin origin;
14+
public final String configId;
1415

1516
private static final Set<String> CONFIG_FILTER_LIST =
1617
new HashSet<>(
1718
Arrays.asList("DD_API_KEY", "dd.api-key", "dd.profiling.api-key", "dd.profiling.apikey"));
1819

1920
public static ConfigSetting of(String key, Object value, ConfigOrigin origin) {
20-
return new ConfigSetting(key, value, origin);
21+
return new ConfigSetting(key, value, origin, null);
2122
}
2223

23-
private ConfigSetting(String key, Object value, ConfigOrigin origin) {
24+
public static ConfigSetting of(String key, Object value, ConfigOrigin origin, String configId) {
25+
return new ConfigSetting(key, value, origin, configId);
26+
}
27+
28+
private ConfigSetting(String key, Object value, ConfigOrigin origin, String configId) {
2429
this.key = key;
2530
this.value = CONFIG_FILTER_LIST.contains(key) ? "<hidden>" : value;
2631
this.origin = origin;
32+
this.configId = configId;
2733
}
2834

2935
public String normalizedKey() {
@@ -99,12 +105,15 @@ public boolean equals(Object o) {
99105
if (this == o) return true;
100106
if (o == null || getClass() != o.getClass()) return false;
101107
ConfigSetting that = (ConfigSetting) o;
102-
return key.equals(that.key) && Objects.equals(value, that.value) && origin == that.origin;
108+
return key.equals(that.key)
109+
&& Objects.equals(value, that.value)
110+
&& origin == that.origin
111+
&& configId.equals(that.configId);
103112
}
104113

105114
@Override
106115
public int hashCode() {
107-
return Objects.hash(key, value, origin);
116+
return Objects.hash(key, value, origin, configId);
108117
}
109118

110119
@Override
@@ -117,6 +126,8 @@ public String toString() {
117126
+ stringValue()
118127
+ ", origin="
119128
+ origin
129+
+ ", configId="
130+
+ configId
120131
+ '}';
121132
}
122133
}

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

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,12 @@ public String getString(String key, String defaultValue, String... aliases) {
7878
String value = source.get(key, aliases);
7979
if (value != null) {
8080
if (collectConfig) {
81-
ConfigCollector.get().put(key, value, source.origin());
81+
if (source instanceof StableConfigSource) {
82+
String configId = ((StableConfigSource) source).getConfigId();
83+
ConfigCollector.get().put(key, value, source.origin(), configId);
84+
} else {
85+
ConfigCollector.get().put(key, value, source.origin());
86+
}
8287
}
8388
return value;
8489
}

0 commit comments

Comments
 (0)