Skip to content

Commit 92c787b

Browse files
committed
nits, and add error field to ConfigSetting
1 parent 7cac55a commit 92c787b

File tree

5 files changed

+22
-8
lines changed

5 files changed

+22
-8
lines changed

dd-java-agent/appsec/src/main/java/com/datadog/appsec/config/AppSecConfigServiceImpl.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -563,7 +563,8 @@ private void setAppSecActivation(final AppSecFeatures.Asm asm) {
563563
} else {
564564
newState = asm.enabled;
565565
// Report AppSec activation change via telemetry when modified via remote config
566-
ConfigCollector.get().put(APPSEC_ENABLED, asm.enabled, ConfigOrigin.REMOTE);
566+
ConfigCollector.get()
567+
.put(APPSEC_ENABLED, asm.enabled, ConfigOrigin.REMOTE); // TODO: Report seq id?
567568
}
568569
if (AppSecSystem.isActive() != newState) {
569570
log.info("AppSec {} (runtime)", newState ? "enabled" : "disabled");

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5217,6 +5217,7 @@ private static boolean isWindowsOS() {
52175217
private static String getEnv(String name) {
52185218
String value = EnvironmentVariables.get(name);
52195219
if (value != null) {
5220+
// TODO: Report seqID?
52205221
ConfigCollector.get().put(name, value, ConfigOrigin.ENV);
52215222
}
52225223
return value;
@@ -5240,6 +5241,7 @@ private static String getProp(String name) {
52405241
private static String getProp(String name, String def) {
52415242
String value = SystemProperties.getOrDefault(name, def);
52425243
if (value != null) {
5244+
// TODO: Report seqId?
52435245
ConfigCollector.get().put(name, value, ConfigOrigin.JVM_PROP);
52445246
}
52455247
return value;

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

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ public final class ConfigSetting {
1212
public final Object value;
1313
public final ConfigOrigin origin;
1414
public final int seqId;
15+
public final boolean error;
1516

1617
public static final int DEFAULT_SEQ_ID = 1;
1718
private static final int ABSENT_SEQ_ID = 0;
@@ -21,18 +22,24 @@ public final class ConfigSetting {
2122
Arrays.asList("DD_API_KEY", "dd.api-key", "dd.profiling.api-key", "dd.profiling.apikey"));
2223

2324
public static ConfigSetting of(String key, Object value, ConfigOrigin origin) {
24-
return new ConfigSetting(key, value, origin, ABSENT_SEQ_ID);
25+
return new ConfigSetting(key, value, origin, ABSENT_SEQ_ID, false);
2526
}
2627

2728
public static ConfigSetting of(String key, Object value, ConfigOrigin origin, int seqId) {
28-
return new ConfigSetting(key, value, origin, seqId);
29+
return new ConfigSetting(key, value, origin, seqId, false);
2930
}
3031

31-
private ConfigSetting(String key, Object value, ConfigOrigin origin, int seqId) {
32+
public static ConfigSetting of(
33+
String key, Object value, ConfigOrigin origin, int seqId, boolean error) {
34+
return new ConfigSetting(key, value, origin, seqId, error);
35+
}
36+
37+
private ConfigSetting(String key, Object value, ConfigOrigin origin, int seqId, boolean error) {
3238
this.key = key;
3339
this.value = CONFIG_FILTER_LIST.contains(key) ? "<hidden>" : value;
3440
this.origin = origin;
3541
this.seqId = seqId;
42+
this.error = error;
3643
}
3744

3845
public String normalizedKey() {
@@ -111,7 +118,8 @@ public boolean equals(Object o) {
111118
return key.equals(that.key)
112119
&& Objects.equals(value, that.value)
113120
&& origin == that.origin
114-
&& seqId == that.seqId;
121+
&& seqId == that.seqId
122+
&& error == that.error;
115123
}
116124

117125
@Override
@@ -132,5 +140,6 @@ public String toString() {
132140
+ ", seqId="
133141
+ seqId
134142
+ '}';
143+
// whether to write errors
135144
}
136145
}

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

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -261,7 +261,8 @@ public Set<String> getSet(String key, Set<String> defaultValue) {
261261
String list = getString(key);
262262
if (null == list) {
263263
if (collectConfig) {
264-
ConfigCollector.get().put(key, defaultValue, ConfigOrigin.DEFAULT);
264+
ConfigCollector.get()
265+
.put(key, defaultValue, ConfigOrigin.DEFAULT, ConfigSetting.DEFAULT_SEQ_ID);
265266
}
266267
return defaultValue;
267268
} else {
@@ -394,7 +395,8 @@ public BitSet getIntegerRange(final String key, final BitSet defaultValue, Strin
394395
log.warn("Invalid configuration for {}", key, e);
395396
}
396397
if (collectConfig) {
397-
ConfigCollector.get().put(key, defaultValue, ConfigOrigin.DEFAULT);
398+
ConfigCollector.get()
399+
.put(key, defaultValue, ConfigOrigin.DEFAULT, ConfigSetting.DEFAULT_SEQ_ID);
398400
}
399401
return defaultValue;
400402
}

telemetry/src/test/groovy/datadog/telemetry/TelemetryRequestBodySpecification.groovy

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ class TelemetryRequestBodySpecification extends DDSpecification {
102102
req.endConfiguration()
103103

104104
then:
105-
drainToString(req) == ',"configuration":[{"name":"this_is_a_key","value":"value","origin":"remote_config"}]'
105+
drainToString(req) == ',"configuration":[{"name":"this_is_a_key","value":"value","origin":"remote_config","seq_id":0}]'
106106
}
107107

108108
def 'add debug flag'() {

0 commit comments

Comments
 (0)