Skip to content
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

Deprecate ObjectWrapper API #996

Merged
merged 34 commits into from
Jan 5, 2024
Merged

Deprecate ObjectWrapper API #996

merged 34 commits into from
Jan 5, 2024

Conversation

TimPansino
Copy link
Contributor

Overview

Context

ObjectWrapper was previously used in instrumentation but was simply a custom and more manual version of FunctionWrapper from wrapt. There is no functional difference in how it is used today in the agent and should be deprecated and removed.

Changes

  • Deprecate ObjectWrapper API.
  • Add CallableObjectProxy to public APIs to replace some of the functionality of ObjectWrapper
  • Add missing NewRelicContextFormatter supportability wrapping in newrelic.agent.
  • Remove instrumentation references to ObjectWrapper, replacing with FunctionWrapper or ObjectProxy.
  • Remove custom ObjectWrapper implementation and instead create a pass through to FunctionWrapper.

Copy link

github-actions bot commented Dec 6, 2023

🦙 MegaLinter status: ❌ ERROR

Descriptor Linter Files Fixed Errors Elapsed time
✅ PYTHON bandit 16 0 6.3s
✅ PYTHON black 16 13 0 2.21s
❌ PYTHON flake8 16 51 1.09s
✅ PYTHON isort 16 15 0 0.28s
❌ PYTHON pylint 16 45 9.72s

See detailed report in MegaLinter reports
Set VALIDATE_ALL_CODEBASE: true in mega-linter.yml to validate all sources, not only the diff

MegaLinter is graciously provided by OX Security

@mergify mergify bot removed the merge-conflicts label Dec 6, 2023
@TimPansino TimPansino marked this pull request as ready for review December 6, 2023 21:04
@TimPansino TimPansino requested a review from a team December 6, 2023 21:04
@codecov-commenter
Copy link

codecov-commenter commented Dec 8, 2023

Codecov Report

Attention: 13 lines in your changes are missing coverage. Please review.

Comparison is base (27c874c) 81.05% compared to head (59b66c3) 81.07%.

Files Patch % Lines
newrelic/config.py 10.00% 9 Missing ⚠️
newrelic/common/object_wrapper.py 50.00% 2 Missing ⚠️
newrelic/api/solr_trace.py 50.00% 1 Missing ⚠️
newrelic/core/internal_metrics.py 50.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #996      +/-   ##
==========================================
+ Coverage   81.05%   81.07%   +0.01%     
==========================================
  Files         190      190              
  Lines       19595    19594       -1     
  Branches     3421     3419       -2     
==========================================
+ Hits        15883    15885       +2     
+ Misses       2728     2727       -1     
+ Partials      984      982       -2     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@mergify mergify bot removed the tests-failing label Dec 11, 2023
@mergify mergify bot removed the merge-conflicts label Dec 15, 2023
Copy link
Contributor

@hmstepanek hmstepanek left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In general this looks good. I had one question about the import path change. It looks correct to me but I think we should change all of them or none of them as there are a lot more occurrences than just this one.

newrelic/hooks/framework_webpy.py Outdated Show resolved Hide resolved
@mergify mergify bot removed the tests-failing label Jan 3, 2024
@mergify mergify bot added the tests-failing label Jan 4, 2024
@hmstepanek hmstepanek added this to the v9.4.0 milestone Jan 4, 2024
@mergify mergify bot added the tests-failing label Jan 5, 2024
Copy link
Contributor

@hmstepanek hmstepanek left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks like we are importing callable_name from object_wrappers when it should be importing from object_names. Note the linter caught this issue but the tests did not. One of those rare cases where the linter caught something super important.

newrelic/hooks/framework_pylons.py Show resolved Hide resolved
@mergify mergify bot removed the tests-failing label Jan 5, 2024
Copy link
Contributor

@hmstepanek hmstepanek left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this looks good now. Maybe just have a quick review of the commits I made before merging as a double check?

@TimPansino TimPansino merged commit 32c66d8 into main Jan 5, 2024
48 of 49 checks passed
@TimPansino TimPansino deleted the remove-objectwrapper branch January 5, 2024 23:38
hmstepanek added a commit that referenced this pull request Jan 11, 2024
* 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)

* Remove duplicated function

* Pin starlette before 0.35.1

* Change starlette pin

---------

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: umaannamalai <umaannamalai@users.noreply.github.com>
Co-authored-by: Hannah Stepanek <hstepanek@newrelic.com>
hmstepanek added a commit that referenced this pull request Jan 17, 2024
* 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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants