-
Notifications
You must be signed in to change notification settings - Fork 312
Match Hands Off Config selectors on process_arguments value #9201
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
17 commits
Select commit
Hold shift + click to select a range
2df85ac
feat: match stable config java properties on other operator than 'con…
paullegranddc 314525a
fix: lowercase match value
paullegranddc b051555
fix: extra parameter
paullegranddc c094176
fix: remove duplicate values
paullegranddc a58bd09
fix: lint
paullegranddc db6e5c7
fi: wrong variable
paullegranddc 5865dc8
fix lint
paullegranddc 2f93fad
fix: tests
paullegranddc ebf333b
fix: null matches with exist should work
paullegranddc 75f6dae
feat: add tests for equal operator on arguments
paullegranddc cfb37db
fix: use equal method instead of operator
paullegranddc a8ff152
Update internal-api/src/main/java/datadog/trace/bootstrap/config/prov…
mtoffl01 6f1ea89
apply PR suggestions
mtoffl01 db73932
fix typo
mtoffl01 12c673d
Add missing locale
mtoffl01 4f4c5bc
add matches == null check back in to avoid NPE
mtoffl01 2cf1092
Merge branch 'master' into paullgdc/stable_config/match_equal_args
mtoffl01 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
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 |
---|---|---|
|
@@ -62,12 +62,40 @@ apm_configuration_rules: | |
Files.delete(filePath) | ||
} | ||
|
||
def "test parse and template"() { | ||
when: | ||
Path filePath = Files.createTempFile("testFile_", ".yaml") | ||
then: | ||
if (filePath == null) { | ||
throw new AssertionError("Failed to create: " + filePath) | ||
} | ||
Comment on lines
+68
to
+71
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
If the YAML is constant, store it in test resources instead. |
||
|
||
when: | ||
String yaml = """ | ||
apm_configuration_rules: | ||
- selectors: | ||
- origin: process_arguments | ||
key: "-Dtest_parse_and_template" | ||
operator: exists | ||
configuration: | ||
DD_SERVICE: {{process_arguments['-Dtest_parse_and_template']}} | ||
""" | ||
System.setProperty("test_parse_and_template", "myservice") | ||
Files.write(filePath, yaml.getBytes()) | ||
StableConfigSource.StableConfig cfg = StableConfigParser.parse(filePath.toString()) | ||
|
||
then: | ||
cfg.get("DD_SERVICE") == "myservice" | ||
} | ||
|
||
def "test selectorMatch"() { | ||
when: | ||
// Env vars | ||
injectEnvConfig("DD_PROFILING_ENABLED", "true") | ||
injectEnvConfig("DD_SERVICE", "mysvc") | ||
injectEnvConfig("DD_TAGS", "team:apm,component:web") | ||
System.setProperty("test_selectorMatch", "value1") | ||
|
||
def match = StableConfigParser.selectorMatch(origin, matches, operator, key) | ||
|
||
then: | ||
|
@@ -83,6 +111,7 @@ apm_configuration_rules: | |
"language" | ["java"] | "exists" | "" | false | ||
"language" | ["java"] | "something unexpected" | "" | false | ||
"environment_variables" | [] | "exists" | "DD_TAGS" | true | ||
"environment_variables" | null | "exists" | "DD_TAGS" | true | ||
"environment_variables" | ["team:apm"] | "contains" | "DD_TAGS" | true | ||
"ENVIRONMENT_VARIABLES" | ["TeAm:ApM"] | "CoNtAiNs" | "Dd_TaGs" | true // check case insensitivity | ||
"environment_variables" | ["team:apm"] | "equals" | "DD_TAGS" | false | ||
|
@@ -96,6 +125,13 @@ apm_configuration_rules: | |
"environment_variables" | ["svc"] | "contains" | "DD_SERVICE" | true | ||
"environment_variables" | ["other"] | "contains" | "DD_SERVICE" | false | ||
"environment_variables" | [null] | "contains" | "DD_SERVICE" | false | ||
"environment_variables" | [] | "equals" | null | false | ||
"environment_variables" | null | "equals" | "DD_SERVICE" | false | ||
"language" | ["java"] | null | "" | false | ||
"process_arguments" | null | "exists" | "-Dtest_selectorMatch" | true | ||
"process_arguments" | null | "exists" | "-Darg2" | false | ||
"process_arguments" | ["value1"] | "equals" | "-Dtest_selectorMatch" | true | ||
"process_arguments" | ["value2"] | "equals" | "-Dtest_selectorMatch" | false | ||
} | ||
|
||
def "test duplicate entries not allowed"() { | ||
|
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can't we use method reference here and loop on the matches with instead?