-
Notifications
You must be signed in to change notification settings - Fork 100
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
Log Attribute Filtering #1008
Log Attribute Filtering #1008
Conversation
🦙 MegaLinter status: ❌ ERROR
See detailed report in MegaLinter reports |
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## develop-logging-attributes #1008 +/- ##
=============================================================
Coverage ? 81.11%
=============================================================
Files ? 190
Lines ? 19699
Branches ? 3443
=============================================================
Hits ? 15979
Misses ? 2728
Partials ? 992 ☔ View full report in Codecov by Sentry. |
541363c
to
81d1f44
Compare
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 couple small things but otherwise looks good.
newrelic/core/attribute.py
Outdated
c_attrs = attr_class() | ||
|
||
for attr_name, attr_value in attr_dict.items(): | ||
if attr_value is 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 we are adding user attributes to a transaction, we would capture an attribute {"foo": None} on the transaction as {"foo": "None"}. Here however, we drop the transaction instead. It seems like these should behave the same in both scenarios?
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.
This matches the implementation in resolve_user_attributes which is used by spans and trace segments, unsure why the behavior is different between these. I'm not super tied to one or the other, but this matches most closely to these other resolve functions from this file.
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.
span attributes actually behave the same way. The attributes actually appear to be processed twice which is different than logging user attributes and seems to be why the None is slipping past that check on spans and transactions. They are processed originally here which converts the None to the string "None" and then again in the resolve_user_attributes function. I'm not actually sure why there's a None check in there at all, since it doesn't seem like that would be reachable in the code. Either way, if you just take out the None check in this new function I think the behavior will be consistent across all the data types. I don't really see the point in processing them twice-I would think this would actually be a bad thing for performance. It seems like a mistake to me, but this code is complex so I could be missing something.
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.
Sorry got a little confused there when I was explaining that ^. It looks like the original function doesn't process the attributes again so they are only processed once but the point is that they are processed before the resolve_ function is called so the None gets converted to a "None" string.
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.
That feels like it might be a bug but there's nothing in the spec either way that I can see so let's stick with sending it up then. I changed the PR.
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'm inclined to agree with you on that but for now, I think it should be consistently wrong rather than a mix of the two depending on the event type.
@@ -902,6 +902,12 @@ def default_otlp_host(host): | |||
_settings.application_logging.forwarding.context_data.enabled = _environ_as_bool( | |||
"NEW_RELIC_APPLICATION_LOGGING_FORWARDING_CONTEXT_DATA_ENABLED", default=False | |||
) | |||
_settings.application_logging.forwarding.context_data.include = _environ_as_bool( | |||
"NEW_RELIC_APPLICATION_LOGGING_FORWARDING_CONTEXT_DATA_INCLUDE", default="" |
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.
We don't have env vars for any of the other attribute include/excludes. I wonder if we should include env vars at all for these?
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.
We could, but I'm not inclined to make that change with this PR.
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 think you may have miss-understood me here. I was suggesting that we could delete these env vars and not provide them since we don't provide them for any of the other attribute settings but if you want to keep these that's fine too.
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.
Looks good!
fb1f47d
into
develop-logging-attributes
* Log Forwarding User Attributes (#682) * Add context data setting Co-authored-by: Uma Annamalai <umaannamalai@users.noreply.github.com> Co-authored-by: Hannah Stepanek <hmstepanek@users.noreply.github.com> Co-authored-by: Lalleh Rafeei <lrafeei@users.noreply.github.com> * Update record_log_event signature with attributes * Logging attributes initial implementation * Fix settings attribute error * Update logging instrumentation with attributes * Update log handler API * Add loguru support for extra attrs * Add more explicit messaging to validator * Expanding testing for record_log_event * Expand record log event testing * Fix settings typo * Remove missing loguru attributes from test * Adjust safe log attr encoding * Correct py2 issues * Fix missing record attrs in logging. Co-authored-by: Uma Annamalai <umaannamalai@users.noreply.github.com> Co-authored-by: Hannah Stepanek <hmstepanek@users.noreply.github.com> Co-authored-by: Lalleh Rafeei <lrafeei@users.noreply.github.com> Co-authored-by: Hannah Stepanek <hstepanek@newrelic.com> * Log Attribute Filtering (#1008) * Expand validator for log events * Add settings for context data filtering * Add attribute filtering for log events * Linting * Apply suggestions from code review * Remove none check on attributes * Squashed commit of the following: commit 3962f54 Author: Uma Annamalai <uannamalai@newrelic.com> Date: Thu Jan 4 12:50:58 2024 -0800 Remove case sensitive check in ASGIBrowserMiddleware check. (#1017) * Remove case sensitive check in should_insert_html. * [Mega-Linter] Apply linters fixes * Remove header decoding. --------- Co-authored-by: umaannamalai <umaannamalai@users.noreply.github.com> commit c3314ae Author: Lalleh Rafeei <84813886+lrafeei@users.noreply.github.com> Date: Tue Jan 2 17:17:20 2024 -0800 Temporarily pin hypercorn version in tests (#1021) * Temporarily pin hypercorn to <0.16 * Temporarily pin hypercorn to <0.16 * Add comment to tox.ini --------- Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com> commit 1357145 Author: Uma Annamalai <uannamalai@newrelic.com> Date: Tue Jan 2 16:17:08 2024 -0800 Drop py27 from memcache testing. (#1018) commit 23f969f Author: Timothy Pansino <11214426+TimPansino@users.noreply.github.com> Date: Wed Dec 20 17:01:50 2023 -0800 Nonced CSP Support (#998) * Add nonce to CSP in browser agent * Adjust nonce position * Add testing for browser timing nonces commit 8bfd2b7 Author: Uma Annamalai <uannamalai@newrelic.com> Date: Mon Dec 18 13:58:10 2023 -0800 Remove RPM config workflow. (#1007) * Add Dictionary Log Message Support (#1014) * Add tests for logging's json logging * Upgrade record_log_event to handle dict logging * Update logging to capture dict messages * Add attributes for dict log messages * Implementation of JSON message filtering * Correct attributes only log behavior * Testing for logging attributes * Add logging context test for py2 * Logically separate attribute tests * Clean out imports * Fix failing tests * Remove logging instrumentation changes for new PR * Add test for record log event edge cases * Update record_log_event for code review * Fix truncation * Move safe_json_encode back to api.log as it's unused elsewhere * Black formatting * Add missing import * Fixup warning message --------- Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com> * Logging Attribute Instrumentation (#1015) * Add tests for logging's json logging * Upgrade record_log_event to handle dict logging * Update logging to capture dict messages * Add attributes for dict log messages * Implementation of JSON message filtering * Correct attributes only log behavior * Testing for logging attributes * Add logging context test for py2 * Logically separate attribute tests * Clean out imports * Fix failing tests * Linting * Ignore path hash * Fix linter errors * Fix linting issues * Apply suggestions from code review * StructLog Attribute Instrumentation (#1026) * Add tests for logging's json logging * Upgrade record_log_event to handle dict logging * Update logging to capture dict messages * Add attributes for dict log messages * Implementation of JSON message filtering * Correct attributes only log behavior * Testing for logging attributes * Add logging context test for py2 * Logically separate attribute tests * Clean out imports * Fix failing tests * Structlog cleanup * Attempting list instrumentation * Structlog attributes support Co-authored-by: Lalleh Rafeei <lrafeei@users.noreply.github.com> Co-authored-by: Uma Annamalai <umaannamalai@users.noreply.github.com> * Remove other frameworks changes * Bump tests * Change cache to lru cache * Linting * Remove TODO * Remove unnecessary check --------- Co-authored-by: Lalleh Rafeei <lrafeei@users.noreply.github.com> Co-authored-by: Uma Annamalai <umaannamalai@users.noreply.github.com> * Loguru Attribute Instrumentation (#1025) * Add tests for logging's json logging * Upgrade record_log_event to handle dict logging * Update logging to capture dict messages * Add attributes for dict log messages * Implementation of JSON message filtering * Correct attributes only log behavior * Testing for logging attributes * Add logging context test for py2 * Logically separate attribute tests * Clean out imports * Fix failing tests * Structlog cleanup * Attempting list instrumentation * Structlog attributes support Co-authored-by: Lalleh Rafeei <lrafeei@users.noreply.github.com> Co-authored-by: Uma Annamalai <umaannamalai@users.noreply.github.com> * Loguru instrumentation refactor * New attribute testing * Move exception settings * Clean up testing * Remove unneeded option * Remove other framework changes * [Mega-Linter] Apply linters fixes * Bump tests --------- Co-authored-by: Lalleh Rafeei <lrafeei@users.noreply.github.com> Co-authored-by: Uma Annamalai <umaannamalai@users.noreply.github.com> Co-authored-by: TimPansino <TimPansino@users.noreply.github.com> Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com> * Temporarily pin starlette tests * Update web_transaction.py --------- Co-authored-by: Uma Annamalai <umaannamalai@users.noreply.github.com> Co-authored-by: Hannah Stepanek <hmstepanek@users.noreply.github.com> Co-authored-by: Lalleh Rafeei <lrafeei@users.noreply.github.com> Co-authored-by: Hannah Stepanek <hstepanek@newrelic.com> Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com> Co-authored-by: TimPansino <TimPansino@users.noreply.github.com>
* Fix botocore tests (#973) * Bedrock Testing Infrastructure (#937) * Add AWS Bedrock testing infrastructure * Cache Package Version Lookups (#946) * Cache _get_package_version * Add Python 2.7 support to get_package_version caching * [Mega-Linter] Apply linters fixes * Bump tests --------- Co-authored-by: SlavaSkvortsov <29122694+SlavaSkvortsov@users.noreply.github.com> Co-authored-by: TimPansino <TimPansino@users.noreply.github.com> * Fix Redis Generator Methods (#947) * Fix scan_iter for redis * Replace generator methods * Update instance info instrumentation * Remove mistake from uninstrumented methods * Add skip condition to asyncio generator tests * Add skip condition to asyncio generator tests --------- Co-authored-by: Lalleh Rafeei <lrafeei@newrelic.com> Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com> * Automatic RPM System Updates (#948) * Checkout old action * Adding RPM action * Add dry run * Incorporating action into workflow * Wire secret into custom action * Enable action * Correct action name * Fix syntax * Fix quoting issues * Drop pre-verification. Does not work on python * Fix merge artifact * Remove OpenAI references --------- Co-authored-by: Uma Annamalai <uannamalai@newrelic.com> Co-authored-by: SlavaSkvortsov <29122694+SlavaSkvortsov@users.noreply.github.com> Co-authored-by: TimPansino <TimPansino@users.noreply.github.com> Co-authored-by: Lalleh Rafeei <lrafeei@newrelic.com> Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com> * Bedrock Sync Chat Completion Instrumentation (#953) * Add AWS Bedrock testing infrastructure * Squashed commit of the following: commit 2834663 Author: Timothy Pansino <11214426+TimPansino@users.noreply.github.com> Date: Mon Oct 9 17:42:05 2023 -0700 OpenAI Mock Backend (#929) * Add mock external openai server * Add mocked OpenAI server fixtures * Set up recorded responses. * Clean mock server to depend on http server * Linting * Pin flask version for flask restx tests. (#931) * Ignore new redis methods. (#932) Co-authored-by: Lalleh Rafeei <84813886+lrafeei@users.noreply.github.com> * Remove approved paths * Update CI Image (#930) * Update available python versions in CI * Update makefile with overrides * Fix default branch detection for arm builds --------- Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com> * Add mocking for embedding endpoint * [Mega-Linter] Apply linters fixes * Add ratelimit headers * [Mega-Linter] Apply linters fixes * Only get package version once (#928) * Only get package version once * Add disconnect method * Add disconnect method --------- Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com> * Add datalib dependency for embedding testing. * Add OpenAI Test Infrastructure (#926) * Add openai to tox * Add OpenAI test files. * Add test functions. * [Mega-Linter] Apply linters fixes --------- Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com> Co-authored-by: mergify[bot] <mergify[bot]@users.noreply.github.com> * Add mock external openai server * Add mocked OpenAI server fixtures * Set up recorded responses. * Clean mock server to depend on http server * Linting * Remove approved paths * Add mocking for embedding endpoint * [Mega-Linter] Apply linters fixes * Add ratelimit headers * [Mega-Linter] Apply linters fixes * Add datalib dependency for embedding testing. --------- Co-authored-by: Uma Annamalai <uannamalai@newrelic.com> Co-authored-by: Lalleh Rafeei <84813886+lrafeei@users.noreply.github.com> Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com> Co-authored-by: TimPansino <TimPansino@users.noreply.github.com> Co-authored-by: Hannah Stepanek <hstepanek@newrelic.com> Co-authored-by: mergify[bot] <mergify[bot]@users.noreply.github.com> commit db63d45 Author: Uma Annamalai <uannamalai@newrelic.com> Date: Mon Oct 2 15:31:38 2023 -0700 Add OpenAI Test Infrastructure (#926) * Add openai to tox * Add OpenAI test files. * Add test functions. * [Mega-Linter] Apply linters fixes --------- Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com> Co-authored-by: mergify[bot] <mergify[bot]@users.noreply.github.com> * Squashed commit of the following: commit 182c7a8 Author: Uma Annamalai <uannamalai@newrelic.com> Date: Fri Oct 13 10:12:55 2023 -0700 Add request/ response IDs. commit f6d13f8 Author: Uma Annamalai <uannamalai@newrelic.com> Date: Thu Oct 12 13:23:39 2023 -0700 Test cleanup. commit d057663 Author: Uma Annamalai <uannamalai@newrelic.com> Date: Tue Oct 10 10:23:00 2023 -0700 Remove commented code. commit dd29433 Author: Uma Annamalai <uannamalai@newrelic.com> Date: Tue Oct 10 10:19:01 2023 -0700 Add openai sync instrumentation. commit 2834663 Author: Timothy Pansino <11214426+TimPansino@users.noreply.github.com> Date: Mon Oct 9 17:42:05 2023 -0700 OpenAI Mock Backend (#929) * Add mock external openai server * Add mocked OpenAI server fixtures * Set up recorded responses. * Clean mock server to depend on http server * Linting * Pin flask version for flask restx tests. (#931) * Ignore new redis methods. (#932) Co-authored-by: Lalleh Rafeei <84813886+lrafeei@users.noreply.github.com> * Remove approved paths * Update CI Image (#930) * Update available python versions in CI * Update makefile with overrides * Fix default branch detection for arm builds --------- Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com> * Add mocking for embedding endpoint * [Mega-Linter] Apply linters fixes * Add ratelimit headers * [Mega-Linter] Apply linters fixes * Only get package version once (#928) * Only get package version once * Add disconnect method * Add disconnect method --------- Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com> * Add datalib dependency for embedding testing. * Add OpenAI Test Infrastructure (#926) * Add openai to tox * Add OpenAI test files. * Add test functions. * [Mega-Linter] Apply linters fixes --------- Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com> Co-authored-by: mergify[bot] <mergify[bot]@users.noreply.github.com> * Add mock external openai server * Add mocked OpenAI server fixtures * Set up recorded responses. * Clean mock server to depend on http server * Linting * Remove approved paths * Add mocking for embedding endpoint * [Mega-Linter] Apply linters fixes * Add ratelimit headers * [Mega-Linter] Apply linters fixes * Add datalib dependency for embedding testing. --------- Co-authored-by: Uma Annamalai <uannamalai@newrelic.com> Co-authored-by: Lalleh Rafeei <84813886+lrafeei@users.noreply.github.com> Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com> Co-authored-by: TimPansino <TimPansino@users.noreply.github.com> Co-authored-by: Hannah Stepanek <hstepanek@newrelic.com> Co-authored-by: mergify[bot] <mergify[bot]@users.noreply.github.com> commit db63d45 Author: Uma Annamalai <uannamalai@newrelic.com> Date: Mon Oct 2 15:31:38 2023 -0700 Add OpenAI Test Infrastructure (#926) * Add openai to tox * Add OpenAI test files. * Add test functions. * [Mega-Linter] Apply linters fixes --------- Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com> Co-authored-by: mergify[bot] <mergify[bot]@users.noreply.github.com> * Cache Package Version Lookups (#946) * Cache _get_package_version * Add Python 2.7 support to get_package_version caching * [Mega-Linter] Apply linters fixes * Bump tests --------- Co-authored-by: SlavaSkvortsov <29122694+SlavaSkvortsov@users.noreply.github.com> Co-authored-by: TimPansino <TimPansino@users.noreply.github.com> * Fix Redis Generator Methods (#947) * Fix scan_iter for redis * Replace generator methods * Update instance info instrumentation * Remove mistake from uninstrumented methods * Add skip condition to asyncio generator tests * Add skip condition to asyncio generator tests --------- Co-authored-by: Lalleh Rafeei <lrafeei@newrelic.com> Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com> * TEMP * Automatic RPM System Updates (#948) * Checkout old action * Adding RPM action * Add dry run * Incorporating action into workflow * Wire secret into custom action * Enable action * Correct action name * Fix syntax * Fix quoting issues * Drop pre-verification. Does not work on python * Fix merge artifact * Bedrock titan extraction nearly complete * Cleaning up titan bedrock implementation * TEMP * Tests for bedrock passing Co-authored-by: Lalleh Rafeei <lrafeei@users.noreply.github.com> * Cleaned up titan testing Co-authored-by: Lalleh Rafeei <lrafeei@users.noreply.github.com> Co-authored-by: Hannah Stepanek <hmstepanek@users.noreply.github.com> * Parametrized bedrock testing * Add support for AI21-J2 models * Change to dynamic no conversation id events * Drop all openai refs * [Mega-Linter] Apply linters fixes * Adding response_id and response_model * Drop python 3.7 tests for Hypercorn (#954) * Apply suggestions from code review * Remove unused import --------- Co-authored-by: Uma Annamalai <uannamalai@newrelic.com> Co-authored-by: SlavaSkvortsov <29122694+SlavaSkvortsov@users.noreply.github.com> Co-authored-by: TimPansino <TimPansino@users.noreply.github.com> Co-authored-by: Lalleh Rafeei <lrafeei@newrelic.com> Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com> Co-authored-by: Lalleh Rafeei <lrafeei@users.noreply.github.com> Co-authored-by: Hannah Stepanek <hmstepanek@users.noreply.github.com> Co-authored-by: Lalleh Rafeei <84813886+lrafeei@users.noreply.github.com> * Feature bedrock cohere instrumentation (#955) * Add AWS Bedrock testing infrastructure * Squashed commit of the following: commit 2834663 Author: Timothy Pansino <11214426+TimPansino@users.noreply.github.com> Date: Mon Oct 9 17:42:05 2023 -0700 OpenAI Mock Backend (#929) * Add mock external openai server * Add mocked OpenAI server fixtures * Set up recorded responses. * Clean mock server to depend on http server * Linting * Pin flask version for flask restx tests. (#931) * Ignore new redis methods. (#932) Co-authored-by: Lalleh Rafeei <84813886+lrafeei@users.noreply.github.com> * Remove approved paths * Update CI Image (#930) * Update available python versions in CI * Update makefile with overrides * Fix default branch detection for arm builds --------- Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com> * Add mocking for embedding endpoint * [Mega-Linter] Apply linters fixes * Add ratelimit headers * [Mega-Linter] Apply linters fixes * Only get package version once (#928) * Only get package version once * Add disconnect method * Add disconnect method --------- Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com> * Add datalib dependency for embedding testing. * Add OpenAI Test Infrastructure (#926) * Add openai to tox * Add OpenAI test files. * Add test functions. * [Mega-Linter] Apply linters fixes --------- Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com> Co-authored-by: mergify[bot] <mergify[bot]@users.noreply.github.com> * Add mock external openai server * Add mocked OpenAI server fixtures * Set up recorded responses. * Clean mock server to depend on http server * Linting * Remove approved paths * Add mocking for embedding endpoint * [Mega-Linter] Apply linters fixes * Add ratelimit headers * [Mega-Linter] Apply linters fixes * Add datalib dependency for embedding testing. --------- Co-authored-by: Uma Annamalai <uannamalai@newrelic.com> Co-authored-by: Lalleh Rafeei <84813886+lrafeei@users.noreply.github.com> Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com> Co-authored-by: TimPansino <TimPansino@users.noreply.github.com> Co-authored-by: Hannah Stepanek <hstepanek@newrelic.com> Co-authored-by: mergify[bot] <mergify[bot]@users.noreply.github.com> commit db63d45 Author: Uma Annamalai <uannamalai@newrelic.com> Date: Mon Oct 2 15:31:38 2023 -0700 Add OpenAI Test Infrastructure (#926) * Add openai to tox * Add OpenAI test files. * Add test functions. * [Mega-Linter] Apply linters fixes --------- Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com> Co-authored-by: mergify[bot] <mergify[bot]@users.noreply.github.com> * Squashed commit of the following: commit 182c7a8 Author: Uma Annamalai <uannamalai@newrelic.com> Date: Fri Oct 13 10:12:55 2023 -0700 Add request/ response IDs. commit f6d13f8 Author: Uma Annamalai <uannamalai@newrelic.com> Date: Thu Oct 12 13:23:39 2023 -0700 Test cleanup. commit d057663 Author: Uma Annamalai <uannamalai@newrelic.com> Date: Tue Oct 10 10:23:00 2023 -0700 Remove commented code. commit dd29433 Author: Uma Annamalai <uannamalai@newrelic.com> Date: Tue Oct 10 10:19:01 2023 -0700 Add openai sync instrumentation. commit 2834663 Author: Timothy Pansino <11214426+TimPansino@users.noreply.github.com> Date: Mon Oct 9 17:42:05 2023 -0700 OpenAI Mock Backend (#929) * Add mock external openai server * Add mocked OpenAI server fixtures * Set up recorded responses. * Clean mock server to depend on http server * Linting * Pin flask version for flask restx tests. (#931) * Ignore new redis methods. (#932) Co-authored-by: Lalleh Rafeei <84813886+lrafeei@users.noreply.github.com> * Remove approved paths * Update CI Image (#930) * Update available python versions in CI * Update makefile with overrides * Fix default branch detection for arm builds --------- Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com> * Add mocking for embedding endpoint * [Mega-Linter] Apply linters fixes * Add ratelimit headers * [Mega-Linter] Apply linters fixes * Only get package version once (#928) * Only get package version once * Add disconnect method * Add disconnect method --------- Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com> * Add datalib dependency for embedding testing. * Add OpenAI Test Infrastructure (#926) * Add openai to tox * Add OpenAI test files. * Add test functions. * [Mega-Linter] Apply linters fixes --------- Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com> Co-authored-by: mergify[bot] <mergify[bot]@users.noreply.github.com> * Add mock external openai server * Add mocked OpenAI server fixtures * Set up recorded responses. * Clean mock server to depend on http server * Linting * Remove approved paths * Add mocking for embedding endpoint * [Mega-Linter] Apply linters fixes * Add ratelimit headers * [Mega-Linter] Apply linters fixes * Add datalib dependency for embedding testing. --------- Co-authored-by: Uma Annamalai <uannamalai@newrelic.com> Co-authored-by: Lalleh Rafeei <84813886+lrafeei@users.noreply.github.com> Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com> Co-authored-by: TimPansino <TimPansino@users.noreply.github.com> Co-authored-by: Hannah Stepanek <hstepanek@newrelic.com> Co-authored-by: mergify[bot] <mergify[bot]@users.noreply.github.com> commit db63d45 Author: Uma Annamalai <uannamalai@newrelic.com> Date: Mon Oct 2 15:31:38 2023 -0700 Add OpenAI Test Infrastructure (#926) * Add openai to tox * Add OpenAI test files. * Add test functions. * [Mega-Linter] Apply linters fixes --------- Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com> Co-authored-by: mergify[bot] <mergify[bot]@users.noreply.github.com> * TEMP * Bedrock titan extraction nearly complete * Cleaning up titan bedrock implementation * TEMP * Tests for bedrock passing Co-authored-by: Lalleh Rafeei <lrafeei@users.noreply.github.com> * Cleaned up titan testing Co-authored-by: Lalleh Rafeei <lrafeei@users.noreply.github.com> Co-authored-by: Hannah Stepanek <hmstepanek@users.noreply.github.com> * Parametrized bedrock testing * Add support for AI21-J2 models * Change to dynamic no conversation id events * Add cohere model * Remove openai instrumentation from this branch * Remove OpenAI from newrelic/config.py --------- Co-authored-by: Uma Annamalai <uannamalai@newrelic.com> Co-authored-by: Tim Pansino <timpansino@gmail.com> Co-authored-by: Lalleh Rafeei <lrafeei@users.noreply.github.com> Co-authored-by: Hannah Stepanek <hmstepanek@users.noreply.github.com> * AWS Bedrock Embedding Instrumentation (#957) * AWS Bedrock embedding instrumentation * Correct symbol name * Add support for bedrock claude (#960) Co-authored-by: Timothy Pansino <11214426+TimPansino@users.noreply.github.com> * Combine Botocore Tests (#959) * Initial file migration * Enable DT on all span tests * Add pytest skip for older botocore versions * Fixup: app name merge conflict --------- Co-authored-by: Hannah Stepanek <hstepanek@newrelic.com> * Initial bedrock error tracing commit * Add status code to mock bedrock server * Updating error response recording logic * Work on bedrock errror tracing * Chat completion error tracing * Adding embedding error tracing * Delete comment * Update moto * Fix botocore tests & re-structure * [Mega-Linter] Apply linters fixes --------- Co-authored-by: Timothy Pansino <11214426+TimPansino@users.noreply.github.com> Co-authored-by: Uma Annamalai <uannamalai@newrelic.com> Co-authored-by: SlavaSkvortsov <29122694+SlavaSkvortsov@users.noreply.github.com> Co-authored-by: TimPansino <TimPansino@users.noreply.github.com> Co-authored-by: Lalleh Rafeei <lrafeei@newrelic.com> Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com> Co-authored-by: Lalleh Rafeei <lrafeei@users.noreply.github.com> Co-authored-by: Hannah Stepanek <hmstepanek@users.noreply.github.com> Co-authored-by: Lalleh Rafeei <84813886+lrafeei@users.noreply.github.com> Co-authored-by: Tim Pansino <timpansino@gmail.com> * Package Version Performance Regression (#970) * Fix package version performance regression * Update tests/agent_unittests/test_package_version_utils.py * Update tests/agent_unittests/test_package_version_utils.py * Update tests/agent_unittests/test_package_version_utils.py * Skip test in python 2 --------- Co-authored-by: Hannah Stepanek <hstepanek@newrelic.com> * Synthetics Info Header Support (#896) * Add support for new synthetics info header * Add testing for new synthetics headers * Linting * Fixup tests for synthetics headers * Add tests for snake and camel casing --------- Co-authored-by: Uma Annamalai <uannamalai@newrelic.com> * Fix CI Image Permissions for Non-Root Users (#969) * Use shared directory for pyenv * Simplify permissions --------- Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com> * Add package_capturing.enabled setting (#982) * Add capture_dependencies.enabled setting * Change setting name --------- Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com> * Revert "Synthetics Info Header Support (#896)" (#983) This reverts commit 3980127. * Remove accidental quote from api keys (#985) * Synthetics Info Header Support (#984) * Add support for new synthetics info header * Add testing for new synthetics headers * Linting * Fixup tests for synthetics headers * Add tests for snake and camel casing --------- Co-authored-by: Uma Annamalai <uannamalai@newrelic.com> * Docker CGroups v2 Utilization Support (#980) * Docker cgroups v2 utilization * Update docker cross agent tests with cgroups v2 * Updated cgroups detection logic * Remove unnecessary grouping --------- Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com> * Testing for supported frameworks in Python 3.12 (#897) * Replaced pkg_resources with importlib.metadata * Add tested/working tests to tox * importlib.metadata version and entry_points logic (#898) * Replaced pkg_resources with importlib.metadata * Fix entry_points logic for Py312 * Fix logic for entry_points * Check to see if list or string * Add Python 3.12 to container setup * Pin dev CI image SHA * Revert sha to latest * Datastores: Replace __version__ with get_package_version (#899) * Replaced pkg_resources with importlib.metadata * Replace pkg_resources in wrapt/importer.py * Add get_package_version from datastores * [Mega-Linter] Apply linters fixes * Push empty commit * Add assert statements for version --------- Co-authored-by: lrafeei <lrafeei@users.noreply.github.com> * Lambdas and Boto: Replace __version__ with get_package_version (#902) * Replaced pkg_resources with importlib.metadata * Replace pkg_resources in wrapt/importer.py * Add get_package_version for lambdas/boto * Unpin moto version in tests * Fix graphql imports in tox * Add 3.12 release candidate 2 to python versions * Add remaining working 3.12 tests * [Mega-Linter] Apply linters fixes * Trigger test run * [Mega-Linter] Apply linters fixes * Fix some merge issues * Fix some (more) merge issues * Remove old tests in tox * Remove unsupported Django testing (< v2.0) * Fix some tests for agent_features * Fix cherrypy test env in tox * Pin hypercorn (for now) * Add more py312 runs and unpin hypercorn * Adding known working test suites * Add remaining non-working test suites * Fix SKLearn Py 3.12 * Fix typos in odbc * Fix fixture scopes for hypercorn * Add settings patch to fix local testing --------- Co-authored-by: lrafeei <lrafeei@users.noreply.github.com> Co-authored-by: Timothy Pansino <11214426+TimPansino@users.noreply.github.com> Co-authored-by: Tim Pansino <timpansino@gmail.com> * Remove all references to NR staging (#989) Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com> * Fix bug with Structlog CallsiteParameter processor (#990) * Fix bug with CallsiteParameters. Co-authored-by: Tim Pansino <tpansino@newrelic.com> Co-authored-by: Hannah Stepanek <hstepanek@newrelic.com> * Add test for structlog processors. * Add test file for structlog processors. * Fix import ordering. * Move asssertion logic into test file. --------- Co-authored-by: Tim Pansino <tpansino@newrelic.com> Co-authored-by: Hannah Stepanek <hstepanek@newrelic.com> * Update wrapt (#993) * Update wrapt to 1.16.0 * Import duplicate functions directly from wrapt * Update object wrappers for wrapt 1.16.0 * Add warning to wrapt duplicate code * Linting * Use super rather than hard coded Object proxy * Formatting * Add test file for wrapper attributes * Linting * Add descriptions to assertions * Overhaul test suite for clarity * Move functions into fixtures * [Mega-Linter] Apply linters fixes * Bump tests * Fix typo * Larger timeout for protobuf --------- Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com> Co-authored-by: TimPansino <TimPansino@users.noreply.github.com> * Patch sentinel bug (#997) Co-authored-by: Timothy Pansino <TimPansino@users.noreply.github.com> Co-authored-by: Hannah Stepanek <hmstepanek@users.noreply.github.com> Co-authored-by: Uma Annamalai <umaannamalai@users.noreply.github.com> * Update flaskrestx testing (#1004) * Update flaskrestx testing * Update tastypie testing * Reformat tox * Fix tox typo --------- Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com> * Remove RPM config workflow. (#1007) * Nonced CSP Support (#998) * Add nonce to CSP in browser agent * Adjust nonce position * Add testing for browser timing nonces * Drop py27 from memcache testing. (#1018) * Temporarily pin hypercorn version in tests (#1021) * Temporarily pin hypercorn to <0.16 * Temporarily pin hypercorn to <0.16 * Add comment to tox.ini --------- Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com> * Remove case sensitive check in ASGIBrowserMiddleware check. (#1017) * Remove case sensitive check in should_insert_html. * [Mega-Linter] Apply linters fixes * Remove header decoding. --------- Co-authored-by: umaannamalai <umaannamalai@users.noreply.github.com> * Parallel Wheel Builds (#1024) * Fix import issue in tests * Parallelize wheel building and add muslinux support --------- Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com> * Deprecate get_browser_timing_footer API (#999) * Add nonce to CSP in browser agent * Adjust nonce position * Add testing for browser timing nonces * Deprecated browser timing footer APIs. * Full rip out of browser timing footer * Remove cross agent tests for RUM footer (per repo) * Update cat_map tests * Adjust browser header generation timing accuracy * Fix browser tests * Linting * Apply suggestions from code review --------- Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com> * Deprecate ObjectWrapper API (#996) * Update wrapt to 1.16.0 * Import duplicate functions directly from wrapt * Update object wrappers for wrapt 1.16.0 * Add warning to wrapt duplicate code * Linting * Use super rather than hard coded Object proxy * Formatting * Add test file for wrapper attributes * Unify ObjectWrapper with FunctionWrapper * Remove ObjectWrapper from httplib * Remove ObjectWrapper from tastypie * Replace ObjectWrapper use in console * Remove ObjectWrapper from celery * Remove extra import * Update agent APIs * Deprecate ObjectWrapper * Fix object wrapper imports * More import issues * Fix taskwrapper in celery * Pin last supported flask restx version for 3.7 * Undo tox changes * Change all api.object_wrapper references to use new locations * Fixup: callable_name import * Fixup: callable_name import --------- Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com> Co-authored-by: Hannah Stepanek <hstepanek@newrelic.com> * Add checkout actions to deploy workflow (#1027) * Remove Slack section in CONTRIBUTING.rst. (#1029) * Update newrelic/hooks/external_botocore.py * Update newrelic/hooks/external_botocore.py * Update newrelic/hooks/external_botocore.py * Update newrelic/hooks/external_botocore.py * Update tox.ini * Remove unused imports /github/workspace/newrelic/api/web_transaction.py:36:1: F401 'newrelic.core.attribute.create_attributes' imported but unused /github/workspace/newrelic/api/web_transaction.py:36:1: F401 'newrelic.core.attribute.process_user_attribute' imported but unused /github/workspace/newrelic/api/web_transaction.py:37:1: F401 'newrelic.core.attribute_filter.DST_NONE' imported but unused * Fix lint errors /github/workspace/newrelic/common/utilization.py:20:1: F401 'threading' imported but unused /github/workspace/newrelic/common/utilization.py:183:26: E711 comparison to None should be 'if cond is None:' * Fix lint errors /github/workspace/newrelic/console.py:74:1: E402 module level import not at top of file /github/workspace/newrelic/console.py:75:1: E402 module level import not at top of file /github/workspace/newrelic/console.py:76:1: E402 module level import not at top of file /github/workspace/newrelic/console.py:77:1: E402 module level import not at top of file * Fix lint errors /github/workspace/newrelic/core/internal_metrics.py:15:1: F401 'functools' imported but unused /github/workspace/newrelic/core/internal_metrics.py:16:1: F401 'sys' imported but unused /github/workspace/newrelic/core/internal_metrics.py:17:1: F401 'types' imported but unused * Fix lint errors /github/workspace/newrelic/hooks/external_feedparser.py:16:1: F401 'types' imported but unused * Fix lint errors /github/workspace/newrelic/hooks/framework_webpy.py:15:1: F401 'sys' imported but unused * Fix lint errors /github/workspace/newrelic/hooks/template_genshi.py:15:1: F401 'types' imported but unused * Fix lint errors /github/workspace/tests/agent_features/test_configuration.py:49:1: E302 expected 2 blank lines, found 1 * Fix lint errors /github/workspace/tests/agent_features/test_error_events.py:30:1: F401 'testing_support.validators.validate_error_trace_attributes.validate_error_trace_attributes' imported but unused * Fix lint errors /github/workspace/tests/cross_agent/test_docker_container_id.py:16:1: F401 'mock' imported but unused /github/workspace/tests/cross_agent/test_docker_container_id_v2.py:16:1: F401 'mock' imported but unused * Fix lint errors /github/workspace/tests/framework_bottle/test_application.py:18:1: F401 'webtest' imported but unused /github/workspace/tests/framework_bottle/test_application.py:37:1: F811 redefinition of unused 'version' from line 19 /github/workspace/tests/framework_bottle/test_application.py:229:5: F401 'newrelic.agent' imported but unused * Fix lint errors /github/workspace/tests/logger_structlog/conftest.py:15:1: F401 'logging' imported but unused /github/workspace/tests/logger_structlog/conftest.py:19:1: F401 'testing_support.fixtures.collector_available_fixture' imported but unused * Fix lint errors /github/workspace/tests/testing_support/external_fixtures.py:57:5: E125 continuation line with same indent as next logical line /github/workspace/tests/testing_support/external_fixtures.py:113:9: E303 too many blank lines (2) /github/workspace/tests/testing_support/external_fixtures.py:154:19: W292 no newline at end of file * Fix lint errors /github/workspace/tests/testing_support/fixtures.py:813:1: W293 blank line contains whitespace * Fix lint errors /github/workspace/tests/testing_support/validators/validate_synthetics_event.py:21:1: E302 expected 2 blank lines, found 1 /github/workspace/tests/testing_support/validators/validate_synthetics_event.py:71:1: W391 blank line at end of file * Logging Attributes (#1033) * Log Forwarding User Attributes (#682) * Add context data setting Co-authored-by: Uma Annamalai <umaannamalai@users.noreply.github.com> Co-authored-by: Hannah Stepanek <hmstepanek@users.noreply.github.com> Co-authored-by: Lalleh Rafeei <lrafeei@users.noreply.github.com> * Update record_log_event signature with attributes * Logging attributes initial implementation * Fix settings attribute error * Update logging instrumentation with attributes * Update log handler API * Add loguru support for extra attrs * Add more explicit messaging to validator * Expanding testing for record_log_event * Expand record log event testing * Fix settings typo * Remove missing loguru attributes from test * Adjust safe log attr encoding * Correct py2 issues * Fix missing record attrs in logging. Co-authored-by: Uma Annamalai <umaannamalai@users.noreply.github.com> Co-authored-by: Hannah Stepanek <hmstepanek@users.noreply.github.com> Co-authored-by: Lalleh Rafeei <lrafeei@users.noreply.github.com> Co-authored-by: Hannah Stepanek <hstepanek@newrelic.com> * Log Attribute Filtering (#1008) * Expand validator for log events * Add settings for context data filtering * Add attribute filtering for log events * Linting * Apply suggestions from code review * Remove none check on attributes * Squashed commit of the following: commit 3962f54 Author: Uma Annamalai <uannamalai@newrelic.com> Date: Thu Jan 4 12:50:58 2024 -0800 Remove case sensitive check in ASGIBrowserMiddleware check. (#1017) * Remove case sensitive check in should_insert_html. * [Mega-Linter] Apply linters fixes * Remove header decoding. --------- Co-authored-by: umaannamalai <umaannamalai@users.noreply.github.com> commit c3314ae Author: Lalleh Rafeei <84813886+lrafeei@users.noreply.github.com> Date: Tue Jan 2 17:17:20 2024 -0800 Temporarily pin hypercorn version in tests (#1021) * Temporarily pin hypercorn to <0.16 * Temporarily pin hypercorn to <0.16 * Add comment to tox.ini --------- Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com> commit 1357145 Author: Uma Annamalai <uannamalai@newrelic.com> Date: Tue Jan 2 16:17:08 2024 -0800 Drop py27 from memcache testing. (#1018) commit 23f969f Author: Timothy Pansino <11214426+TimPansino@users.noreply.github.com> Date: Wed Dec 20 17:01:50 2023 -0800 Nonced CSP Support (#998) * Add nonce to CSP in browser agent * Adjust nonce position * Add testing for browser timing nonces commit 8bfd2b7 Author: Uma Annamalai <uannamalai@newrelic.com> Date: Mon Dec 18 13:58:10 2023 -0800 Remove RPM config workflow. (#1007) * Add Dictionary Log Message Support (#1014) * Add tests for logging's json logging * Upgrade record_log_event to handle dict logging * Update logging to capture dict messages * Add attributes for dict log messages * Implementation of JSON message filtering * Correct attributes only log behavior * Testing for logging attributes * Add logging context test for py2 * Logically separate attribute tests * Clean out imports * Fix failing tests * Remove logging instrumentation changes for new PR * Add test for record log event edge cases * Update record_log_event for code review * Fix truncation * Move safe_json_encode back to api.log as it's unused elsewhere * Black formatting * Add missing import * Fixup warning message --------- Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com> * Logging Attribute Instrumentation (#1015) * Add tests for logging's json logging * Upgrade record_log_event to handle dict logging * Update logging to capture dict messages * Add attributes for dict log messages * Implementation of JSON message filtering * Correct attributes only log behavior * Testing for logging attributes * Add logging context test for py2 * Logically separate attribute tests * Clean out imports * Fix failing tests * Linting * Ignore path hash * Fix linter errors * Fix linting issues * Apply suggestions from code review * StructLog Attribute Instrumentation (#1026) * Add tests for logging's json logging * Upgrade record_log_event to handle dict logging * Update logging to capture dict messages * Add attributes for dict log messages * Implementation of JSON message filtering * Correct attributes only log behavior * Testing for logging attributes * Add logging context test for py2 * Logically separate attribute tests * Clean out imports * Fix failing tests * Structlog cleanup * Attempting list instrumentation * Structlog attributes support Co-authored-by: Lalleh Rafeei <lrafeei@users.noreply.github.com> Co-authored-by: Uma Annamalai <umaannamalai@users.noreply.github.com> * Remove other frameworks changes * Bump tests * Change cache to lru cache * Linting * Remove TODO * Remove unnecessary check --------- Co-authored-by: Lalleh Rafeei <lrafeei@users.noreply.github.com> Co-authored-by: Uma Annamalai <umaannamalai@users.noreply.github.com> * Loguru Attribute Instrumentation (#1025) * Add tests for logging's json logging * Upgrade record_log_event to handle dict logging * Update logging to capture dict messages * Add attributes for dict log messages * Implementation of JSON message filtering * Correct attributes only log behavior * Testing for logging attributes * Add logging context test for py2 * Logically separate attribute tests * Clean out imports * Fix failing tests * Structlog cleanup * Attempting list instrumentation * Structlog attributes support Co-authored-by: Lalleh Rafeei <lrafeei@users.noreply.github.com> Co-authored-by: Uma Annamalai <umaannamalai@users.noreply.github.com> * Loguru instrumentation refactor * New attribute testing * Move exception settings * Clean up testing * Remove unneeded option * Remove other framework changes * [Mega-Linter] Apply linters fixes * Bump tests --------- Co-authored-by: Lalleh Rafeei <lrafeei@users.noreply.github.com> Co-authored-by: Uma Annamalai <umaannamalai@users.noreply.github.com> Co-authored-by: TimPansino <TimPansino@users.noreply.github.com> Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com> * Temporarily pin starlette tests * Update web_transaction.py --------- Co-authored-by: Uma Annamalai <umaannamalai@users.noreply.github.com> Co-authored-by: Hannah Stepanek <hmstepanek@users.noreply.github.com> Co-authored-by: Lalleh Rafeei <lrafeei@users.noreply.github.com> Co-authored-by: Hannah Stepanek <hstepanek@newrelic.com> Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com> Co-authored-by: TimPansino <TimPansino@users.noreply.github.com> * Obfuscate License Keys in Logs (#1031) * Obfuscate license keys * Run formatter * Fix None errors in obfuscate_license_key * Obfuscate API keys from headers * Add lowercase api-key to denied headers * Change audit log header filters to be case insensitive --------- Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com> * Instrument Lantern vectorstore * Fix instrumentation for openai 1.8.0 --------- Co-authored-by: Timothy Pansino <11214426+TimPansino@users.noreply.github.com> Co-authored-by: Uma Annamalai <uannamalai@newrelic.com> Co-authored-by: SlavaSkvortsov <29122694+SlavaSkvortsov@users.noreply.github.com> Co-authored-by: TimPansino <TimPansino@users.noreply.github.com> Co-authored-by: Lalleh Rafeei <lrafeei@newrelic.com> Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com> Co-authored-by: Lalleh Rafeei <lrafeei@users.noreply.github.com> Co-authored-by: Hannah Stepanek <hmstepanek@users.noreply.github.com> Co-authored-by: Lalleh Rafeei <84813886+lrafeei@users.noreply.github.com> Co-authored-by: Tim Pansino <timpansino@gmail.com> Co-authored-by: Tim Pansino <tpansino@newrelic.com> Co-authored-by: Uma Annamalai <umaannamalai@users.noreply.github.com>
Overview