|
14 | 14 | import datadog.trace.core.CoreTracer; |
15 | 15 | import java.io.ByteArrayInputStream; |
16 | 16 | import java.io.IOException; |
| 17 | +import java.util.HashMap; |
| 18 | +import java.util.Map; |
17 | 19 | import okio.Okio; |
18 | 20 |
|
19 | 21 | 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"; |
22 | 23 | private final DynamicConfig<?> dynamicConfig; |
23 | 24 |
|
24 | 25 | private Runnable stopPreparer; |
25 | 26 | private Runnable stopSubmitter; |
26 | 27 |
|
27 | 28 | private TracerFlareService tracerFlareService; |
28 | 29 |
|
| 30 | + private final Map<String, String> configAction = new HashMap<>(); |
| 31 | + |
29 | 32 | public TracerFlarePoller(DynamicConfig<?> dynamicConfig) { |
30 | 33 | this.dynamicConfig = dynamicConfig; |
31 | 34 | } |
@@ -68,23 +71,22 @@ public Runnable register(Config config, SharedCommunicationObjects sco) { |
68 | 71 | @Override |
69 | 72 | public void accept(ConfigKey configKey, byte[] content, PollingRateHinter hinter) |
70 | 73 | 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(); |
82 | 84 | } |
83 | 85 | } |
84 | 86 |
|
85 | 87 | @Override |
86 | 88 | 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)) { |
88 | 90 | cleanupAfterFlare(); |
89 | 91 | } |
90 | 92 | } |
|
0 commit comments