-
Notifications
You must be signed in to change notification settings - Fork 131
Enable environment variables for attribute filters #1558
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
base: main
Are you sure you want to change the base?
Conversation
✅MegaLinter analysis: Success
See detailed reports in MegaLinter artifacts |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #1558 +/- ##
=======================================
Coverage 81.74% 81.74%
=======================================
Files 207 207
Lines 23948 23948
Branches 3797 3797
=======================================
+ Hits 19576 19577 +1
Misses 3103 3103
+ Partials 1269 1268 -1 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
newrelic/core/config.py
Outdated
| def _environ_as_comma_separated_list(name, default=""): | ||
| result = [] | ||
| attributes = os.environ.get(name, default) | ||
|
|
||
| # Strip all whitespace and commas from the end of the string. | ||
| # That way, when we split a valid labels string by ',', the resulting | ||
| # list will contain no empty elements. | ||
|
|
||
| attributes = attributes.strip(", \t\n\r\f\v") | ||
|
|
||
| if not attributes: | ||
| return result | ||
|
|
||
| for attribute in attributes.split(","): | ||
| attribute = attribute.strip() | ||
|
|
||
| if attribute: | ||
| result.append(attribute) | ||
| else: | ||
| _logger.warning( | ||
| "Invalid configuration. Cannot parse: %r. Expected format 'attribute1, attribute2, attribute3'", | ||
| attributes, | ||
| ) | ||
| result = [] | ||
| break | ||
|
|
||
| return result | ||
|
|
||
|
|
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.
I believe you want _environ_as_set for this. We already used that for the logging attribute filter.
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.
For some reason, I thought these were comma delimited instead of space delimited. Changing that now to _environ_as_set

This PR adds the option to use environment variables to enable/disable attributes as well as exclude/include filtering rules.
This can be useful for users running New Relic without an
*.inifile.The following have been added: