-
Notifications
You must be signed in to change notification settings - Fork 103
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
Add cloud.aws.account_id config setting #1249
base: main
Are you sure you want to change the base?
Conversation
🦙 MegaLinter status: ❌ ERROR
See detailed report in MegaLinter reports |
newrelic/core/config.py
Outdated
if s and len(s) == 12: | ||
try: | ||
account_id = int(s) | ||
return account_id | ||
except ValueError: | ||
pass | ||
# Only log a warning if s is set. | ||
if s: | ||
_logger.warning( | ||
"Improper configuration. cloud.aws.account_id = %s will be ignored because it is not a 12 digit number.", s | ||
) | ||
return None |
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.
if s and len(s) == 12: | |
try: | |
account_id = int(s) | |
return account_id | |
except ValueError: | |
pass | |
# Only log a warning if s is set. | |
if s: | |
_logger.warning( | |
"Improper configuration. cloud.aws.account_id = %s will be ignored because it is not a 12 digit number.", s | |
) | |
return None | |
if s and len(s) == 12 and s.isdigit(): | |
return int(s) | |
# Only log a warning if s is set. | |
if s: | |
_logger.warning( | |
f"Improper configuration. cloud.aws.account_id = {s} will be ignored because it is not a 12 digit number." | |
) | |
return None |
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.
isdigit looks cool! It looks like it also returns true if there is a power digit like ² which would result in a ValueError still being raised by the int cast though.
>>> s="01234²34"
>>> s.isdigit()
True
>>> int(s)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ValueError: invalid literal for int() with base 10: '01234²34'
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.
@hmstepanek you can use s.isdecimal()
instead!
In [1]: s="01234²34"
In [2]: s.isdecimal()
Out[2]: False
In [3]: s="01234234"
In [4]: s.isdecimal()
Out[4]: True
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #1249 +/- ##
==========================================
+ Coverage 81.15% 81.17% +0.01%
==========================================
Files 200 200
Lines 21953 21971 +18
Branches 3479 3482 +3
==========================================
+ Hits 17816 17834 +18
- Misses 2986 2987 +1
+ Partials 1151 1150 -1 ☔ View full report in Codecov by Sentry. 🚨 Try these New Features:
|
6233bf4
to
3b1053a
Compare
Overview
Add cloud.aws.account_id configuration setting. This is not used in this PR but will be used in future AWS linking for the user to provide the account_id when it cannot be derived by the instrumentation. See the Entity-Relationships agent spec.