11package datadog .trace .bootstrap .config .provider ;
22
3- import datadog .trace .bootstrap .config .provider .stableconfigyaml .ConfigurationMap ;
43import datadog .trace .bootstrap .config .provider .stableconfigyaml .Rule ;
54import datadog .trace .bootstrap .config .provider .stableconfigyaml .Selector ;
65import datadog .trace .bootstrap .config .provider .stableconfigyaml .StableConfigYaml ;
109import java .nio .file .Files ;
1110import java .nio .file .Paths ;
1211import java .util .Collections ;
13- import java .util .HashMap ;
12+ import java .util .LinkedHashMap ;
1413import java .util .List ;
14+ import java .util .Map ;
1515import java .util .function .BiPredicate ;
1616import org .slf4j .Logger ;
1717import org .slf4j .LoggerFactory ;
@@ -41,10 +41,11 @@ public static StableConfigSource.StableConfig parse(String filePath) throws IOEx
4141 try {
4242 String content = new String (Files .readAllBytes (Paths .get (filePath )), StandardCharsets .UTF_8 );
4343 String processedContent = processTemplate (content );
44- StableConfigYaml data = YamlParser .parse (processedContent , StableConfigYaml .class );
44+ Object parsedYaml = YamlParser .parse (processedContent );
45+ StableConfigYaml data = new StableConfigYaml (parsedYaml );
4546
4647 String configId = data .getConfig_id ();
47- ConfigurationMap configMap = data .getApm_configuration_default ();
48+ Map < String , Object > configMap = data .getApm_configuration_default ();
4849 List <Rule > rules = data .getApm_configuration_rules ();
4950
5051 if (!rules .isEmpty ()) {
@@ -53,14 +54,16 @@ public static StableConfigSource.StableConfig parse(String filePath) throws IOEx
5354 if (doesRuleMatch (rule )) {
5455 // Merge configs found in apm_configuration_rules with those found in
5556 // apm_configuration_default
56- configMap .putAll (rule .getConfiguration ());
57- return createStableConfig (configId , configMap );
57+ Map <String , Object > mergedConfigMap = new LinkedHashMap <>(configMap );
58+ mergedConfigMap .putAll (rule .getConfiguration ());
59+ return new StableConfigSource .StableConfig (configId , mergedConfigMap );
5860 }
5961 }
6062 }
6163 // If configs were found in apm_configuration_default, use them
6264 if (!configMap .isEmpty ()) {
63- return createStableConfig (configId , configMap );
65+ return new StableConfigSource .StableConfig (
66+ configId , new LinkedHashMap <String , Object >(configMap ));
6467 }
6568
6669 // If there's a configId but no configMap, use configId but return an empty map
@@ -91,12 +94,6 @@ private static boolean doesRuleMatch(Rule rule) {
9194 return true ; // Return true if all selectors match
9295 }
9396
94- /** Creates a StableConfig object from the provided configId and configMap. */
95- private static StableConfigSource .StableConfig createStableConfig (
96- String configId , ConfigurationMap configMap ) {
97- return new StableConfigSource .StableConfig (configId , new HashMap <>(configMap ));
98- }
99-
10097 private static boolean validOperatorForLanguageOrigin (String operator ) {
10198 operator = operator .toLowerCase ();
10299 // "exists" is not valid
0 commit comments