-
Notifications
You must be signed in to change notification settings - Fork 64
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
Improve logging and validation for license keys. #2982
base: main
Are you sure you want to change the base?
Conversation
} | ||
|
||
// return string.Empty instead of null to allow caching and prevent checking repeatedly | ||
Log.Finest("No valid license key found."); |
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.
Seems like we might want to log this at a higher level -- info or warning?
|
||
// If the key is the default value from newrelic.config, we return the default value | ||
// AgentManager.AssertAgentEnabled() relies on this behavior and will throw an exception if the key is the default value | ||
if (candidateKey.Value.Equals("REPLACE_WITH_LICENSE_KEY")) |
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.
A small suggestion: a lot of our sample code uses variations of YOUR_LICENSE_KEY
for the environment variable. Maybe if we search for the string "license", it's a good bet that they haven't filled it in? That should cover us for all three key sources, and may be more helpful than the fall-through invalid key log messages.
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #2982 +/- ##
==========================================
+ Coverage 82.16% 82.19% +0.03%
==========================================
Files 473 473
Lines 30364 30355 -9
Branches 3388 3384 -4
==========================================
+ Hits 24948 24950 +2
+ Misses 4617 4605 -12
- Partials 799 800 +1
Flags with carried forward coverage won't be shown. Click here to find out more.
|
Description
Adds an additional warning when the agent receives a HTTP 401 Unauthorized response from the collector. This occurs when the key is not valid (for many reasons).
Expands the validation logic from the license key in DefaultConfiguration to:
Unit tests have been expanded to cover the new logic.
Note: valid in this context means that it is not null or whitespace, exactly 40 ASCII characters from 0x21 to 0x7E, or "REPLACE_WITH_LICENSE_KEY".
Fixes #2969
Fixes #2783
Author Checklist
Reviewer Checklist