Skip to content

Conversation

@lrafeei
Copy link
Contributor

@lrafeei lrafeei commented Oct 28, 2025

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 *.ini file.

The following have been added:

NEW_RELIC_ATTRIBUTES_ENABLED
NEW_RELIC_ATTRIBUTES_EXCLUDE
NEW_RELIC_ATTRIBUTES_INCLUDE
NEW_RELIC_BROWSER_MONITORING_ATTRIBUTES_ENABLED
NEW_RELIC_BROWSER_MONITORING_ATTRIBUTES_EXCLUDE
NEW_RELIC_BROWSER_MONITORING_ATTRIBUTES_INCLUDE
NEW_RELIC_ERROR_COLLECTOR_ATTRIBUTES_ENABLED
NEW_RELIC_ERROR_COLLECTOR_ATTRIBUTES_EXCLUDE
NEW_RELIC_ERROR_COLLECTOR_ATTRIBUTES_INCLUDE
NEW_RELIC_SPAN_EVENTS_ATTRIBUTES_ENABLED
NEW_RELIC_SPAN_EVENTS_ATTRIBUTES_EXCLUDE
NEW_RELIC_SPAN_EVENTS_ATTRIBUTES_INCLUDE
NEW_RELIC_TRANSACTION_EVENTS_ATTRIBUTES_ENABLED
NEW_RELIC_TRANSACTION_EVENTS_ATTRIBUTES_EXCLUDE
NEW_RELIC_TRANSACTION_EVENTS_ATTRIBUTES_INCLUDE
NEW_RELIC_TRANSACTION_SEGMENTS_ATTRIBUTES_ENABLED
NEW_RELIC_TRANSACTION_SEGMENTS_ATTRIBUTES_EXCLUDE
NEW_RELIC_TRANSACTION_SEGMENTS_ATTRIBUTES_INCLUDE
NEW_RELIC_TRANSACTION_TRACER_ATTRIBUTES_ENABLED
NEW_RELIC_TRANSACTION_TRACER_ATTRIBUTES_EXCLUDE
NEW_RELIC_TRANSACTION_TRACER_ATTRIBUTES_INCLUDE

@github-actions
Copy link

github-actions bot commented Oct 28, 2025

MegaLinter analysis: Success

Descriptor Linter Files Fixed Errors Warnings Elapsed time
✅ ACTION actionlint 7 0 0 0.87s
✅ MARKDOWN markdownlint 7 0 0 0 1.14s
✅ PYTHON ruff 948 0 0 0 1.02s
✅ PYTHON ruff-format 948 0 0 0 0.35s
✅ YAML prettier 15 0 0 0 1.52s
✅ YAML v8r 15 0 0 5.13s
✅ YAML yamllint 15 0 0 0.69s

See detailed reports in MegaLinter artifacts

MegaLinter is graciously provided by OX Security

@lrafeei lrafeei marked this pull request as ready for review October 28, 2025 19:10
@lrafeei lrafeei requested a review from a team as a code owner October 28, 2025 19:10
@mergify mergify bot added the tests-failing Tests failing in CI. label Oct 28, 2025
@codecov-commenter
Copy link

codecov-commenter commented Oct 28, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 81.74%. Comparing base (953f379) to head (2df2591).

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.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@mergify mergify bot removed the tests-failing Tests failing in CI. label Oct 28, 2025
Comment on lines 628 to 656
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


Copy link
Contributor

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.

Copy link
Contributor Author

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

@mergify mergify bot added the tests-failing Tests failing in CI. label Oct 29, 2025
@lrafeei lrafeei requested a review from TimPansino October 29, 2025 23:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

tests-failing Tests failing in CI.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants