internal/log: allow RecordLogger to ignore certain logs #1810
+83
−87
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.
What does this PR do?
Some unit tests in the tracer assert based on the content or positioning of log messages (example). When new log messages are added (e.g. by appsec) these tests will fail. To workaround this, we've previously introduced a
removeAppsec
method that removes strings which containappsec:
from recorded logs. This PR introduces an alternate solution to directly ignore certain substrings usingRecordLogger
while logging.More specifically, this PR:
testLogger
from the tracer package.testLogger
has a near identical implementation toRecordLogger
in theinternal/log
package, so we can just useRecordLogger
instead.Ignore
method toRecordLogger
that allows us to ignore logs which contain certain substrings.RecordLogger
andIgnore
to ignore appsec logsMotivation
Introduces a slightly friendlier interface for ignoring logs in comparison to creating custom functions that remove log messages, which may be useful when new features that use logging (e.g. instrumentation telemetry) are introduced.
Describe how to test/QA your changes
Reviewer's Checklist
Triage
milestone is set.