-
Notifications
You must be signed in to change notification settings - Fork 306
The Stable Config migration from snakeyaml to the snakeyaml engine to support GraalVM Native #8790
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
22 commits
Select commit
Hold shift + click to select a range
9a3ba87
Migrate from snakeyaml to snakeyaml-engine
ygree 68d5f1d
Clean up
ygree a4deaea
Clean up stableconfig stuff
ygree 9305638
Merge branch 'master' into ygree/snakeyaml-engine-migration
ygree 4ac352a
Properly exclude snakeyaml-engine
ygree 92446dc
Merge branch 'master' into ygree/snakeyaml-engine-migration
ygree ae34b12
Merge branch 'master' into ygree/snakeyaml-engine-migration
ygree 956c96b
Merge branch 'master' into ygree/snakeyaml-engine-migration
ygree 4174012
Merge branch 'master' into ygree/snakeyaml-engine-migration
ygree a160ce9
Merge branch 'master' into ygree/snakeyaml-engine-migration
ygree c556fa3
Merge branch 'master' into ygree/snakeyaml-engine-migration
ygree 38e5389
Merge branch 'master' into ygree/snakeyaml-engine-migration
ygree f38f8ce
Merge branch 'master' into ygree/snakeyaml-engine-migration
ygree ec92fee
Merge branch 'master' into ygree/snakeyaml-engine-migration
ygree 2c56ffe
Clean up
ygree 84da741
Merge branch 'master' into ygree/snakeyaml-engine-migration
ygree fe3e325
Merge branch 'master' into ygree/snakeyaml-engine-migration
ygree b7fd4e5
Merge branch 'master' into ygree/snakeyaml-engine-migration
ygree b572aa5
Merge branch 'master' into ygree/snakeyaml-engine-migration
ygree 24f89bc
Fix broken tests
ygree c68d1b1
Merge branch 'master' into ygree/snakeyaml-engine-migration
ygree 9bc2136
Merge branch 'master' into ygree/snakeyaml-engine-migration
ygree File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
21 changes: 12 additions & 9 deletions
21
components/yaml/src/main/java/datadog/yaml/YamlParser.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,18 @@ | ||
package datadog.yaml; | ||
|
||
import org.yaml.snakeyaml.Yaml; | ||
import org.snakeyaml.engine.v2.api.Load; | ||
import org.snakeyaml.engine.v2.api.LoadSettings; | ||
|
||
public class YamlParser { | ||
// Supports clazz == null for default yaml parsing | ||
public static <T> T parse(String content, Class<T> clazz) { | ||
Yaml yaml = new Yaml(); | ||
if (clazz == null) { | ||
return yaml.load(content); | ||
} else { | ||
return yaml.loadAs(content, clazz); | ||
} | ||
/** | ||
* Parses YAML content. Duplicate keys are not allowed and will result in a runtime exception.. | ||
* | ||
* @param content - text context to be parsed as YAML | ||
* @return - a parsed representation as a composition of map and list objects. | ||
*/ | ||
public static Object parse(String content) { | ||
LoadSettings settings = LoadSettings.builder().build(); | ||
Load yaml = new Load(settings); | ||
return yaml.loadFromString(content); | ||
} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
44 changes: 44 additions & 0 deletions
44
internal-api/src/main/java/datadog/trace/bootstrap/config/provider/stableconfig/Rule.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
package datadog.trace.bootstrap.config.provider.stableconfig; | ||
|
||
import static java.util.Collections.*; | ||
import static java.util.stream.Collectors.toList; | ||
|
||
import java.util.List; | ||
import java.util.Map; | ||
import java.util.Objects; | ||
|
||
/** | ||
* Rule represents a set of selectors and their corresponding configurations found in stable | ||
* configuration files | ||
*/ | ||
public final class Rule { | ||
private final List<Selector> selectors; | ||
private final Map<String, Object> configuration; | ||
|
||
public Rule() { | ||
this.selectors = emptyList(); | ||
this.configuration = emptyMap(); | ||
} | ||
|
||
public Rule(List<Selector> selectors, Map<String, Object> configuration) { | ||
this.selectors = selectors; | ||
this.configuration = configuration; | ||
} | ||
|
||
public Rule(Object yaml) { | ||
Map map = (Map) yaml; | ||
selectors = | ||
unmodifiableList( | ||
((List<Object>) map.get("selectors")) | ||
.stream().filter(Objects::nonNull).map(Selector::new).collect(toList())); | ||
configuration = unmodifiableMap((Map<String, Object>) map.get("configuration")); | ||
} | ||
|
||
public List<Selector> getSelectors() { | ||
return selectors; | ||
} | ||
|
||
public Map<String, Object> getConfiguration() { | ||
return configuration; | ||
} | ||
} |
43 changes: 43 additions & 0 deletions
43
...rnal-api/src/main/java/datadog/trace/bootstrap/config/provider/stableconfig/Selector.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
package datadog.trace.bootstrap.config.provider.stableconfig; | ||
|
||
import java.util.Collections; | ||
import java.util.List; | ||
import java.util.Map; | ||
|
||
public final class Selector { | ||
private final String origin; | ||
private final String key; | ||
private final List<String> matches; | ||
private final String operator; | ||
|
||
public Selector(String origin, String key, List<String> matches, String operator) { | ||
this.origin = origin; | ||
this.key = key; | ||
this.matches = matches; | ||
this.operator = operator; | ||
} | ||
|
||
public Selector(Object yaml) { | ||
Map map = (Map) yaml; | ||
origin = (String) map.get("origin"); | ||
key = (String) map.get("key"); | ||
matches = Collections.unmodifiableList((List<String>) map.get("matches")); | ||
operator = (String) map.get("operator"); | ||
} | ||
|
||
public String getOrigin() { | ||
return origin; | ||
} | ||
|
||
public String getKey() { | ||
return key; | ||
} | ||
|
||
public List<String> getMatches() { | ||
return matches; | ||
} | ||
|
||
public String getOperator() { | ||
return operator; | ||
} | ||
} |
48 changes: 48 additions & 0 deletions
48
...-api/src/main/java/datadog/trace/bootstrap/config/provider/stableconfig/StableConfig.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
package datadog.trace.bootstrap.config.provider.stableconfig; | ||
|
||
import static java.util.Collections.emptyList; | ||
import static java.util.Collections.emptyMap; | ||
import static java.util.Collections.unmodifiableList; | ||
import static java.util.Collections.unmodifiableMap; | ||
import static java.util.stream.Collectors.toList; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
import java.util.Map; | ||
|
||
public final class StableConfig { | ||
private final String configId; | ||
private final Map<String, Object> apmConfigurationDefault; | ||
private final List<Rule> apmConfigurationRules; | ||
|
||
public StableConfig(Object yaml) { | ||
Map<Object, Object> map = (Map<Object, Object>) yaml; | ||
this.configId = String.valueOf(map.get("config_id")); | ||
this.apmConfigurationDefault = | ||
unmodifiableMap( | ||
(Map<String, Object>) map.getOrDefault("apm_configuration_default", emptyMap())); | ||
this.apmConfigurationRules = | ||
unmodifiableList( | ||
((List<Object>) map.getOrDefault("apm_configuration_rules", emptyList())) | ||
.stream().map(Rule::new).collect(toList())); | ||
} | ||
|
||
// test only | ||
private StableConfig(String configId, Map<String, Object> apmConfigurationDefault) { | ||
this.configId = configId; | ||
this.apmConfigurationDefault = apmConfigurationDefault; | ||
this.apmConfigurationRules = new ArrayList<>(); | ||
} | ||
|
||
public String getConfigId() { | ||
return configId; | ||
} | ||
|
||
public Map<String, Object> getApmConfigurationDefault() { | ||
return apmConfigurationDefault; | ||
} | ||
|
||
public List<Rule> getApmConfigurationRules() { | ||
return apmConfigurationRules; | ||
} | ||
} |
23 changes: 0 additions & 23 deletions
23
.../main/java/datadog/trace/bootstrap/config/provider/stableconfigyaml/ConfigurationMap.java
This file was deleted.
Oops, something went wrong.
38 changes: 0 additions & 38 deletions
38
...rnal-api/src/main/java/datadog/trace/bootstrap/config/provider/stableconfigyaml/Rule.java
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.