Skip to content

Commit b7af674

Browse files
cecile75Cecile Terpinmcculls
authored
Fix relying on configId for remote config log level tracer flare change (#7788)
* initial commit * Update dd-trace-core/src/main/java/datadog/trace/core/flare/TracerFlarePoller.java simplification of code Co-authored-by: Stuart McCulloch <stuart.mcculloch@datadoghq.com> --------- Co-authored-by: Cecile Terpin <“cecile.terpin@datadoghq.com”> Co-authored-by: Stuart McCulloch <stuart.mcculloch@datadoghq.com>
1 parent 4c87388 commit b7af674

File tree

1 file changed

+16
-14
lines changed

1 file changed

+16
-14
lines changed

dd-trace-core/src/main/java/datadog/trace/core/flare/TracerFlarePoller.java

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -14,18 +14,21 @@
1414
import datadog.trace.core.CoreTracer;
1515
import java.io.ByteArrayInputStream;
1616
import java.io.IOException;
17+
import java.util.HashMap;
18+
import java.util.Map;
1719
import okio.Okio;
1820

1921
public final class TracerFlarePoller {
20-
private static final String FLARE_LOG_LEVEL_PREFIX = "flare-log-level.";
21-
22+
private static final String FLARE_LOG_LEVEL = "flare-log-level";
2223
private final DynamicConfig<?> dynamicConfig;
2324

2425
private Runnable stopPreparer;
2526
private Runnable stopSubmitter;
2627

2728
private TracerFlareService tracerFlareService;
2829

30+
private final Map<String, String> configAction = new HashMap<>();
31+
2932
public TracerFlarePoller(DynamicConfig<?> dynamicConfig) {
3033
this.dynamicConfig = dynamicConfig;
3134
}
@@ -68,23 +71,22 @@ public Runnable register(Config config, SharedCommunicationObjects sco) {
6871
@Override
6972
public void accept(ConfigKey configKey, byte[] content, PollingRateHinter hinter)
7073
throws IOException {
71-
if (configKey.getConfigId().startsWith(FLARE_LOG_LEVEL_PREFIX)) {
72-
AgentConfigLayer agentConfigLayer =
73-
AGENT_CONFIG_LAYER_ADAPTER.fromJson(
74-
Okio.buffer(Okio.source(new ByteArrayInputStream(content))));
75-
if (null != agentConfigLayer
76-
&& null != agentConfigLayer.config
77-
&& null != agentConfigLayer.config.logLevel) {
78-
prepareForFlare(agentConfigLayer.config.logLevel);
79-
} else {
80-
cleanupAfterFlare();
81-
}
74+
AgentConfigLayer agentConfigLayer =
75+
AGENT_CONFIG_LAYER_ADAPTER.fromJson(
76+
Okio.buffer(Okio.source(new ByteArrayInputStream(content))));
77+
if (null != agentConfigLayer
78+
&& null != agentConfigLayer.config
79+
&& null != agentConfigLayer.config.logLevel) {
80+
configAction.put(configKey.getConfigId(), FLARE_LOG_LEVEL);
81+
prepareForFlare(agentConfigLayer.config.logLevel);
82+
} else {
83+
cleanupAfterFlare();
8284
}
8385
}
8486

8587
@Override
8688
public void remove(ConfigKey configKey, PollingRateHinter hinter) {
87-
if (configKey.getConfigId().startsWith(FLARE_LOG_LEVEL_PREFIX)) {
89+
if (configAction.remove(configKey.getConfigId(), FLARE_LOG_LEVEL)) {
8890
cleanupAfterFlare();
8991
}
9092
}

0 commit comments

Comments
 (0)