From 709227d4184cf86b0cd963d6413c2fdbef65e150 Mon Sep 17 00:00:00 2001 From: Timothy Pansino <11214426+TimPansino@users.noreply.github.com> Date: Thu, 14 Sep 2023 14:40:58 -0700 Subject: [PATCH] Fix merge conflicts for develop scikitlearn (#922) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Exclude command line functionality from test coverage (#855) * FIX: resilient environment settings (#825) if the application uses generalimport to manage optional depedencies, it's possible that generalimport.MissingOptionalDependency is raised. In this case, we should not report the module as it is not actually loaded and is not a runtime dependency of the application. Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com> Co-authored-by: Hannah Stepanek * Replace drop_transaction logic by using transaction context manager (#832) * Replace drop_transaction call * [Mega-Linter] Apply linters fixes * Empty commit to start tests * Change logic in BG Wrappers --------- Co-authored-by: lrafeei Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com> * Upgrade to Pypy38 for TypedDict (#861) * Fix base branch * Revert tox dependencies * Replace all pypy37 with pypy38 * Remove action.yml file * Push Empty Commit * Fix skip_missing_interpreters behavior * Fix skip_missing_interpreters behavior * Pin dev CI image sha * Remove unsupported Tornado tests * Add latest tests to Tornado * Remove pypy38 (for now) --------- Co-authored-by: Tim Pansino * Add profile_trace testing (#858) * Include isort stdlibs for determining stdlib modules * Use isort & sys to eliminate std & builtin modules Previously, the logic would fail to identify third party modules installed within the local user socpe. This fixes that issue by skipping builtin and stdlib modules by name, instead of attempting to identify third party modules based on file paths. * Handle importlib_metadata.version being a callable * Add isort into third party notices * [Mega-Linter] Apply linters fixes * Remove Python 2.7 and pypy2 testing (#835) * Change setup-python to @v2 for py2.7 * Remove py27 and pypy testing * Fix syntax errors * Fix comma related syntax errors * Fix more issues in tox * Remove gearman test * Containerized CI Pipeline (#836) * Revert "Remove Python 2.7 and pypy2 testing (#835)" This reverts commit abb6405d2bfd629ed83f48e8a17b4a28e3a3c352. * Containerize CI process * Publish new docker container for CI images * Rename github actions job * Copyright tag scripts * Drop debug line * Swap to new CI image * Move pip install to just main python * Remove libcurl special case from tox * Install special case packages into main image * Remove unused packages * Remove all other triggers besides manual * Add make run command * Cleanup small bugs * Fix CI Image Tagging (#838) * Correct templated CI image name * Pin pypy2.7 in image * Fix up scripting * Temporarily Restore Old CI Pipeline (#841) * Restore old pipelines * Remove python 2 from setup-python * Rework CI Pipeline (#839) Change pypy to pypy27 in tox. Fix checkout logic Pin tox requires * Fix Tests on New CI (#843) * Remove non-root user * Test new CI image * Change pypy to pypy27 in tox. * Fix checkout logic * Fetch git tags properly * Pin tox requires * Adjust default db settings for github actions * Rename elasticsearch services * Reset to new pipelines * [Mega-Linter] Apply linters fixes * Fix timezone * Fix docker networking * Pin dev image to new sha * Standardize gearman DB settings * Fix elasticsearch settings bug * Fix gearman bug * Add missing odbc headers * Add more debug messages * Swap out dev ci image * Fix required virtualenv version * Swap out dev ci image * Swap out dev ci image * Remove aioredis v1 for EOL * Add coverage paths for docker container * Unpin ci container --------- Co-authored-by: TimPansino * Trigger tests * Add testing for profile trace. * [Mega-Linter] Apply linters fixes * Ignore __call__ from coverage on profile_trace. * [Mega-Linter] Apply linters fixes --------- Co-authored-by: Hannah Stepanek Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com> Co-authored-by: hmstepanek Co-authored-by: Lalleh Rafeei <84813886+lrafeei@users.noreply.github.com> Co-authored-by: Timothy Pansino <11214426+TimPansino@users.noreply.github.com> Co-authored-by: TimPansino Co-authored-by: umaannamalai * Add Transaction API Tests (#857) * Test for suppress_apdex_metric * Add custom_metrics tests * Add distributed_trace_headers testing in existing tests * [Mega-Linter] Apply linters fixes * Remove redundant if-statement * Ignore deprecated transaction function from coverage * [Mega-Linter] Apply linters fixes * Push empty commit * Update newrelic/api/transaction.py --------- Co-authored-by: lrafeei Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com> Co-authored-by: Timothy Pansino <11214426+TimPansino@users.noreply.github.com> Co-authored-by: Uma Annamalai * Add tests for jinja2. (#842) * Add tests for jinja2. * [Mega-Linter] Apply linters fixes * Update tox.ini Co-authored-by: Timothy Pansino <11214426+TimPansino@users.noreply.github.com> --------- Co-authored-by: umaannamalai Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com> Co-authored-by: Timothy Pansino <11214426+TimPansino@users.noreply.github.com> * Add tests for newrelic/config.py (#860) Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com> * Fix starlette testing matrix for updated behavior. (#869) Co-authored-by: Lalleh Rafeei Co-authored-by: Hannah Stepanek Co-authored-by: Uma Annamalai * Correct Serverless Distributed Tracing Logic (#870) * Fix serverless logic for distributed tracing * Test stubs * Collapse testing changes * Add negative testing to regular DT test suite * Apply linter fixes * [Mega-Linter] Apply linters fixes --------- Co-authored-by: TimPansino * Fix Kafka CI (#863) * Reenable kafka testing * Add kafka dev lib * Sync install python with devcontainer * Fix kafka local host setting * Drop set -u flag * Pin CI image dev sha * Add parallel flag to kafka * Fix proper exit status * Build librdkafka from source * Updated dev image sha * Remove coverage exclusions * Add new options to better emulate GHA * Reconfigure kafka networking Co-authored-by: Hannah Stepanek * Fix kafka ports on GHA * Run kafka tests serially * Separate kafka consumer groups * Put CI container makefile back * Remove confluent kafka Py27 for latest * Roll back ubuntu version update * Update dev ci sha --------- Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com> Co-authored-by: Hannah Stepanek * Change image tag to latest (#871) * Change image tag to latest * Use built sha * Fixup * Replace w/ latest * Add full version for pypy3.8 to tox (#872) * Add full version for pypy3.8 * Remove solrpy from tests * Instrument RedisCluster (#809) * Add instrumentation for RedisCluster * Add tests for redis cluster * Ignore Django instrumentation from older versions (#859) * Ignore Django instrumentation from older versions * Ignore Django instrumentation from older versions * Fix text concatenation * Update newrelic/hooks/framework_django.py Co-authored-by: Hannah Stepanek * Update newrelic/hooks/framework_django.py Co-authored-by: Hannah Stepanek --------- Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com> Co-authored-by: Hannah Stepanek * Modify postgresql tests to include WITH query (#885) * Modify postgresql tests to include WITH * [Mega-Linter] Apply linters fixes --------- Co-authored-by: lrafeei * Develop redis addons (#888) * Added separate instrumentation for redis.asyncio.client (#808) * Added separate instrumentation for redis.asyncio.client Merge main branch updates Add tests for newrelic/config.py (#860) Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com> * Modify redis tests * removed redis.asyncio from aioredis instrumentation removed aioredis instrumentation in redis asyncio client removed redis.asyncio from aioredis instrumentation --------- Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com> Co-authored-by: Lalleh Rafeei Co-authored-by: Lalleh Rafeei <84813886+lrafeei@users.noreply.github.com> * Redis asyncio testing (#881) * Add/modify redis asyncio tests * Change to psubscribe * Tweak redis async tests/instrumentation * [Mega-Linter] Apply linters fixes * Push empty commit * Exclude older instrumentation from coverage * Resolve requested testing changes * Tweak async pubsub test * Fix pubsub test --------- Co-authored-by: lrafeei * Remove aioredis and aredis from tox (#891) * Remove aioredis and aredis from tox * Add aredis and aioredis to coverage ignore * Push empty commit * Fix codecov ignore file --------- Co-authored-by: Ahmed Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com> Co-authored-by: lrafeei * Add google firestore instrumentation (#893) * Add instrumentation for Google Firestore documents and collections (#876) * Initial GCP firestore instrumentation commit. * Add testing for documents and collections + test generators Co-authored-by: Tim Pansino Co-authored-by: Lalleh Rafeei Co-authored-by: Hannah Stepanek * Add co-authors. Co-authored-by: Tim Pansino Co-authored-by: Lalleh Rafeei Co-authored-by: Hannah Stepanek * Add co-authors. Co-authored-by: Tim Pansino Co-authored-by: Lalleh Rafeei Co-authored-by: Hannah Stepanek * Trim whitespace --------- Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com> Co-authored-by: Tim Pansino Co-authored-by: Lalleh Rafeei Co-authored-by: Hannah Stepanek Co-authored-by: Timothy Pansino <11214426+TimPansino@users.noreply.github.com> * Firestore CI (#877) * Add firestore CI runner * Correct hook file name * Setup emulator credentials * Swap dependency to firestore alone * Hacky setup for firestore * Fix firestore hostname * Ensure firestore connection * Fix CI issues * Refactor Firestore Hooks (#879) * Remove unnecessary instrumentation * Simplify existing instrumentation * Remove unnecessary settings lookups * Firestore Sync Client Instrumentation (#880) * Remove unnecessary instrumentation * Simplify existing instrumentation * Remove unnecessary settings lookups * Client instrumentation * Add query and aggregation query instrumentation * Fix deprecation warning * Simplify collection lookup * Combine query test files * Rename methods for clarity * Instrument Firestore batching * Add transaction instrumentation * Consumer iterators on <=Py38 * Allow better parallelization in firestore tests * Clean out unnecessary code * [Mega-Linter] Apply linters fixes * Better parallelization safeguards * Add collection group instrumentation * [Mega-Linter] Apply linters fixes * Change imports to native APIs * Swap target functions to lambdas * Convert exercise functions to fixtures --------- Co-authored-by: TimPansino * Update datastore_trace wrapper to take instance info (#883) * Update datastore trace wrapper to take instance info. * [Mega-Linter] Apply linters fixes * Make instance info args optional. * [Mega-Linter] Apply linters fixes * Add datastore trace testing. * Add background task decorator. * [Mega-Linter] Apply linters fixes * Fix typo in validator. --------- Co-authored-by: umaannamalai * Async Generator Wrapper (#884) * Add async generator wrapper * Add no harm test * Remove anext calls * Add graphql traces to decorator testing * Remove pypy generator gc logic --------- Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com> * Trace Async Wrapper Argument (#886) * Add async_wrapper to datastore_trace api * Add async wrapper argument to all trace APIs * Add testing for automatic and manual asyncwrappers * Firstore Async Instrumentation (#882) * Remove unnecessary instrumentation * Simplify existing instrumentation * Remove unnecessary settings lookups * Client instrumentation * Add query and aggregation query instrumentation * Fix deprecation warning * Simplify collection lookup * Combine query test files * Rename methods for clarity * Instrument Firestore batching * Add transaction instrumentation * Consumer iterators on <=Py38 * Add async generator wrapper * Allow better parallelization in firestore tests * Fix issue in async generator wrapper * Add async client instrumentation * Squashed commit of the following: commit 9d411e00e37476be4ce0c40c7e64e71c4a09cfc6 Author: Tim Pansino Date: Wed Jul 26 15:57:39 2023 -0700 Clean out unnecessary code commit cb550bad9bb9e15edfdcef5dd361022448e0348f Author: Tim Pansino Date: Wed Jul 26 14:27:01 2023 -0700 Allow better parallelization in firestore tests * Add async collection instrumentation * Add async document instrumentation * Async Query instrumentation * Add async batch instrumentation * Add instrumentation for AsyncTransaction * Squashed commit of the following: commit c836f8f377f9391af86452e81b59f834330b18fb Author: TimPansino Date: Thu Jul 27 19:54:35 2023 +0000 [Mega-Linter] Apply linters fixes commit 02a55a11017fd27b45f06ab719a33917cf185aac Author: Tim Pansino Date: Thu Jul 27 12:46:46 2023 -0700 Add collection group instrumentation commit ab1f4ff5d2e88e6def42fa3c99c619f9673ce918 Author: Tim Pansino Date: Thu Jul 27 12:00:33 2023 -0700 Better parallelization safeguards commit fa5f39a2b037421cf017a062901c0ea1ec2b9723 Author: TimPansino Date: Wed Jul 26 22:59:11 2023 +0000 [Mega-Linter] Apply linters fixes commit 9d411e00e37476be4ce0c40c7e64e71c4a09cfc6 Author: Tim Pansino Date: Wed Jul 26 15:57:39 2023 -0700 Clean out unnecessary code commit cb550bad9bb9e15edfdcef5dd361022448e0348f Author: Tim Pansino Date: Wed Jul 26 14:27:01 2023 -0700 Allow better parallelization in firestore tests * Remove reset_firestore * Re-merge of test_query * Use public API imports * Add async collection group instrumentation * Refactor exercise functions to fixtures * Squashed commit of the following: commit 09c5e11498b4c200057190e859f8151241c421f3 Author: Tim Pansino Date: Wed Aug 2 14:33:24 2023 -0700 Add testing for automatic and manual asyncwrappers commit fc3ef6bfb8cb2f9cd6c8ffdf7bfd953be41cc974 Author: Tim Pansino Date: Wed Aug 2 14:33:05 2023 -0700 Add async wrapper argument to all trace APIs commit 479f9e236e2212e0f9cdf51627996068027acd82 Merge: faf3cccea edd1f94b0 Author: Tim Pansino Date: Wed Aug 2 13:44:24 2023 -0700 Merge remote-tracking branch 'origin/develop-google-firestore-instrumentation' into feature-async-wrapper-argument commit edd1f94b0f601a2674da4e594b777bae0eed6643 Author: Timothy Pansino <11214426+TimPansino@users.noreply.github.com> Date: Wed Aug 2 13:40:51 2023 -0700 Async Generator Wrapper (#884) * Add async generator wrapper * Add no harm test * Remove anext calls * Add graphql traces to decorator testing * Remove pypy generator gc logic --------- Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com> commit faf3ccceae127128aff81fc59d95dd3f49699a3c Author: Tim Pansino Date: Mon Jul 31 15:10:56 2023 -0700 Add async_wrapper to datastore_trace api * Remove custom wrapper code from firestore * Undo wrapper edits --------- Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com> * Firestore Instance Info (#887) * Add instance info testing to query * Instance info for query.stream * Squashed commit of the following: commit 1c426c84b2c8ee36c6a40bf6bbfcb862c90db1cf Author: umaannamalai Date: Mon Jul 31 23:01:49 2023 +0000 [Mega-Linter] Apply linters fixes commit 7687c0695783fe40a86e705ec9790c19248f0c1e Author: Uma Annamalai Date: Mon Jul 31 15:47:09 2023 -0700 Make instance info args optional. commit 53f8400ce0d0e8b53bfcaba4b54f898a63e3d68b Author: umaannamalai Date: Mon Jul 31 22:23:20 2023 +0000 [Mega-Linter] Apply linters fixes commit d95d477cdfd54de4490211e3c4dd7de2504057f3 Author: Uma Annamalai Date: Mon Jul 31 15:20:41 2023 -0700 Update datastore trace wrapper to take instance info. * Add instance info testing to all apis * Separate transaction instance info tests * Implement all instance info getters * Squashed commit of the following: commit db3561e54f773730f269455ae323865b6230a613 Merge: 844e556ab edd1f94b0 Author: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com> Date: Wed Aug 2 22:10:32 2023 +0000 Merge branch 'develop-google-firestore-instrumentation' into feature-firstore-async-instrumentation commit 844e556abfbca63573e51a2647141e07ce9e942f Author: Tim Pansino Date: Wed Aug 2 15:09:49 2023 -0700 Remove custom wrapper code from firestore commit ad2999ff50b6b17b5774f69ca8116ee901f47474 Author: Tim Pansino Date: Wed Aug 2 14:58:38 2023 -0700 Squashed commit of the following: commit 09c5e11498b4c200057190e859f8151241c421f3 Author: Tim Pansino Date: Wed Aug 2 14:33:24 2023 -0700 Add testing for automatic and manual asyncwrappers commit fc3ef6bfb8cb2f9cd6c8ffdf7bfd953be41cc974 Author: Tim Pansino Date: Wed Aug 2 14:33:05 2023 -0700 Add async wrapper argument to all trace APIs commit 479f9e236e2212e0f9cdf51627996068027acd82 Merge: faf3cccea edd1f94b0 Author: Tim Pansino Date: Wed Aug 2 13:44:24 2023 -0700 Merge remote-tracking branch 'origin/develop-google-firestore-instrumentation' into feature-async-wrapper-argument commit edd1f94b0f601a2674da4e594b777bae0eed6643 Author: Timothy Pansino <11214426+TimPansino@users.noreply.github.com> Date: Wed Aug 2 13:40:51 2023 -0700 Async Generator Wrapper (#884) * Add async generator wrapper * Add no harm test * Remove anext calls * Add graphql traces to decorator testing * Remove pypy generator gc logic --------- Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com> commit faf3ccceae127128aff81fc59d95dd3f49699a3c Author: Tim Pansino Date: Mon Jul 31 15:10:56 2023 -0700 Add async_wrapper to datastore_trace api commit edd1f94b0f601a2674da4e594b777bae0eed6643 Author: Timothy Pansino <11214426+TimPansino@users.noreply.github.com> Date: Wed Aug 2 13:40:51 2023 -0700 Async Generator Wrapper (#884) * Add async generator wrapper * Add no harm test * Remove anext calls * Add graphql traces to decorator testing * Remove pypy generator gc logic --------- Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com> commit 29579fc2ecd8199b0227922425556d3279f17e57 Merge: 4a8a3fe04 7596fb40d Author: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com> Date: Wed Aug 2 19:54:09 2023 +0000 Merge branch 'develop-google-firestore-instrumentation' into feature-firstore-async-instrumentation commit 7596fb40dd739572a4224978173d61f5c9da9b3d Author: Uma Annamalai Date: Wed Aug 2 12:53:29 2023 -0700 Update datastore_trace wrapper to take instance info (#883) * Update datastore trace wrapper to take instance info. * [Mega-Linter] Apply linters fixes * Make instance info args optional. * [Mega-Linter] Apply linters fixes * Add datastore trace testing. * Add background task decorator. * [Mega-Linter] Apply linters fixes * Fix typo in validator. --------- Co-authored-by: umaannamalai commit 4a8a3fe0486801ab88f7ddac05e89d96b6ae6fc0 Merge: 7bf6f4978 dcc92a914 Author: Tim Pansino Date: Mon Jul 31 14:51:20 2023 -0700 Merge remote-tracking branch 'origin/develop-google-firestore-instrumentation' into feature-firstore-async-instrumentation commit 7bf6f4978f058206c3cfb2b9c0efed963ca610ef Author: Tim Pansino Date: Mon Jul 31 14:34:26 2023 -0700 Refactor exercise functions to fixtures commit d3e473204bb2d840d6a73ec1b5de897e11e193ee Author: Tim Pansino Date: Thu Jul 27 13:20:37 2023 -0700 Add async collection group instrumentation commit 5902515202f7c7985b787bd00bb66b7f89699e19 Author: Tim Pansino Date: Thu Jul 27 13:09:13 2023 -0700 Use public API imports commit 9266924d8ef965852dec415973d7d9699031f011 Author: Tim Pansino Date: Thu Jul 27 13:04:19 2023 -0700 Re-merge of test_query commit b6bc9a47f28f2da29a8c5bf77dd37273c83a3757 Author: Tim Pansino Date: Thu Jul 27 13:01:27 2023 -0700 Remove reset_firestore commit 87fbe6203def1e583ff8fea58d4d6a0e70bfa606 Author: Tim Pansino Date: Thu Jul 27 13:00:37 2023 -0700 Squashed commit of the following: commit c836f8f377f9391af86452e81b59f834330b18fb Author: TimPansino Date: Thu Jul 27 19:54:35 2023 +0000 [Mega-Linter] Apply linters fixes commit 02a55a11017fd27b45f06ab719a33917cf185aac Author: Tim Pansino Date: Thu Jul 27 12:46:46 2023 -0700 Add collection group instrumentation commit ab1f4ff5d2e88e6def42fa3c99c619f9673ce918 Author: Tim Pansino Date: Thu Jul 27 12:00:33 2023 -0700 Better parallelization safeguards commit fa5f39a2b037421cf017a062901c0ea1ec2b9723 Author: TimPansino Date: Wed Jul 26 22:59:11 2023 +0000 [Mega-Linter] Apply linters fixes commit 9d411e00e37476be4ce0c40c7e64e71c4a09cfc6 Author: Tim Pansino Date: Wed Jul 26 15:57:39 2023 -0700 Clean out unnecessary code commit cb550bad9bb9e15edfdcef5dd361022448e0348f Author: Tim Pansino Date: Wed Jul 26 14:27:01 2023 -0700 Allow better parallelization in firestore tests commit e04ec6f7959001558951bb0b716bf7c2f9062380 Author: Tim Pansino Date: Thu Jul 27 11:55:44 2023 -0700 Add instrumentation for AsyncTransaction commit 6b7fc79b2466bc729d07878193643f989f95bf04 Author: Tim Pansino Date: Wed Jul 26 16:56:04 2023 -0700 Add async batch instrumentation commit c392e78fba4cde9334dc7e1b40a7a6531e9b672c Author: Tim Pansino Date: Wed Jul 26 16:36:03 2023 -0700 Async Query instrumentation commit aab244bcb45cc5cb6cb2be870a8182da95128582 Author: Tim Pansino Date: Wed Jul 26 16:20:58 2023 -0700 Add async document instrumentation commit 3fb6a6cd32c3a7fcfa1874aeb68e2cf3c23ea85c Author: Tim Pansino Date: Wed Jul 26 16:11:17 2023 -0700 Add async collection instrumentation commit 7851baf92ece9d7aa85c0286b32aa8249d3b2191 Author: Tim Pansino Date: Wed Jul 26 15:58:12 2023 -0700 Squashed commit of the following: commit 9d411e00e37476be4ce0c40c7e64e71c4a09cfc6 Author: Tim Pansino Date: Wed Jul 26 15:57:39 2023 -0700 Clean out unnecessary code commit cb550bad9bb9e15edfdcef5dd361022448e0348f Author: Tim Pansino Date: Wed Jul 26 14:27:01 2023 -0700 Allow better parallelization in firestore tests commit c49a1cf0b079c53f61192de589efa32044712b58 Author: Tim Pansino Date: Wed Jul 26 15:54:13 2023 -0700 Add async client instrumentation commit c857358cc89d064fa7dddb5a6a0f2069496db708 Author: Tim Pansino Date: Wed Jul 26 15:53:21 2023 -0700 Fix issue in async generator wrapper commit 5693dd2f3ca2c23bc170b1e2cd9ea87862d9d80f Author: Tim Pansino Date: Wed Jul 26 14:27:01 2023 -0700 Allow better parallelization in firestore tests commit fbe40eaf4eb9da57fd6cb881328087fedc0dc2d9 Author: Tim Pansino Date: Wed Jul 26 14:22:53 2023 -0700 Add async generator wrapper commit b9a91e574a8e183249549f223bb4090226467f80 Author: Tim Pansino Date: Wed Jul 26 12:21:25 2023 -0700 Consumer iterators on <=Py38 commit ef06df5dca7d6e6f0f7e96700544514b99e9c132 Author: Tim Pansino Date: Wed Jul 26 12:01:25 2023 -0700 Add transaction instrumentation commit 2ce45c85ebf0a6951884c675d6cad77486988b7b Author: Tim Pansino Date: Tue Jul 25 15:55:50 2023 -0700 Instrument Firestore batching commit d17b62f720c98216fe5e80df13234ab84ccd9924 Author: Tim Pansino Date: Tue Jul 25 15:31:48 2023 -0700 Rename methods for clarity commit 6214f0bc5926b0b76acdf4bad612cc2710eeb3c7 Author: Tim Pansino Date: Tue Jul 25 15:30:23 2023 -0700 Combine query test files commit b4e87005d6b15c777563dc9ba1885612b384c61e Author: Tim Pansino Date: Tue Jul 25 15:23:03 2023 -0700 Simplify collection lookup commit a0c78a22dbd4ac43d7ef0cb444614683ce76142b Author: Tim Pansino Date: Tue Jul 25 15:18:51 2023 -0700 Fix deprecation warning commit 44598cc271e4a8d5d2962284894a9547372efdbe Author: Tim Pansino Date: Tue Jul 25 15:15:13 2023 -0700 Add query and aggregation query instrumentation commit b9eaa5b35144be48243e6315b8c64ad599d6a4de Author: Tim Pansino Date: Tue Jul 25 13:33:42 2023 -0700 Client instrumentation commit 19f5a48326b6aa51c1deb7e3acc2e5e6ba6ef749 Author: Tim Pansino Date: Mon Jul 24 15:55:52 2023 -0700 Remove unnecessary settings lookups commit ba7850a06a48005612e59b44c1a509d28f99f86d Author: Tim Pansino Date: Mon Jul 24 15:44:54 2023 -0700 Simplify existing instrumentation commit e07ffc3efb351769614c67425f7352dc4217e6be Author: Tim Pansino Date: Mon Jul 24 15:44:10 2023 -0700 Remove unnecessary instrumentation * Add instance info to async client * Simplify lookup logic for instance info * Precompute closures for memory usage * Undo wrapper edits * Fix typo * Change port from int ot str * Fix Generator Wrappers (#890) * Fix async wrapper implementations * Add regression testing --------- Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com> --------- Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com> Co-authored-by: Tim Pansino Co-authored-by: Lalleh Rafeei Co-authored-by: Hannah Stepanek Co-authored-by: Timothy Pansino <11214426+TimPansino@users.noreply.github.com> Co-authored-by: TimPansino Co-authored-by: umaannamalai * Base Devcontainer on CI Image (#873) * Base devcontainer on ci image * Build arm image on main * Fix syntax --------- Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com> * Add support for redis v5. (#895) * Instrumentat methods added in redis v5 release. * Update metrics in redis tests. * Use importlib.metadata first to avoid deprecation warnings (#878) * Use importlib.metadata first to avoid deprecation warnings * Use get distribution name of module before fetching its version * Add support for Python versions < 3.9 * Fix conditional for packages_distributions * Linter fixes * Remove fixture in favor of test skips --------- Co-authored-by: Lalleh Rafeei <84813886+lrafeei@users.noreply.github.com> * Fix Normalization Rules (#894) * Fix cross agent tests to run from anywhere * Cover failures in rules engine with testing Co-authored-by: Lalleh Rafeei Co-authored-by: Hannah Stepanek Co-authored-by: Uma Annamalai * Patch metrics not being properly ignored * Patch normalization rule init default arguments * Clean up to match other fixture setups --------- Co-authored-by: Lalleh Rafeei Co-authored-by: Hannah Stepanek Co-authored-by: Uma Annamalai Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com> * Fix database instance metric bug (#905) * Remove enable_datastore_instance_feature This was added in 2016 when the database instance feature was first developed. It appears to be a method of gating this feature internally within the agent at the time that it was implemented. However, it is not needed now and database instrumentations that don't call this are actually broken in that the metric that is used to create the service map (namely `Datastore/instance/MySQL//`) does not get created due to not calling this enable feature function. * Rename cross agent test * Add Database/instance metric check * Add check for both path and file (#907) * Update structlog instrumentation. (#865) * Add structlog instrumentation. (#685) * Add initial structlog instrumentation. * Cleanup. * Add processor filtering and attribute testing. * Add more filtering tests. * Add co-authors. Co-authored-by: Tim Pansino Co-authored-by: Lalleh Rafeei * Remove pylint codes from flake8 config (#701) * Create pytest fixtures and cleanup tests. Co-authored-by: Tim Pansino Co-authored-by: Lalleh Rafeei Co-authored-by: Timothy Pansino <11214426+TimPansino@users.noreply.github.com> Co-authored-by: Hannah Stepanek * Updates to release structlog instrumentation. * Update pypy testing versions. * Update from pypy37 to pypy38 for structlog. --------- Co-authored-by: Tim Pansino Co-authored-by: Lalleh Rafeei Co-authored-by: Timothy Pansino <11214426+TimPansino@users.noreply.github.com> Co-authored-by: Hannah Stepanek Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com> * GraphQL Async Instrumentation Support (#908) * Add GraphQL Server Sanic Instrumentation * Co-authored-by: Timothy Pansino Co-authored-by: Uma Annamalai * Add co-authors Co-authored-by: Timothy Pansino Co-authored-by: Uma Annamalai * Comment out Copyright notice message Co-authored-by: Timothy Pansino Co-authored-by: Uma Annamalai * Finalize Sanic testing * Fix flask framework details with callable * Parametrized testing for graphql-server * GraphQL Async Resolvers Co-authored-by: Lalleh Rafeei Co-authored-by: Uma Annamalai * GraphQL Proper Coro and Promise Support (#508) * Fix GraphQL async issues * Fix nonlocal binding issues in python 2 * Fix promises with async graphql * Issues with promises * Fix promises in graphql2 * Fixed all graphql async issues * Fix Py27 quirks * Update tox * Fix importing paths of graphqlserver * Fix broken import path * Unpin pypy37 * Fix weird import issues * Fix graphql impl coros (#522) * Strawberry Async Updates (#521) * Parameterize strawberry tests * Remove duplicate functions * Fix strawberry version testing * Updates * Finalize strawberry updates * Clean out code * Ariadne Async Testing (#523) * Parameterize ariadne tests * Fixing ariadne tests * Fixing ariadne middleware * Set 0 extra spans for graphql core tests * Add spans attr to strawberry tests * Graphene Async Testing (#524) * Graphene Async Testing * Fix missing extra spans numbers * Graphene promise tests * Fix py2 imports * Removed unused __init__ * Update code level metrics validator for py2 * Unify graphql testing imports * Fix ariadne imports * Fix other imports * Fix import issues * Merge main into develop-graphql-async (#892) * Update Versioning Scheme (#651) * Update versioning scheme to 3 semver digits * Fix version indexing Co-authored-by: Hannah Stepanek Co-authored-by: Lalleh Rafeei * Remove version truncation * [Mega-Linter] Apply linters fixes * Bump tests Co-authored-by: Hannah Stepanek Co-authored-by: Lalleh Rafeei Co-authored-by: TimPansino * Fix Trace Finalizer Crashes (#652) * Patch crashes in various traces with None settings * Add tests for graphql trace types to unittests * Add test to ensure traces don't crash in finalizer * [Mega-Linter] Apply linters fixes * Bump tests Co-authored-by: TimPansino Co-authored-by: Lalleh Rafeei <84813886+lrafeei@users.noreply.github.com> * Add usage tracking metrics for Kafka clients. (#658) * Add usage tracking metrics for Kafka clients. * Fix double import lint error * [Mega-Linter] Apply linters fixes * Create version util file and add metrics to consumer. * Address linting errors. * Add missing semi-colon. * [Mega-Linter] Apply linters fixes * Bump tests. Co-authored-by: Hannah Stepanek Co-authored-by: hmstepanek Co-authored-by: umaannamalai * Deprecate add_custom_parameter(s) API (#655) * Deprecate add_custom_parameter(s) API * Fix unicode tests and some pylint errors * Fix more pylint errors * Revert "Fix more pylint errors" This reverts commit 807ec1c5c40fe421300ccdcd6fedd81f288dce2c. * Edit deprecation message in add_custom_parameters * Add usage metrics for Daphne and Hypercorn. (#665) * Add usage metrics for Daphne and Hypercorn. * [Mega-Linter] Apply linters fixes Co-authored-by: umaannamalai * Fix Flask view support in Code Level Metrics (#664) * Fix Flask view support in Code Level Metrics Co-authored-by: Lalleh Rafeei Co-authored-by: Hannah Stepanek Co-authored-by: Uma Annamalai * [Mega-Linter] Apply linters fixes * Bump tests * Fix CLM tests for flaskrest * [Mega-Linter] Apply linters fixes * Bump tests Co-authored-by: Lalleh Rafeei Co-authored-by: Hannah Stepanek Co-authored-by: Uma Annamalai Co-authored-by: TimPansino Co-authored-by: Uma Annamalai * Fix aioredis version crash (#661) Co-authored-by: Uma Annamalai * Add double wrapped testing for Hypercorn and Daphne and dispatcher argument to WSGI API. (#667) * Add double wrapped app tests. * Fix linting errors. * [Mega-Linter] Apply linters fixes * Add co-authors. Co-authored-by: Tim Pansino Co-authored-by: Lalleh Rafeei Co-authored-by: Hannah Stepanek Co-authored-by: umaannamalai Co-authored-by: Tim Pansino Co-authored-by: Lalleh Rafeei Co-authored-by: Hannah Stepanek * Add Python 3.11 Support (#654) * Add py311 tests * Fix typo * Added 3.11 support for aiohttp framework Co-authored-by: Timothy Pansino * Set up environment to run Python 3.11 Co-authored-by: Timothy Pansino * Add Python 3.11 support for agent_features Co-authored-by: Timothy Pansino * Partial Python 3.11 support added for Tornado Co-authored-by: Timothy Pansino * Adjust postgres versions * Fix tornado install path locally * Remove aioredis py311 tests * Update 3.11 to dev in tests * Fix sanic instrumentation and imp/importlib deprecation Co-authored-by: Timothy Pansino * Simplify wheel build options * Update cibuildwheel for 3.11 * Remove falconmaster py311 test Co-authored-by: Lalleh Rafeei Co-authored-by: Timothy Pansino * Remove devcontainer submodule (#669) * Uncomment NewRelicContextFormatter from agent.py (#676) * Fix botocore tests for botocore v1.28.1+ (#675) * Fix botocore tests for botocore v1.28.1+ Co-authored-by: Timothy Pansino * Fix boto3 tests for botocore v1.28.1+ Co-authored-by: Timothy Pansino Co-authored-by: Hannah Stepanek Co-authored-by: Uma Annamalai * Fix boto3 tests for python 2.7 Co-authored-by: Timothy Pansino Co-authored-by: Hannah Stepanek Co-authored-by: Uma Annamalai Co-authored-by: Timothy Pansino Co-authored-by: Hannah Stepanek Co-authored-by: Uma Annamalai Co-authored-by: Timothy Pansino <11214426+TimPansino@users.noreply.github.com> * Feature increased custom event limit (#674) * Update reservoir size for custom events. * [Mega-Linter] Apply linters fixes * Increase custom event limit. (#666) * Remove duplicated CUSTOM_EVENT_RESERVOIR_SIZE Co-authored-by: Tim Pansino Co-authored-by: TimPansino Co-authored-by: Timothy Pansino <11214426+TimPansino@users.noreply.github.com> Co-authored-by: Uma Annamalai * Add python 3.11 stable release to GHA (#671) * Double kafka test runners (#677) Co-authored-by: Hannah Stepanek * Fix failing flask_rest tests (#683) * Pin flask-restx in flask_rest tests for 2.7 flask-restx dropped support for 2.7 in 1.0.1. * Drop support for flask-restplus flask-restx replaced flask-restplus. flask-restplus's latest version supports 3.6 which we don't even support anymore. * Fix failing botocore tests (#684) * Change queue url for botocore>=1.29.0 botocore >=1.29.0 uses sqs.us-east-1.amazonaws.com url instead of queue.amazonaws.com. * Use tuple version instead of str * Change botocore129->botocore128 * Add record_log_event to public api (#681) * Add patch for sentry SDK to correct ASGI v2/v3 detection. (#680) * Add patch for sentry to correct ASGI v2/v3 detection. Co-authored-by: Tim Pansino Co-authored-by: Lalleh Rafeei Co-authored-by: Hannah Stepanek * [Mega-Linter] Apply linters fixes Co-authored-by: Tim Pansino Co-authored-by: Lalleh Rafeei Co-authored-by: Hannah Stepanek Co-authored-by: umaannamalai Co-authored-by: Timothy Pansino <11214426+TimPansino@users.noreply.github.com> * Update pip install command (#688) * Validator transfer from fixtures.py to validators directory, Part 1 (#672) * Move validate_transaction_metrics to validators directory * Comment out original validate_transaction_metrics from fixtures.py * Move validate_time_metrics_outside_transaction to validators directory * Move validate_internal_metrics into validators directory and fixed validate_transaction_metrics * Move validate_transaction_errors into validators directory * Move validate_application_errors into validators directory * Move validate_custom_parameters into validators directory * Move validate_synthetics_event into validators directory * Move validate_transaction_event_attributes into validators directory * Move validate_non_transaction_error_event into validators directory * Fix import issues * Fix (more) import issues * Fix validate_transaction_metrics import in aioredis * Remove commented code from fixtures.py * Initialize ExternalNode properties (#687) Co-authored-by: Hannah Stepanek * Fix package_version_utils.py logic (#689) * Fix package_version_utils.py logic Co-authored-by: Timothy Pansino Co-authored-by: Hannah Stepanek Co-authored-by: Uma Annamalai * Move description of func into func itself * typecast lists into tuples * Remove breakpoints * Empty _test_package_version_utils.py * Make changes to the test Co-authored-by: Timothy Pansino Co-authored-by: Hannah Stepanek Co-authored-by: Uma Annamalai * Pin Github Actions Runner to Ubuntu 20 for Py27 (#698) * Pin Github Actions runner to ubuntu 20 for Py27 * Upgrade setup-python * Fix Confluent Kafka Producer Arguments (#699) * Add confluentkafka test for posargs/kwargs * Fix confluent kafka topic argument bug * More sensible producer arguments * Fix tornado master tests & instrument redis 4.3.5 (#695) * Remove 3.7 testing of tornado master tornadomaster dropped support for 3.7 * Instrument new redis 4.3.5 client methods Co-authored-by: Lalleh Rafeei <84813886+lrafeei@users.noreply.github.com> Co-authored-by: Timothy Pansino <11214426+TimPansino@users.noreply.github.com> * Remove pylint codes from flake8 config (#701) * Validator transfer from fixtures.py to validators directory, Part 2 (#690) * Move validate_transaction_metrics to validators directory * Comment out original validate_transaction_metrics from fixtures.py * Move validate_time_metrics_outside_transaction to validators directory * Move validate_internal_metrics into validators directory and fixed validate_transaction_metrics * Move validate_transaction_errors into validators directory * Move validate_application_errors into validators directory * Move validate_custom_parameters into validators directory * Move validate_synthetics_event into validators directory * Move validate_transaction_event_attributes into validators directory * Move validate_non_transaction_error_event into validators directory * Move validate_application_error_trace_count into validators directory * Move validate_application_error_event_count into validators directory * Move validate_synthetics_transaction_trace into validators directory * Move validate_tt_collector_json to validators directory * Move validate_transaction_trace_attributes into validator directory * Move validate_transaction_error_trace_attributes into validator directory * Move validate_error_trace_collector_json into validator directory * Move validate_error_event_collector_json into validator directory * Move validate_transaction_event_collector_json into validator directory * Fix import issues from merge * Fix some pylint errors * Revert 'raise ValueError' to be PY2 compatible * Delete commented lines * Fix bug in celery where works don't report data (#696) This fixes Missing information from Celery workers when using MAX_TASKS_PER_CHILD issue. Previously, if celery was run with the --loglevel=INFO flag, an agent instance would be created for the main celery process and after the first worker shutdown, all following worker's agent instances would point to that agent instance instead of creating a new instance. This was root caused to incorrectly creating an agent instance when application activate was not set. Now no agent instance will be created for the main celery process. * Reverts removal of flask_restful hooks. (#705) * Update instrumented methods in redis. (#707) Co-authored-by: Lalleh Rafeei Co-authored-by: Uma Annamalai Co-authored-by: Hannah Stepanek Co-authored-by: Lalleh Rafeei Co-authored-by: Uma Annamalai Co-authored-by: Hannah Stepanek * Add TraceCache Guarded Iteration (#704) * Add MutableMapping API to TraceCache * Update trace cache usage to use guarded APIs. * [Mega-Linter] Apply linters fixes * Bump tests * Fix keys iterator * Comments for trace cache methods * Reorganize tests * Fix fixture refs * Fix testing refs * [Mega-Linter] Apply linters fixes * Bump tests * Upper case constant Co-authored-by: TimPansino Co-authored-by: Lalleh Rafeei <84813886+lrafeei@users.noreply.github.com> * Fix Type Constructor Classes in Code Level Metrics (#708) * Fix CLM exception catching * Reorganize CLM Tests * Add type constructor tests to CLM * Fix line number * Pin tox version * Fix lambda tests in CLM * Fix lint issues * Turn helper func into pytest fixture Co-authored-by: Hannah Stepanek * Fix sanic and starlette tests (#734) * Fix sanic tests * Tweak test fix for sanic * Remove test for v18.12 in sanic (no longer supported) * Pin starlette latest to v0.23.1 (for now) * Add comment in tox about pinned starlette version * Add methods to instrument (#738) * Add card to instrumented methods in Redis (#740) * Add DevContainer (#711) * Add devcontainer setup * Add newrelic env vars to passenv * Add default extensions * Add devcontainer instructions to contributing docs * Convert smart quotes in contributing docs. * Apply proper RST formatting * [Mega-Linter] Apply linters fixes * Add GHCR to prerequisites * [Mega-Linter] Apply linters fixes * Bump tests Co-authored-by: TimPansino * Module classmethod fix (#662) * Fix function_wrapper calls to module * Fix wrapper in pika hook * Revert elasticsearch instrumentation * Revert some wrap_function_wrappers to orig * Remove comments/breakpoints * Fix hooks in elasticsearch Co-authored-by: Timothy Pansino <11214426+TimPansino@users.noreply.github.com> * Fix log decorating to be JSON compatible (#736) * Initial addition of JSON capability * Add NR-LINKING metadata JSON combatibility * Remove breakpoint * Hardcode local log decorating tests * Tweak linking metatdata parsing/adding * Revert "Fix log decorating to be JSON compatible" (#746) * Revert "Fix log decorating to be JSON compatible (#736)" This reverts commit 0db5fee1e5d44b0791dc517ac9f5d88d1240a340. * [Mega-Linter] Apply linters fixes * Trigger tests Co-authored-by: hmstepanek * Add apdexPerfZone attribute to Transaction. (#753) Co-authored-by: Enriqueta De Leon Co-authored-by: Kate Anderson Co-authored-by: Mary Martinez Co-authored-by: Enriqueta De Leon Co-authored-by: Kate Anderson Co-authored-by: Mary Martinez Co-authored-by: Hannah Stepanek * Fix tests in starlette v0.23.1 (#752) * Fix tests in starlette v0.23.1 * Fix conditional tests * Add comment to bg_task test * Support `redis.asyncio` (#744) * Support `redis.asyncio` * Fix `flake8` issues Co-authored-by: Timothy Pansino <11214426+TimPansino@users.noreply.github.com> * Redis Asyncio Testing (#750) * Add standardized method for package version tuples * Adapt aioredis tests to redis.asyncio * Standardize version tuple * Refresh uninstrumented redis methods * Fix aioredis version checking * Remove aioredis version function * CodeCov Integration (#710) * Add aggregate coverage settings to tox.ini * Refactor coverage fixture for GHA * Send coverage data files * Linter fixes * Configure codecov report * Yield cov handle from fixture * Fix empty coverage fixture * Specify artifact download dir * Find coverage files with find command * Add concurrency cancelling to github actions * uncomment test deps * Fix or symbol * Fix concurrency groups * Linter fixes * Add comment for yield None in fixture * [Mega-Linter] Apply linters fixes * Bump Tests --------- Co-authored-by: TimPansino * Mergify (#761) * Add mergify config file * Remove priority * Clean up mergify rules * Add non-draft requirement for merge * Add merge method * [Mega-Linter] Apply linters fixes * Don't update draft PRs. * Remove merge rules for develop branches * Linting --------- Co-authored-by: TimPansino * Elasticsearch v8 support (#741) * Fix function_wrapper calls to module * Fix wrapper in pika hook * Revert elasticsearch instrumentation * Revert some wrap_function_wrappers to orig * Remove comments/breakpoints * Fix hooks in elasticsearch * Add new client methods from v8 and their hooks * Add elasticsearch v8 to workflow and tox * Fix indices for elasticsearch01 * Disable xpack security in elasticsearch v8.0 * Start to add try/except blocks in tests * Add support for v8 transport * add support for v8 connection * Add tests-WIP * Clean up most tests * Clean up unused instrumentation Co-authored-by: Lalleh Rafeei Co-authored-by: Enriqueta De Leon Co-authored-by: Uma Annamalai Co-authored-by: Kate Anderson Co-authored-by: Mary Martinez Co-authored-by: Hannah Stepanek * Remove elastic search source code * Elasticsearch v8 testing Co-authored-by: Lalleh Rafeei Co-authored-by: Enriqueta De Leon Co-authored-by: Uma Annamalai Co-authored-by: Kate Anderson Co-authored-by: Mary Martinez Co-authored-by: Hannah Stepanek * Scope ES fixture * ES v8 only supports Python3.6+ * Refactor transport tests for v8 Co-authored-by: Lalleh Rafeei Co-authored-by: Uma Annamalai Co-authored-by: Hannah Stepanek Co-authored-by: Kate Anderson Co-authored-by: Enriqueta De Leon * Remove extra comments * Added perform_request_kwargs to test_transport * Fix some linter issues * Remove extra newline * Group es v7 v8 process modules together * Add auto signature detection & binding * Use bind_arguments in ES * Add test for wrapped function * Add validator for datastore trace inputs * Use common bind_arguments for PY3 * Fix tests in starlette v0.23.1 (#752) * Fix tests in starlette v0.23.1 * Fix conditional tests * Add comment to bg_task test * Split below es 8 methods from es 8 methods Note the previous tests in this file to check whether a method was instrumented, did not test anything because they were checking whether the list of methods that we instrumented were instrumented instead of whether there were uninstrumented methods on the es client that we missed. Because we decided due to lack of reporting of bugs by our customers, to not support the buggy wrapping on previous es versions (below es8), we only added tests to assert all methods were wrapped from es8+. We also are only testing es8+ wrapping of methods since the previous versions wrapping behavior may not have been correct due to the signature of the methods changing without us detecting it due to lack of tests. Since our customers have not reported any issues, it seems not worth it at this time to go back and fix these bugs. * Remove signature auto detection implementation * Fixup: remove signature autodetection * Fixup: cleanup * Test method calls on all es versions * Fixup: don't run some methods on es7 --------- Co-authored-by: Timothy Pansino <11214426+TimPansino@users.noreply.github.com> Co-authored-by: mary-martinez Co-authored-by: enriqueta Co-authored-by: Tim Pansino Co-authored-by: Lalleh Rafeei Co-authored-by: Enriqueta De Leon Co-authored-by: Uma Annamalai Co-authored-by: Kate Anderson Co-authored-by: Mary Martinez Co-authored-by: Hannah Stepanek Co-authored-by: Hannah Stepanek Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com> * Update contributors workspace link in CONTRIBUTING.rst. (#760) * Update link in CONTRIBUTING.rst. * Update to RST syntax. * [Mega-Linter] Apply linters fixes --------- Co-authored-by: umaannamalai Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com> * Add Retry to Pip Install (#763) * Add retry to pip install * Fix retry backoff constant * Fix script failures --------- Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com> * Add aiohttp support for expected status codes (#735) * Add aiohttp support for expected status codes * Adjust naming convention * Fix expected tests for new validator behavior --------- Co-authored-by: Timothy Pansino <11214426+TimPansino@users.noreply.github.com> Co-authored-by: Tim Pansino * Fix PyPy Priority Sampling Test (#766) * Fix pypy priority sampling * [Mega-Linter] Apply linters fixes * Bump tests --------- Co-authored-by: TimPansino * Config linter fixes (#768) * Fix default value and lazy logging pylint * Fix default value and lazy logging pylint * Fix unnecessary 'else' in pylint * Fix logging-not-lazy in pylint * Fix redefined built-in error in Pylint * Fix implicit string concatenation in Pylint * Fix dict() to {} in Pylint * Make sure eval is OK to use for Pylint * Fix logging format string for Pylint * Change list comprehension to generator expression * [Mega-Linter] Apply linters fixes * Rerun tests --------- Co-authored-by: lrafeei * Sync tests w/ agents/cross_agent_tests/pull/150 (#770) Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com> * Infinite Tracing Batching & Compression (#762) * Infinite Tracing Batching and Compression settings (#756) * Add compression setting * Add batching setting * Infinite Tracing Compression (#758) * Initial commit * Add compression option in StreamingRPC * Add compression default to tests * Add test to confirm compression settings * Remove commented out code * Set compression settings from settings override * Infinite Tracing Batching (#759) * Initial infinite tracing batching implementation * Add RecordSpanBatch method to mock grpc server * Span batching settings and testing. Co-authored-by: Lalleh Rafeei Co-authored-by: Hannah Stepanek Co-authored-by: Uma Annamalai * Add final 8t batching tests * Rename serialization test * Formatting * Guard unittests from failing due to batching * Linting * Simplify batching algorithm * Properly wire batching parametrization * Fix incorrect validator use * Data loss on reconnect regression testing Co-authored-by: Uma Annamalai Co-authored-by: Hannah Stepanek * Test stream buffer batch sizes * Fix logic in supportability metrics for spans * Clean up nested conditionals in stream buffer * Compression parametrization in serialization test * Formatting * Update 8t test_no_delay_on_ok * Update protobufs * Remove unnecessary patching from test * Fix waiting in supportability metric tests * Add sleep to waiting in test * Reorder sleep and condition check * Mark no data loss xfail for py2. * Fix conditional check * Fix flake8 linter issues --------- Co-authored-by: Lalleh Rafeei Co-authored-by: Hannah Stepanek Co-authored-by: Uma Annamalai Co-authored-by: Hannah Stepanek * Infinite Tracing Supportability Feature Toggle Metrics (#769) * Add 8T feature toggle supportability metrics * Remove supportability metrics when 8t is disabled. * Formatting --------- Co-authored-by: Lalleh Rafeei <84813886+lrafeei@users.noreply.github.com> Co-authored-by: Lalleh Rafeei Co-authored-by: Hannah Stepanek Co-authored-by: Uma Annamalai Co-authored-by: Hannah Stepanek * Fix DT settings for txn feature tests (#771) * Fix pyramid testing versions (#764) Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com> * Fix Ariadne Middleware Testing (#776) * Fix ariadne middleware testing Co-authored-by: Uma Annamalai Co-authored-by: Lalleh Rafeei * [Mega-Linter] Apply linters fixes * Bump tests --------- Co-authored-by: Uma Annamalai Co-authored-by: Lalleh Rafeei Co-authored-by: TimPansino * Exclude merged PRs from automatic mergify actions. (#774) Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com> * Refactor Code Coverage (#765) * Reorder dependency of code coverage fixture * Fix tests with coverage disabled * Refactor code coverage fixture * Clean out old coverage settings * Fix missing code coverage fixture * Fix pypy priority sampling * Start coverage from pytest-cov for better tracking * Refactor coverage config file * Ripping out coverage fixtures * Move tool config to bottom of tox.ini * Disabling py27 warning * Renaming env var --------- Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com> * Add GraphQL Introspection Setting (#783) * Add graphql introspection setting * Sort settings object hierarchy * Add test for introspection queries setting * Expand introspection queries testing * [Mega-Linter] Apply linters fixes * Adjust introspection detection for graphql --------- Co-authored-by: TimPansino * Fix instance info tests for redis. (#784) * Fix instance info tests for redis. * [Mega-Linter] Apply linters fixes --------- Co-authored-by: umaannamalai * Fix Redis Instance Info (#790) * Fix failing redis test for new default behavior * Revert "Fix instance info tests for redis. (#784)" This reverts commit f7108e3c2a54ab02a1104f6c16bd5fd799b9fc7e. * Guard GraphQL Settings Lookup (#787) * Guard graphql settings lookup * [Mega-Linter] Apply linters fixes * Bump tests * Update graphql settings test --------- Co-authored-by: TimPansino Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com> * Errors Inbox Improvements (#791) * Errors inbox attributes and tests (#778) * Initial errors inbox commit Co-authored-by: Timothy Pansino Co-authored-by: Hannah Stepanek Co-authored-by: Uma Annamalai * Add enduser.id field * Move validate_error_trace_attributes into validators directory * Add error callback attributes test * Add tests for enduser.id & error.group.name Co-authored-by: Timothy Pansino * Uncomment code_coverage * Drop commented out line --------- Co-authored-by: Timothy Pansino Co-authored-by: Hannah Stepanek Co-authored-by: Uma Annamalai Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com> Co-authored-by: Timothy Pansino <11214426+TimPansino@users.noreply.github.com> * Error Group Callback API (#785) * Error group initial implementation * Rewrite error callback to pass map of info * Fixed incorrect validators causing errors Co-authored-by: Uma Annamalai Co-authored-by: Hannah Stepanek * Fix validation of error trace attributes * Expanded error callback test * Add incorrect type to error callback testing * Change error group callback to private setting * Add testing for error group callback inputs * Separate error group callback tests * Add explicit testing for the set API * Ensure error group is string * Fix python 2 type validation --------- Co-authored-by: Uma Annamalai Co-authored-by: Hannah Stepanek Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com> * User Tracking for Errors Inbox (#789) * Add user tracking feature for errors inbox. * Address review comments, * Add high_security test. * Cleanup invalid tests test. * Update user_id string check. * Remove set_id outside txn test. --------- Co-authored-by: Timothy Pansino <11214426+TimPansino@users.noreply.github.com> --------- Co-authored-by: Lalleh Rafeei <84813886+lrafeei@users.noreply.github.com> Co-authored-by: Timothy Pansino Co-authored-by: Hannah Stepanek Co-authored-by: Uma Annamalai Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com> Co-authored-by: Uma Annamalai * Update Packages (#793) * Update urllib3 to v1.26.15 * Update six to v1.16.0 * Update coverage exclude for newrelic/packages * [Mega-Linter] Apply linters fixes * Drop removed package from urllib3 * Update pytest * Downgrade websockets version for old sanic testing --------- Co-authored-by: TimPansino * Remove Unused Instrumentation and Tests (#794) * Remove unused instrumentation files * Remove testing for deprecated CherryPy versions * Remove unused pyelasticsearch tests --------- Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com> * Fix Loguru Instrumentation for v0.7.0 (#798) * Add autosignature implementation * Fix loguru with auto-signature * [Mega-Linter] Apply linters fixes * Fix tests for Py2 * [Mega-Linter] Apply linters fixes * Bump tests * Remove unwrap from signature utils * Fix arg unpacking * Remove unwrap arg from bind_args * Fix linter errors --------- Co-authored-by: TimPansino Co-authored-by: Lalleh Rafeei * Remove Twisted framework (#800) * Initial twisted commit * Remove Twisted Framework * Pin virtualenv, fix pip arg deprecation & disable kafka tests (#803) * Pin virtualenv * Fixup: use 20.21.1 instead * Replace install-options with config-settings See https://github.com/pypa/pip/issues/11358. * Temporarily disable kafka tests * Add tests for pyodbc (#796) * Add tests for pyodbc * Move imports into tests to get import coverage * Fixup: remove time import * Trigger tests --------- Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com> * Add tests for Waitress (#797) * Change import format * Initial commit * Add more tests to adapter_waitress * Remove commented out code * [Mega-Linter] Apply linters fixes * Add assertions to all tests * Add more NR testing to waitress --------- Co-authored-by: lrafeei Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com> * Add testing for genshi and mako. (#799) * Add testing for genshi and mako. * [Mega-Linter] Apply linters fixes --------- Co-authored-by: umaannamalai Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com> * Omit some frameworks from coverage analysis (#810) * Omit some frameworks from coverage analysis * Remove commas * Change format of omit * Add relative_files option to coverage * Add absolute directory * Add envsitepackagedir * Add coveragerc file * Add codecov.yml * [Mega-Linter] Apply linters fixes * Revert coveragerc file settings * Add files in packages and more frameworks * Remove commented line --------- Co-authored-by: lrafeei Co-authored-by: Hannah Stepanek * Run coverage around pytest (#813) * Run coverage around pytest * Trigger tests * Fixup * Add redis client_no_touch to ignore list * Temporarily remove kafka from coverage * Remove coverage for old libs * Add required option for tox v4 (#795) * Add required option for tox v4 * Update tox in GHA * Remove py27 no-cache-dir * Fix Testing Failures (#828) * Fix tastypie tests * Adjust asgiref pinned version * Make aioredis key PID unique * Pin more asgiref versions * Fix pytest test filtering when running tox (#823) Co-authored-by: Uma Annamalai * Validator transfer p3 (#745) * Move validate_transaction_metrics to validators directory * Comment out original validate_transaction_metrics from fixtures.py * Move validate_time_metrics_outside_transaction to validators directory * Move validate_internal_metrics into validators directory and fixed validate_transaction_metrics * Move validate_transaction_errors into validators directory * Move validate_application_errors into validators directory * Move validate_custom_parameters into validators directory * Move validate_synthetics_event into validators directory * Move validate_transaction_event_attributes into validators directory * Move validate_non_transaction_error_event into validators directory * Move validate_application_error_trace_count into validators directory * Move validate_application_error_event_count into validators directory * Move validate_synthetics_transaction_trace into validators directory * Move validate_tt_collector_json to validators directory * Move validate_transaction_trace_attributes into validator directory * Move validate_transaction_error_trace_attributes into validator directory * Move validate_error_trace_collector_json into validator directory * Move validate_error_event_collector_json into validator directory * Move validate_transaction_event_collector_json into validator directory * Move validate_custom_event_collector_json into validator directory * Move validate_tt_parameters into validator directory * Move validate_tt_parameters into validator directory * Move validate_tt_segment_params into validator directory * Move validate_browser_attributes into validators directory * Move validate_error_event_attributes into validators directory * Move validate_error_trace_attributes_outside_transaction into validators directory * Move validate_error_event_attributes_outside_transaction into validators directory * Fix some pylint errors * Redirect check_error_attributes * Fix more Pylint errors * Fix import issues from move * Fix more import shuffle errors * Sort logging JSON test for PY2 consistency * Fix Pylint errors in validators * Fix import error --------- Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com> * Fix set output warning using new GHA syntax (#833) * Fix set output warning using new GHA syntax * Fix quoting * Remove Python 2.7 and pypy2 testing (#835) * Change setup-python to @v2 for py2.7 * Remove py27 and pypy testing * Fix syntax errors * Fix comma related syntax errors * Fix more issues in tox * Remove gearman test * Containerized CI Pipeline (#836) * Revert "Remove Python 2.7 and pypy2 testing (#835)" This reverts commit abb6405d2bfd629ed83f48e8a17b4a28e3a3c352. * Containerize CI process * Publish new docker container for CI images * Rename github actions job * Copyright tag scripts * Drop debug line * Swap to new CI image * Move pip install to just main python * Remove libcurl special case from tox * Install special case packages into main image * Remove unused packages * Remove all other triggers besides manual * Add make run command * Cleanup small bugs * Fix CI Image Tagging (#838) * Correct templated CI image name * Pin pypy2.7 in image * Fix up scripting * Temporarily Restore Old CI Pipeline (#841) * Restore old pipelines * Remove python 2 from setup-python * Rework CI Pipeline (#839) Change pypy to pypy27 in tox. Fix checkout logic Pin tox requires * Fix Tests on New CI (#843) * Remove non-root user * Test new CI image * Change pypy to pypy27 in tox. * Fix checkout logic * Fetch git tags properly * Pin tox requires * Adjust default db settings for github actions * Rename elasticsearch services * Reset to new pipelines * [Mega-Linter] Apply linters fixes * Fix timezone * Fix docker networking * Pin dev image to new sha * Standardize gearman DB settings * Fix elasticsearch settings bug * Fix gearman bug * Add missing odbc headers * Add more debug messages * Swap out dev ci image * Fix required virtualenv version * Swap out dev ci image * Swap out dev ci image * Remove aioredis v1 for EOL * Add coverage paths for docker container * Unpin ci container --------- Co-authored-by: TimPansino * Instrument Redis waitaof (#851) * Add uninstrumented command to redis * Update logic for datastore_aioredis instance info * [Mega-Linter] Apply linters fixes * Bump tests * Update defaults for aioredis port --------- Co-authored-by: TimPansino * Ignore patched hooks files. (#849) Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com> * Fix local scoped package reporting (#837) * Include isort stdlibs for determining stdlib modules * Use isort & sys to eliminate std & builtin modules Previously, the logic would fail to identify third party modules installed within the local user socpe. This fixes that issue by skipping builtin and stdlib modules by name, instead of attempting to identify third party modules based on file paths. * Handle importlib_metadata.version being a callable * Add isort into third party notices * [Mega-Linter] Apply linters fixes * Remove Python 2.7 and pypy2 testing (#835) * Change setup-python to @v2 for py2.7 * Remove py27 and pypy testing * Fix syntax errors * Fix comma related syntax errors * Fix more issues in tox * Remove gearman test * Containerized CI Pipeline (#836) * Revert "Remove Python 2.7 and pypy2 testing (#835)" This reverts commit abb6405d2bfd629ed83f48e8a17b4a28e3a3c352. * Containerize CI process * Publish new docker container for CI images * Rename github actions job * Copyright tag scripts * Drop debug line * Swap to new CI image * Move pip install to just main python * Remove libcurl special case from tox * Install special case packages into main image * Remove unused packages * Remove all other triggers besides manual * Add make run command * Cleanup small bugs * Fix CI Image Tagging (#838) * Correct templated CI image name * Pin pypy2.7 in image * Fix up scripting * Temporarily Restore Old CI Pipeline (#841) * Restore old pipelines * Remove python 2 from setup-python * Rework CI Pipeline (#839) Change pypy to pypy27 in tox. Fix checkout logic Pin tox requires * Fix Tests on New CI (#843) * Remove non-root user * Test new CI image * Change pypy to pypy27 in tox. * Fix checkout logic * Fetch git tags properly * Pin tox requires * Adjust default db settings for github actions * Rename elasticsearch services * Reset to new pipelines * [Mega-Linter] Apply linters fixes * Fix timezone * Fix docker networking * Pin dev image to new sha * Standardize gearman DB settings * Fix elasticsearch settings bug * Fix gearman bug * Add missing odbc headers * Add more debug messages * Swap out dev ci image * Fix required virtualenv version * Swap out dev ci image * Swap out dev ci image * Remove aioredis v1 for EOL * Add coverage paths for docker container * Unpin ci container --------- Co-authored-by: TimPansino * Trigger tests --------- Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com> Co-authored-by: hmstepanek Co-authored-by: Lalleh Rafeei <84813886+lrafeei@users.noreply.github.com> Co-authored-by: Timothy Pansino <11214426+TimPansino@users.noreply.github.com> Co-authored-by: TimPansino Co-authored-by: Uma Annamalai * MSSQL Testing (#852) * For mysql tests into mssql * Add tox envs for mssql * Add mssql DB settings * Add correct MSSQL tests * Add mssql to GHA * Add MSSQL libs to CI image * Pin to dev CI image sha * Swap SQLServer container image * Fix healthcheck * Put MSSQL image back * Drop pypy37 tests * Unpin dev image sha * Exclude command line functionality from test coverage (#855) * FIX: resilient environment settings (#825) if the application uses generalimport to manage optional depedencies, it's possible that generalimport.MissingOptionalDependency is raised. In this case, we should not report the module as it is not actually loaded and is not a runtime dependency of the application. Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com> Co-authored-by: Hannah Stepanek * Replace drop_transaction logic by using transaction context manager (#832) * Replace drop_transaction call * [Mega-Linter] Apply linters fixes * Empty commit to start tests * Change logic in BG Wrappers --------- Co-authored-by: lrafeei Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com> * Upgrade to Pypy38 for TypedDict (#861) * Fix base branch * Revert tox dependencies * Replace all pypy37 with pypy38 * Remove action.yml file * Push Empty Commit * Fix skip_missing_interpreters behavior * Fix skip_missing_interpreters behavior * Pin dev CI image sha * Remove unsupported Tornado tests * Add latest tests to Tornado * Remove pypy38 (for now) --------- Co-authored-by: Tim Pansino * Add profile_trace testing (#858) * Include isort stdlibs for determining stdlib modules * Use isort & sys to eliminate std & builtin modules Previously, the logic would fail to identify third party modules installed within the local user socpe. This fixes that issue by skipping builtin and stdlib modules by name, instead of attempting to identify third party modules based on file paths. * Handle importlib_metadata.version being a callable * Add isort into third party notices * [Mega-Linter] Apply linters fixes * Remove Python 2.7 and pypy2 testing (#835) * Change setup-python to @v2 for py2.7 * Remove py27 and pypy testing * Fix syntax errors * Fix comma related syntax errors * Fix more issues in tox * Remove gearman test * Containerized CI Pipeline (#836) * Revert "Remove Python 2.7 and pypy2 testing (#835)" This reverts commit abb6405d2bfd629ed83f48e8a17b4a28e3a3c352. * Containerize CI process * Publish new docker container for CI images * Rename github actions job * Copyright tag scripts * Drop debug line * Swap to new CI image * Move pip install to just main python * Remove libcurl special case from tox * Install special case packages into main image * Remove unused packages * Remove all other triggers besides manual * Add make run command * Cleanup small bugs * Fix CI Image Tagging (#838) * Correct templated CI image name * Pin pypy2.7 in image * Fix up scripting * Temporarily Restore Old CI Pipeline (#841) * Restore old pipelines * Remove python 2 from setup-python * Rework CI Pipeline (#839) Change pypy to pypy27 in tox. Fix checkout logic Pin tox requires * Fix Tests on New CI (#843) * Remove non-root user * Test new CI image * Change pypy to pypy27 in tox. * Fix checkout logic * Fetch git tags properly * Pin tox requires * Adjust default db settings for github actions * Rename elasticsearch services * Reset to new pipelines * [Mega-Linter] Apply linters fixes * Fix timezone * Fix docker networking * Pin dev image to new sha * Standardize gearman DB settings * Fix elasticsearch settings bug * Fix gearman bug * Add missing odbc headers * Add more debug messages * Swap out dev ci image * Fix required virtualenv version * Swap out dev ci image * Swap out dev ci image * Remove aioredis v1 for EOL * Add coverage paths for docker container * Unpin ci container --------- Co-authored-by: TimPansino * Trigger tests * Add testing for profile trace. * [Mega-Linter] Apply linters fixes * Ignore __call__ from coverage on profile_trace. * [Mega-Linter] Apply linters fixes --------- Co-authored-by: Hannah Stepanek Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com> Co-authored-by: hmstepanek Co-authored-by: Lalleh Rafeei <84813886+lrafeei@users.noreply.github.com> Co-authored-by: Timothy Pansino <11214426+TimPansino@users.noreply.github.com> Co-authored-by: TimPansino Co-authored-by: umaannamalai * Add Transaction API Tests (#857) * Test for suppress_apdex_metric * Add custom_metrics tests * Add distributed_trace_headers testing in existing tests * [Mega-Linter] Apply linters fixes * Remove redundant if-statement * Ignore deprecated transaction function from coverage * [Mega-Linter] Apply linters fixes * Push empty commit * Update newrelic/api/transaction.py --------- Co-authored-by: lrafeei Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com> Co-authored-by: Timothy Pansino <11214426+TimPansino@users.noreply.github.com> Co-authored-by: Uma Annamalai * Add tests for jinja2. (#842) * Add tests for jinja2. * [Mega-Linter] Apply linters fixes * Update tox.ini Co-authored-by: Timothy Pansino <11214426+TimPansino@users.noreply.github.com> --------- Co-authored-by: umaannamalai Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com> Co-authored-by: Timothy Pansino <11214426+TimPansino@users.noreply.github.com> * Add tests for newrelic/config.py (#860) Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com> * Fix starlette testing matrix for updated behavior. (#869) Co-authored-by: Lalleh Rafeei Co-authored-by: Hannah Stepanek Co-authored-by: Uma Annamalai * Correct Serverless Distributed Tracing Logic (#870) * Fix serverless logic for distributed tracing * Test stubs * Collapse testing changes * Add negative testing to regular DT test suite * Apply linter fixes * [Mega-Linter] Apply linters fixes --------- Co-authored-by: TimPansino * Fix Kafka CI (#863) * Reenable kafka testing * Add kafka dev lib * Sync install python with devcontainer * Fix kafka local host setting * Drop set -u flag * Pin CI image dev sha * Add parallel flag to kafka * Fix proper exit status * Build librdkafka from source * Updated dev image sha * Remove coverage exclusions * Add new options to better emulate GHA * Reconfigure kafka networking Co-authored-by: Hannah Stepanek * Fix kafka ports on GHA * Run kafka tests serially * Separate kafka consumer groups * Put CI container makefile back * Remove confluent kafka Py27 for latest * Roll back ubuntu version update * Update dev ci sha --------- Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com> Co-authored-by: Hannah Stepanek * Change image tag to latest (#871) * Change image tag to latest * Use built sha * Fixup * Replace w/ latest * Add full version for pypy3.8 to tox (#872) * Add full version for pypy3.8 * Remove solrpy from tests * Instrument RedisCluster (#809) * Add instrumentation for RedisCluster * Add tests for redis cluster * Ignore Django instrumentation from older versions (#859) * Ignore Django instrumentation from older versions * Ignore Django instrumentation from older versions * Fix text concatenation * Update newrelic/hooks/framework_django.py Co-authored-by: Hannah Stepanek * Update newrelic/hooks/framework_django.py Co-authored-by: Hannah Stepanek --------- Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com> Co-authored-by: Hannah Stepanek * Modify postgresql tests to include WITH query (#885) * Modify postgresql tests to include WITH * [Mega-Linter] Apply linters fixes --------- Co-authored-by: lrafeei * Develop redis addons (#888) * Added separate instrumentation for redis.asyncio.client (#808) * Added separate instrumentation for redis.asyncio.client Merge main branch updates Add tests for newrelic/config.py (#860) Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com> * Modify redis tests * removed redis.asyncio from aioredis instrumentation removed aioredis instrumentation in redis asyncio client removed redis.asyncio from aioredis instrumentation --------- Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com> Co-authored-by: Lalleh Rafeei Co-authored-by: Lalleh Rafeei <84813886+lrafeei@users.noreply.github.com> * Redis asyncio testing (#881) * Add/modify redis asyncio tests * Change to psubscribe * Tweak redis async tests/instrumentation * [Mega-Linter] Apply linters fixes * Push empty commit * Exclude older instrumentation from coverage * Resolve requested testing changes * Tweak async pubsub test * Fix pubsub test --------- Co-authored-by: lrafeei * Remove aioredis and aredis from tox (#891) * Remove aioredis and aredis from tox * Add aredis and aioredis to coverage ignore * Push empty commit * Fix codecov ignore file --------- Co-authored-by: Ahmed Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com> Co-authored-by: lrafeei * Fix drift * Fix ariadne middleware tests for all versions. --------- Co-authored-by: Hannah Stepanek Co-authored-by: Lalleh Rafeei Co-authored-by: TimPansino Co-authored-by: Lalleh Rafeei <84813886+lrafeei@users.noreply.github.com> Co-authored-by: Uma Annamalai Co-authored-by: Hannah Stepanek Co-authored-by: umaannamalai Co-authored-by: Lalleh Rafeei Co-authored-by: Kevin Morey Co-authored-by: Kate Anderson <90657569+kanderson250@users.noreply.github.com> Co-authored-by: Enriqueta De Leon Co-authored-by: Kate Anderson Co-authored-by: Mary Martinez Co-authored-by: Dmitry Kolyagin Co-authored-by: mary-martinez Co-authored-by: enriqueta Co-authored-by: Mary Martinez Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com> Co-authored-by: Justin Richert Co-authored-by: Ahmed Helil Co-authored-by: Ahmed * Remove graphql 2 & promise support (#875) * Update Versioning Scheme (#651) * Update versioning scheme to 3 semver digits * Fix version indexing Co-authored-by: Hannah Stepanek Co-authored-by: Lalleh Rafeei * Remove version truncation * [Mega-Linter] Apply linters fixes * Bump tests Co-authored-by: Hannah Stepanek Co-authored-by: Lalleh Rafeei Co-authored-by: TimPansino * Fix Trace Finalizer Crashes (#652) * Patch crashes in various traces with None settings * Add tests for graphql trace types to unittests * Add test to ensure traces don't crash in finalizer * [Mega-Linter] Apply linters fixes * Bump tests Co-authored-by: TimPansino Co-authored-by: Lalleh Rafeei <84813886+lrafeei@users.noreply.github.com> * Add usage tracking metrics for Kafka clients. (#658) * Add usage tracking metrics for Kafka clients. * Fix double import lint error * [Mega-Linter] Apply linters fixes * Create version util file and add metrics to consumer. * Address linting errors. * Add missing semi-colon. * [Mega-Linter] Apply linters fixes * Bump tests. Co-authored-by: Hannah Stepanek Co-authored-by: hmstepanek Co-authored-by: umaannamalai * Deprecate add_custom_parameter(s) API (#655) * Deprecate add_custom_parameter(s) API * Fix unicode tests and some pylint errors * Fix more pylint errors * Revert "Fix more pylint errors" This reverts commit 807ec1c5c40fe421300ccdcd6fedd81f288dce2c. * Edit deprecation message in add_custom_parameters * Add usage metrics for Daphne and Hypercorn. (#665) * Add usage metrics for Daphne and Hypercorn. * [Mega-Linter] Apply linters fixes Co-authored-by: umaannamalai * Fix Flask view support in Code Level Metrics (#664) * Fix Flask view support in Code Level Metrics Co-authored-by: Lalleh Rafeei Co-authored-by: Hannah Stepanek Co-authored-by: Uma Annamalai * [Mega-Linter] Apply linters fixes * Bump tests * Fix CLM tests for flaskrest * [Mega-Linter] Apply linters fixes * Bump tests Co-authored-by: Lalleh Rafeei Co-authored-by: Hannah Stepanek Co-authored-by: Uma Annamalai Co-authored-by: TimPansino Co-authored-by: Uma Annamalai * Fix aioredis version crash (#661) Co-authored-by: Uma Annamalai * Add double wrapped testing for Hypercorn and Daphne and dispatcher argument to WSGI API. (#667) * Add double wrapped app tests. * Fix linting errors. * [Mega-Linter] Apply linters fixes * Add co-authors. Co-authored-by: Tim Pansino Co-authored-by: Lalleh Rafeei Co-authored-by: Hannah Stepanek Co-authored-by: umaannamalai Co-authored-by: Tim Pansino Co-authored-by: Lalleh Rafeei Co-authored-by: Hannah Stepanek * Add Python 3.11 Support (#654) * Add py311 tests * Fix typo * Added 3.11 support for aiohttp framework Co-authored-by: Timothy Pansino * Set up environment to run Python 3.11 Co-authored-by: Timothy Pansino * Add Python 3.11 support for agent_features Co-authored-by: Timothy Pansino * Partial Python 3.11 support added for Tornado Co-authored-by: Timothy Pansino * Adjust postgres versions * Fix tornado install path locally * Remove aioredis py311 tests * Update 3.11 to dev in tests * Fix sanic instrumentation and imp/importlib deprecation Co-authored-by: Timothy Pansino * Simplify wheel build options * Update cibuildwheel for 3.11 * Remove falconmaster py311 test Co-authored-by: Lalleh Rafeei Co-authored-by: Timothy Pansino * Remove devcontainer submodule (#669) * Uncomment NewRelicContextFormatter from agent.py (#676) * Fix botocore tests for botocore v1.28.1+ (#675) * Fix botocore tests for botocore v1.28.1+ Co-authored-by: Timothy Pansino * Fix boto3 tests for botocore v1.28.1+ Co-authored-by: Timothy Pansino Co-authored-by: Hannah Stepanek Co-authored-by: Uma Annamalai * Fix boto3 tests for python 2.7 Co-authored-by: Timothy Pansino Co-authored-by: Hannah Stepanek Co-authored-by: Uma Annamalai Co-authored-by: Timothy Pansino Co-authored-by: Hannah Stepanek Co-authored-by: Uma Annamalai Co-authored-by: Timothy Pansino <11214426+TimPansino@users.noreply.github.com> * Feature increased custom event limit (#674) * Update reservoir size for custom events. * [Mega-Linter] Apply linters fixes * Increase custom event limit. (#666) * Remove duplicated CUSTOM_EVENT_RESERVOIR_SIZE Co-authored-by: Tim Pansino Co-authored-by: TimPansino Co-authored-by: Timothy Pansino <11214426+TimPansino@users.noreply.github.com> Co-authored-by: Uma Annamalai * Add python 3.11 stable release to GHA (#671) * Double kafka test runners (#677) Co-authored-by: Hannah Stepanek * Fix failing flask_rest tests (#683) * Pin flask-restx in flask_rest tests for 2.7 flask-restx dropped support for 2.7 in 1.0.1. * Drop support for flask-restplus flask-restx replaced flask-restplus. flask-restplus's latest version supports 3.6 which we don't even support anymore. * Fix failing botocore tests (#684) * Change queue url for botocore>=1.29.0 botocore >=1.29.0 uses sqs.us-east-1.amazonaws.com url instead of queue.amazonaws.com. * Use tuple version instead of str * Change botocore129->botocore128 * Add record_log_event to public api (#681) * Add patch for sentry SDK to correct ASGI v2/v3 detection. (#680) * Add patch for sentry to correct ASGI v2/v3 detection. Co-authored-by: Tim Pansino Co-authored-by: Lalleh Rafeei Co-authored-by: Hannah Stepanek * [Mega-Linter] Apply linters fixes Co-authored-by: Tim Pansino Co-authored-by: Lalleh Rafeei Co-authored-by: Hannah Stepanek Co-authored-by: umaannamalai Co-authored-by: Timothy Pansino <11214426+TimPansino@users.noreply.github.com> * Update pip install command (#688) * Validator transfer from fixtures.py to validators directory, Part 1 (#672) * Move validate_transaction_metrics to validators directory * Comment out original validate_transaction_metrics from fixtures.py * Move validate_time_metrics_outside_transaction to validators directory * Move validate_internal_metrics into validators directory and fixed validate_transaction_metrics * Move validate_transaction_errors into validators directory * Move validate_application_errors into validators directory * Move valid… * Develop swap redis asyncio commits (#913) * Revert "Redis asyncio testing (#881)" (#911) * Revert "Redis asyncio testing (#881)" This reverts commit 05cff1b6cf0629f7764e46b92c8f2cea2c206dd0. * Add spublish to list of commands * Fix redis.asyncio sync operations wrapper (#782) * Fix redis.asyncio sync operations wrapper * Add clean ups * Fixes: - `loop` -> noqa - catch `TimeoutError` on `asyncio.timeout` * Added separate instrumentation for redis.asyncio.client (#808) * Added separate instrumentation for redis.asyncio.client Merge main branch updates Add tests for newrelic/config.py (#860) Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com> * Modify redis tests * removed redis.asyncio from aioredis instrumentation removed aioredis instrumentation in redis asyncio client removed redis.asyncio from aioredis instrumentation --------- Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com> Co-authored-by: Lalleh Rafeei Co-authored-by: Lalleh Rafeei <84813886+lrafeei@users.noreply.github.com> * Modify tests * Tweak tests and instrumentation * Tweak tests to separate aioredis and redis.asyncio * Correctly separate commands to sync/async --------- Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com> Co-authored-by: Ahmed Co-authored-by: Lalleh Rafeei Co-authored-by: Lalleh Rafeei <84813886+lrafeei@users.noreply.github.com> * Remove formatting in import --------- Co-authored-by: Błażej Cyrzon <36710760+bc291@users.noreply.github.com> Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com> Co-authored-by: Ahmed * Increase days until stale. (#909) Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com> * Pin anyio version to below 4.0.0 (#916) * Add redis.asyncio.Connection instrumentation (#919) * Add async connection instrumentation * Remove unsupported flask tests * Remove old instrumentation from coverage analysis * [Mega-Linter] Apply linters fixes * Trigger tests --------- Co-authored-by: lrafeei * Update testing matrix for supported packages. (#904) * Remove testing for unsupported package versions. * Add no cover flags. * [Mega-Linter] Apply linters fixes --------- Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com> Co-authored-by: umaannamalai Co-authored-by: Timothy Pansino <11214426+TimPansino@users.noreply.github.com> * Correct merge conflicts for develop-sklearn --------- Co-authored-by: Lalleh Rafeei <84813886+lrafeei@users.noreply.github.com> Co-authored-by: Ahmed Helil Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com> Co-authored-by: Hannah Stepanek Co-authored-by: lrafeei Co-authored-by: Uma Annamalai Co-authored-by: hmstepanek Co-authored-by: TimPansino Co-authored-by: umaannamalai Co-authored-by: Ahmed Co-authored-by: Lalleh Rafeei Co-authored-by: Renan Ivo Co-authored-by: Kevin Morey Co-authored-by: Kate Anderson <90657569+kanderson250@users.noreply.github.com> Co-authored-by: Enriqueta De Leon Co-authored-by: Kate Anderson Co-authored-by: Mary Martinez Co-authored-by: Dmitry Kolyagin Co-authored-by: mary-martinez Co-authored-by: enriqueta Co-authored-by: Mary Martinez Co-authored-by: Justin Richert Co-authored-by: Błażej Cyrzon <36710760+bc291@users.noreply.github.com> --- .github/containers/install-python.sh | 3 - newrelic/hooks/framework_bottle.py | 106 +++++------ newrelic/hooks/framework_pyramid.py | 48 ++--- newrelic/hooks/logger_loguru.py | 2 +- newrelic/hooks/messagebroker_pika.py | 8 +- .../datastore_redis/test_custom_conn_pool.py | 111 ++++++------ tests/datastore_redis/test_execute_command.py | 171 +++++++++--------- tests/datastore_redis/test_get_and_set.py | 103 +++++------ tests/datastore_redis/test_multiple_dbs.py | 109 +++++------ tests/datastore_redis/test_rb.py | 96 +++++----- tox.ini | 38 +--- 11 files changed, 376 insertions(+), 419 deletions(-) diff --git a/.github/containers/install-python.sh b/.github/containers/install-python.sh index 2031e2d92..f9da0a003 100755 --- a/.github/containers/install-python.sh +++ b/.github/containers/install-python.sh @@ -45,9 +45,6 @@ main() { # Set all installed versions as globally accessible pyenv global ${PYENV_VERSIONS[@]} - - # Install dependencies for main python installation - pyenv exec pip install --upgrade -r /requirements.txt } main diff --git a/newrelic/hooks/framework_bottle.py b/newrelic/hooks/framework_bottle.py index 99caa844f..5635fa782 100644 --- a/newrelic/hooks/framework_bottle.py +++ b/newrelic/hooks/framework_bottle.py @@ -18,14 +18,21 @@ import functools -from newrelic.api.function_trace import (FunctionTrace, FunctionTraceWrapper, - wrap_function_trace) +from newrelic.api.function_trace import ( + FunctionTrace, + FunctionTraceWrapper, + wrap_function_trace, +) from newrelic.api.transaction import current_transaction from newrelic.api.wsgi_application import wrap_wsgi_application from newrelic.common.object_names import callable_name -from newrelic.common.object_wrapper import (wrap_out_function, - function_wrapper, ObjectProxy, wrap_object_attribute, - wrap_function_wrapper) +from newrelic.common.object_wrapper import ( + ObjectProxy, + function_wrapper, + wrap_function_wrapper, + wrap_object_attribute, + wrap_out_function, +) module_bottle = None @@ -34,17 +41,17 @@ def status_code(exc, value, tb): # The HTTPError class derives from HTTPResponse and so we do not # need to check for it seperately as isinstance() will pick it up. - if isinstance(value, module_bottle.HTTPResponse): - if hasattr(value, 'status_code'): + if isinstance(value, module_bottle.HTTPResponse): # pragma: no cover + if hasattr(value, "status_code"): return value.status_code - elif hasattr(value, 'status'): + elif hasattr(value, "status"): return value.status - elif hasattr(value, 'http_status_code'): + elif hasattr(value, "http_status_code"): return value.http_status_code def should_ignore(exc, value, tb): - if hasattr(module_bottle, 'RouteReset'): + if hasattr(module_bottle, "RouteReset"): if isinstance(value, module_bottle.RouteReset): return True @@ -113,8 +120,7 @@ def get(self, status, default=None): transaction.set_transaction_name(name, priority=1) handler = FunctionTraceWrapper(handler, name=name) else: - transaction.set_transaction_name(str(status), - group='StatusCode', priority=1) + transaction.set_transaction_name(str(status), group="StatusCode", priority=1) return handler or default @@ -140,43 +146,39 @@ def instrument_bottle(module): global module_bottle module_bottle = module - framework_details = ('Bottle', getattr(module, '__version__')) - - if hasattr(module.Bottle, 'wsgi'): # version >= 0.9 - wrap_wsgi_application(module, 'Bottle.wsgi', - framework=framework_details) - elif hasattr(module.Bottle, '__call__'): # version < 0.9 - wrap_wsgi_application(module, 'Bottle.__call__', - framework=framework_details) - - if (hasattr(module, 'Route') and - hasattr(module.Route, '_make_callback')): # version >= 0.10 - wrap_out_function(module, 'Route._make_callback', - output_wrapper_Route_make_callback) - elif hasattr(module.Bottle, '_match'): # version >= 0.9 - wrap_out_function(module, 'Bottle._match', - output_wrapper_Bottle_match) - elif hasattr(module.Bottle, 'match_url'): # version < 0.9 - wrap_out_function(module, 'Bottle.match_url', - output_wrapper_Bottle_match) - - wrap_object_attribute(module, 'Bottle.error_handler', - proxy_Bottle_error_handler) - - if hasattr(module, 'auth_basic'): - wrap_function_wrapper(module, 'auth_basic', wrapper_auth_basic) - - if hasattr(module, 'SimpleTemplate'): - wrap_function_trace(module, 'SimpleTemplate.render') - - if hasattr(module, 'MakoTemplate'): - wrap_function_trace(module, 'MakoTemplate.render') - - if hasattr(module, 'CheetahTemplate'): - wrap_function_trace(module, 'CheetahTemplate.render') - - if hasattr(module, 'Jinja2Template'): - wrap_function_trace(module, 'Jinja2Template.render') - - if hasattr(module, 'SimpleTALTemplate'): - wrap_function_trace(module, 'SimpleTALTemplate.render') + framework_details = ("Bottle", getattr(module, "__version__")) + # version >= 0.9 + if hasattr(module.Bottle, "wsgi"): # pragma: no cover + wrap_wsgi_application(module, "Bottle.wsgi", framework=framework_details) + # version < 0.9 + elif hasattr(module.Bottle, "__call__"): # pragma: no cover + wrap_wsgi_application(module, "Bottle.__call__", framework=framework_details) + # version >= 0.10 + if hasattr(module, "Route") and hasattr(module.Route, "_make_callback"): # pragma: no cover + wrap_out_function(module, "Route._make_callback", output_wrapper_Route_make_callback) + # version >= 0.9 + elif hasattr(module.Bottle, "_match"): # pragma: no cover + wrap_out_function(module, "Bottle._match", output_wrapper_Bottle_match) + # version < 0.9 + elif hasattr(module.Bottle, "match_url"): # pragma: no cover + wrap_out_function(module, "Bottle.match_url", output_wrapper_Bottle_match) + + wrap_object_attribute(module, "Bottle.error_handler", proxy_Bottle_error_handler) + + if hasattr(module, "auth_basic"): + wrap_function_wrapper(module, "auth_basic", wrapper_auth_basic) + + if hasattr(module, "SimpleTemplate"): + wrap_function_trace(module, "SimpleTemplate.render") + + if hasattr(module, "MakoTemplate"): + wrap_function_trace(module, "MakoTemplate.render") + + if hasattr(module, "CheetahTemplate"): + wrap_function_trace(module, "CheetahTemplate.render") + + if hasattr(module, "Jinja2Template"): + wrap_function_trace(module, "Jinja2Template.render") + + if hasattr(module, "SimpleTALTemplate"): # pragma: no cover + wrap_function_trace(module, "SimpleTALTemplate.render") diff --git a/newrelic/hooks/framework_pyramid.py b/newrelic/hooks/framework_pyramid.py index efe3c4468..996ebb372 100644 --- a/newrelic/hooks/framework_pyramid.py +++ b/newrelic/hooks/framework_pyramid.py @@ -48,8 +48,11 @@ from newrelic.api.transaction import current_transaction from newrelic.api.wsgi_application import wrap_wsgi_application from newrelic.common.object_names import callable_name -from newrelic.common.object_wrapper import (FunctionWrapper, wrap_out_function, - wrap_function_wrapper) +from newrelic.common.object_wrapper import ( + FunctionWrapper, + wrap_function_wrapper, + wrap_out_function, +) def instrument_pyramid_router(module): @@ -57,16 +60,17 @@ def instrument_pyramid_router(module): try: import pkg_resources - pyramid_version = pkg_resources.get_distribution('pyramid').version + + pyramid_version = pkg_resources.get_distribution("pyramid").version except Exception: pass - wrap_wsgi_application( - module, 'Router.__call__', framework=('Pyramid', pyramid_version)) + wrap_wsgi_application(module, "Router.__call__", framework=("Pyramid", pyramid_version)) def status_code(exc, value, tb): from pyramid.httpexceptions import HTTPException + # Ignore certain exceptions based on HTTP status codes. if isinstance(value, HTTPException): @@ -75,6 +79,7 @@ def status_code(exc, value, tb): def should_ignore(exc, value, tb): from pyramid.exceptions import PredicateMismatch + # Always ignore PredicateMismatch as it is raised by views to force # subsequent views to be consulted when multi views are being used. # It isn't therefore strictly an error as such as a subsequent view @@ -100,9 +105,7 @@ def view_handler_wrapper(wrapped, instance, args, kwargs): # set exception views to priority=1 so they won't take precedence over # the original view callable - transaction.set_transaction_name( - name, - priority=1 if args and isinstance(args[0], Exception) else 2) + transaction.set_transaction_name(name, priority=1 if args and isinstance(args[0], Exception) else 2) with FunctionTrace(name, source=view_callable) as trace: try: @@ -114,7 +117,7 @@ def view_handler_wrapper(wrapped, instance, args, kwargs): def wrap_view_handler(mapped_view): - if hasattr(mapped_view, '_nr_wrapped'): + if hasattr(mapped_view, "_nr_wrapped"): # pragma: no cover return mapped_view else: wrapped = FunctionWrapper(mapped_view, view_handler_wrapper) @@ -157,7 +160,7 @@ def _wrapper(context, request): return wrapper(context, request) finally: attr = instance.attr - inst = getattr(request, '__view__', None) + inst = getattr(request, "__view__", None) if inst is not None: if attr: handler = getattr(inst, attr) @@ -166,7 +169,7 @@ def _wrapper(context, request): tracer.name = name tracer.add_code_level_metrics(handler) else: - method = getattr(inst, '__call__') + method = getattr(inst, "__call__") if method: name = callable_name(method) transaction.set_transaction_name(name, priority=2) @@ -180,22 +183,21 @@ def instrument_pyramid_config_views(module): # Location of the ViewDeriver class changed from pyramid.config to # pyramid.config.views so check if present before trying to update. - if hasattr(module, 'ViewDeriver'): - wrap_out_function(module, 'ViewDeriver.__call__', wrap_view_handler) - elif hasattr(module, 'Configurator'): - wrap_out_function(module, 'Configurator._derive_view', - wrap_view_handler) + if hasattr(module, "ViewDeriver"): # pragma: no cover + wrap_out_function(module, "ViewDeriver.__call__", wrap_view_handler) + elif hasattr(module, "Configurator"): + wrap_out_function(module, "Configurator._derive_view", wrap_view_handler) - if hasattr(module, 'DefaultViewMapper'): + if hasattr(module, "DefaultViewMapper"): module.DefaultViewMapper.map_class_requestonly = FunctionWrapper( - module.DefaultViewMapper.map_class_requestonly, - default_view_mapper_wrapper) + module.DefaultViewMapper.map_class_requestonly, default_view_mapper_wrapper + ) module.DefaultViewMapper.map_class_native = FunctionWrapper( - module.DefaultViewMapper.map_class_native, - default_view_mapper_wrapper) + module.DefaultViewMapper.map_class_native, default_view_mapper_wrapper + ) def instrument_pyramid_config_tweens(module): - wrap_function_wrapper(module, 'Tweens.add_explicit', wrap_add_tween) + wrap_function_wrapper(module, "Tweens.add_explicit", wrap_add_tween) - wrap_function_wrapper(module, 'Tweens.add_implicit', wrap_add_tween) + wrap_function_wrapper(module, "Tweens.add_implicit", wrap_add_tween) diff --git a/newrelic/hooks/logger_loguru.py b/newrelic/hooks/logger_loguru.py index 9e7ed3eae..dc9843b20 100644 --- a/newrelic/hooks/logger_loguru.py +++ b/newrelic/hooks/logger_loguru.py @@ -134,7 +134,7 @@ def patch_loguru_logger(logger): if not hasattr(logger._core, "_nr_instrumented"): logger.add(_nr_log_forwarder, format="{message}") logger._core._nr_instrumented = True - elif not hasattr(logger, "_nr_instrumented"): + elif not hasattr(logger, "_nr_instrumented"): # pragma: no cover for _, handler in six.iteritems(logger._handlers): if handler._writer is _nr_log_forwarder: logger._nr_instrumented = True diff --git a/newrelic/hooks/messagebroker_pika.py b/newrelic/hooks/messagebroker_pika.py index cecc1b934..d6120c10d 100644 --- a/newrelic/hooks/messagebroker_pika.py +++ b/newrelic/hooks/messagebroker_pika.py @@ -36,7 +36,6 @@ def _add_consume_rabbitmq_trace(transaction, method, properties, nr_start_time, queue_name=None): - routing_key = None if hasattr(method, "routing_key"): routing_key = method.routing_key @@ -197,7 +196,7 @@ def _wrap_basic_get_Channel(wrapper, queue, callback, *args, **kwargs): return queue, args, kwargs -def _wrap_basic_get_Channel_old(wrapper, callback=None, queue="", *args, **kwargs): +def _wrap_basic_get_Channel_old(wrapper, callback=None, queue="", *args, **kwargs): # pragma: no cover if callback is not None: callback = wrapper(callback) args = (callback, queue) + args @@ -368,7 +367,6 @@ def callback_wrapper(wrapped, instance, args, kwargs): correlation_id=correlation_id, source=wrapped, ) as mt: - # Improve transaction naming _new_txn_name = "RabbitMQ/Exchange/%s/%s" % (exchange, name) mt.set_transaction_name(_new_txn_name, group="Message") @@ -404,7 +402,7 @@ def instrument_pika_adapters(module): version = tuple(int(num) for num in pika.__version__.split(".", 1)[0]) - if version[0] < 1: + if version[0] < 1: # pragma: no cover wrap_consume = _wrap_basic_consume_BlockingChannel_old else: wrap_consume = _wrap_basic_consume_Channel @@ -426,7 +424,7 @@ def instrument_pika_channel(module): version = tuple(int(num) for num in pika.__version__.split(".", 1)[0]) - if version[0] < 1: + if version[0] < 1: # pragma: no cover wrap_consume = _wrap_basic_consume_Channel_old wrap_get = _wrap_basic_get_Channel_old else: diff --git a/tests/datastore_redis/test_custom_conn_pool.py b/tests/datastore_redis/test_custom_conn_pool.py index 3da24f454..8e4503b75 100644 --- a/tests/datastore_redis/test_custom_conn_pool.py +++ b/tests/datastore_redis/test_custom_conn_pool.py @@ -12,23 +12,23 @@ # See the License for the specific language governing permissions and # limitations under the License. -""" The purpose of these tests is to confirm that using a non-standard +''' The purpose of these tests is to confirm that using a non-standard connection pool that does not have a `connection_kwargs` attribute will not result in an error. -""" +''' import pytest import redis -from testing_support.db_settings import redis_settings -from testing_support.fixtures import override_application_settings -from testing_support.util import instance_hostname -from testing_support.validators.validate_transaction_metrics import ( - validate_transaction_metrics, -) from newrelic.api.background_task import background_task from newrelic.common.package_version_utils import get_package_version_tuple +from testing_support.fixtures import override_application_settings +from testing_support.validators.validate_transaction_metrics import validate_transaction_metrics +from testing_support.db_settings import redis_settings +from testing_support.util import instance_hostname + + DB_SETTINGS = redis_settings()[0] REDIS_PY_VERSION = get_package_version_tuple("redis") @@ -45,14 +45,13 @@ def get_connection(self, name, *keys, **options): def release(self, connection): self.connection.disconnect() - # Settings _enable_instance_settings = { - "datastore_tracer.instance_reporting.enabled": True, + 'datastore_tracer.instance_reporting.enabled': True, } _disable_instance_settings = { - "datastore_tracer.instance_reporting.enabled": False, + 'datastore_tracer.instance_reporting.enabled': False, } # Metrics @@ -62,100 +61,98 @@ def release(self, connection): datastore_all_metric_count = 5 if REDIS_PY_VERSION >= (5, 0) else 3 _base_scoped_metrics = [ - ("Datastore/operation/Redis/get", 1), - ("Datastore/operation/Redis/set", 1), - ("Datastore/operation/Redis/client_list", 1), + ('Datastore/operation/Redis/get', 1), + ('Datastore/operation/Redis/set', 1), + ('Datastore/operation/Redis/client_list', 1), ] # client_setinfo was introduced in v5.0.0 and assigns info displayed in client_list output if REDIS_PY_VERSION >= (5, 0): - _base_scoped_metrics.append( - ("Datastore/operation/Redis/client_setinfo", 2), - ) + _base_scoped_metrics.append(('Datastore/operation/Redis/client_setinfo', 2),) _base_rollup_metrics = [ - ("Datastore/all", datastore_all_metric_count), - ("Datastore/allOther", datastore_all_metric_count), - ("Datastore/Redis/all", datastore_all_metric_count), - ("Datastore/Redis/allOther", datastore_all_metric_count), - ("Datastore/operation/Redis/get", 1), - ("Datastore/operation/Redis/set", 1), - ("Datastore/operation/Redis/client_list", 1), + ('Datastore/all', datastore_all_metric_count), + ('Datastore/allOther', datastore_all_metric_count), + ('Datastore/Redis/all', datastore_all_metric_count), + ('Datastore/Redis/allOther', datastore_all_metric_count), + ('Datastore/operation/Redis/get', 1), + ('Datastore/operation/Redis/set', 1), + ('Datastore/operation/Redis/client_list', 1), ] if REDIS_PY_VERSION >= (5, 0): - _base_rollup_metrics.append( - ("Datastore/operation/Redis/client_setinfo", 2), - ) + _base_rollup_metrics.append(('Datastore/operation/Redis/client_setinfo', 2),) -_host = instance_hostname(DB_SETTINGS["host"]) -_port = DB_SETTINGS["port"] +_host = instance_hostname(DB_SETTINGS['host']) +_port = DB_SETTINGS['port'] -_instance_metric_name = "Datastore/instance/Redis/%s/%s" % (_host, _port) +_instance_metric_name = 'Datastore/instance/Redis/%s/%s' % (_host, _port) instance_metric_count = 5 if REDIS_PY_VERSION >= (5, 0) else 3 -_enable_rollup_metrics = _base_rollup_metrics.append((_instance_metric_name, instance_metric_count)) +_enable_rollup_metrics = _base_rollup_metrics.append( + (_instance_metric_name, instance_metric_count) +) -_disable_rollup_metrics = _base_rollup_metrics.append((_instance_metric_name, None)) +_disable_rollup_metrics = _base_rollup_metrics.append( + (_instance_metric_name, None) +) # Operations - def exercise_redis(client): - client.set("key", "value") - client.get("key") - client.execute_command("CLIENT", "LIST", parse="LIST") - + client.set('key', 'value') + client.get('key') + client.execute_command('CLIENT', 'LIST', parse='LIST') # Tests - -@pytest.mark.skipif(REDIS_PY_VERSION < (2, 7), reason="Client list command introduced in 2.7") +@pytest.mark.skipif(REDIS_PY_VERSION < (2, 7), + reason='Client list command introduced in 2.7') @override_application_settings(_enable_instance_settings) @validate_transaction_metrics( - "test_custom_conn_pool:test_fake_conn_pool_enable_instance", - scoped_metrics=_base_scoped_metrics, - rollup_metrics=_enable_rollup_metrics, - background_task=True, -) + 'test_custom_conn_pool:test_fake_conn_pool_enable_instance', + scoped_metrics=_base_scoped_metrics, + rollup_metrics=_enable_rollup_metrics, + background_task=True) @background_task() def test_fake_conn_pool_enable_instance(): - client = redis.StrictRedis(host=DB_SETTINGS["host"], port=DB_SETTINGS["port"], db=0) + client = redis.StrictRedis(host=DB_SETTINGS['host'], + port=DB_SETTINGS['port'], db=0) # Get a real connection - conn = client.connection_pool.get_connection("GET") + conn = client.connection_pool.get_connection('GET') # Replace the original connection pool with one that doesn't # have the `connection_kwargs` attribute. fake_pool = FakeConnectionPool(conn) client.connection_pool = fake_pool - assert not hasattr(client.connection_pool, "connection_kwargs") + assert not hasattr(client.connection_pool, 'connection_kwargs') exercise_redis(client) - -@pytest.mark.skipif(REDIS_PY_VERSION < (2, 7), reason="Client list command introduced in 2.7") +@pytest.mark.skipif(REDIS_PY_VERSION < (2, 7), + reason='Client list command introduced in 2.7') @override_application_settings(_disable_instance_settings) @validate_transaction_metrics( - "test_custom_conn_pool:test_fake_conn_pool_disable_instance", - scoped_metrics=_base_scoped_metrics, - rollup_metrics=_disable_rollup_metrics, - background_task=True, -) + 'test_custom_conn_pool:test_fake_conn_pool_disable_instance', + scoped_metrics=_base_scoped_metrics, + rollup_metrics=_disable_rollup_metrics, + background_task=True) @background_task() def test_fake_conn_pool_disable_instance(): - client = redis.StrictRedis(host=DB_SETTINGS["host"], port=DB_SETTINGS["port"], db=0) + client = redis.StrictRedis(host=DB_SETTINGS['host'], + port=DB_SETTINGS['port'], db=0) # Get a real connection - conn = client.connection_pool.get_connection("GET") + conn = client.connection_pool.get_connection('GET') # Replace the original connection pool with one that doesn't # have the `connection_kwargs` attribute. fake_pool = FakeConnectionPool(conn) client.connection_pool = fake_pool - assert not hasattr(client.connection_pool, "connection_kwargs") + assert not hasattr(client.connection_pool, 'connection_kwargs') exercise_redis(client) diff --git a/tests/datastore_redis/test_execute_command.py b/tests/datastore_redis/test_execute_command.py index 99a5ed22f..741bc5034 100644 --- a/tests/datastore_redis/test_execute_command.py +++ b/tests/datastore_redis/test_execute_command.py @@ -14,16 +14,15 @@ import pytest import redis -from testing_support.db_settings import redis_settings -from testing_support.fixtures import override_application_settings -from testing_support.util import instance_hostname -from testing_support.validators.validate_transaction_metrics import ( - validate_transaction_metrics, -) from newrelic.api.background_task import background_task from newrelic.common.package_version_utils import get_package_version_tuple +from testing_support.fixtures import override_application_settings +from testing_support.validators.validate_transaction_metrics import validate_transaction_metrics +from testing_support.db_settings import redis_settings +from testing_support.util import instance_hostname + DB_SETTINGS = redis_settings()[0] REDIS_PY_VERSION = get_package_version_tuple("redis") @@ -31,157 +30,151 @@ # Settings _enable_instance_settings = { - "datastore_tracer.instance_reporting.enabled": True, + 'datastore_tracer.instance_reporting.enabled': True, } _disable_instance_settings = { - "datastore_tracer.instance_reporting.enabled": False, + 'datastore_tracer.instance_reporting.enabled': False, } # Metrics _base_scoped_metrics = [ - ("Datastore/operation/Redis/client_list", 1), + ('Datastore/operation/Redis/client_list', 1), ] if REDIS_PY_VERSION >= (5, 0): - _base_scoped_metrics.append( - ("Datastore/operation/Redis/client_setinfo", 2), - ) + _base_scoped_metrics.append(('Datastore/operation/Redis/client_setinfo', 2),) _base_rollup_metrics = [ - ("Datastore/all", 3), - ("Datastore/allOther", 3), - ("Datastore/Redis/all", 3), - ("Datastore/Redis/allOther", 3), - ("Datastore/operation/Redis/client_list", 1), + ('Datastore/all', 3), + ('Datastore/allOther', 3), + ('Datastore/Redis/all', 3), + ('Datastore/Redis/allOther', 3), + ('Datastore/operation/Redis/client_list', 1), ] if REDIS_PY_VERSION >= (5, 0): - _base_rollup_metrics.append( - ("Datastore/operation/Redis/client_setinfo", 2), - ) + _base_rollup_metrics.append(('Datastore/operation/Redis/client_setinfo', 2),) -_host = instance_hostname(DB_SETTINGS["host"]) -_port = DB_SETTINGS["port"] +_host = instance_hostname(DB_SETTINGS['host']) +_port = DB_SETTINGS['port'] -_instance_metric_name = "Datastore/instance/Redis/%s/%s" % (_host, _port) +_instance_metric_name = 'Datastore/instance/Redis/%s/%s' % (_host, _port) instance_metric_count = 3 if REDIS_PY_VERSION >= (5, 0) else 1 -_enable_rollup_metrics = _base_rollup_metrics.append((_instance_metric_name, instance_metric_count)) - -_disable_rollup_metrics = _base_rollup_metrics.append((_instance_metric_name, None)) +_enable_rollup_metrics = _base_rollup_metrics.append( + (_instance_metric_name, instance_metric_count) +) +_disable_rollup_metrics = _base_rollup_metrics.append( + (_instance_metric_name, None) +) def exercise_redis_multi_args(client): - client.execute_command("CLIENT", "LIST", parse="LIST") - + client.execute_command('CLIENT', 'LIST', parse='LIST') def exercise_redis_single_arg(client): - client.execute_command("CLIENT LIST") - + client.execute_command('CLIENT LIST') @override_application_settings(_enable_instance_settings) @validate_transaction_metrics( - "test_execute_command:test_strict_redis_execute_command_two_args_enable", - scoped_metrics=_base_scoped_metrics, - rollup_metrics=_enable_rollup_metrics, - background_task=True, -) + 'test_execute_command:test_strict_redis_execute_command_two_args_enable', + scoped_metrics=_base_scoped_metrics, + rollup_metrics=_enable_rollup_metrics, + background_task=True) @background_task() def test_strict_redis_execute_command_two_args_enable(): - r = redis.StrictRedis(host=DB_SETTINGS["host"], port=DB_SETTINGS["port"], db=0) + r = redis.StrictRedis(host=DB_SETTINGS['host'], + port=DB_SETTINGS['port'], db=0) exercise_redis_multi_args(r) - @override_application_settings(_disable_instance_settings) @validate_transaction_metrics( - "test_execute_command:test_strict_redis_execute_command_two_args_disabled", - scoped_metrics=_base_scoped_metrics, - rollup_metrics=_disable_rollup_metrics, - background_task=True, -) + 'test_execute_command:test_strict_redis_execute_command_two_args_disabled', + scoped_metrics=_base_scoped_metrics, + rollup_metrics=_disable_rollup_metrics, + background_task=True) @background_task() def test_strict_redis_execute_command_two_args_disabled(): - r = redis.StrictRedis(host=DB_SETTINGS["host"], port=DB_SETTINGS["port"], db=0) + r = redis.StrictRedis(host=DB_SETTINGS['host'], + port=DB_SETTINGS['port'], db=0) exercise_redis_multi_args(r) - @override_application_settings(_enable_instance_settings) @validate_transaction_metrics( - "test_execute_command:test_redis_execute_command_two_args_enable", - scoped_metrics=_base_scoped_metrics, - rollup_metrics=_enable_rollup_metrics, - background_task=True, -) + 'test_execute_command:test_redis_execute_command_two_args_enable', + scoped_metrics=_base_scoped_metrics, + rollup_metrics=_enable_rollup_metrics, + background_task=True) @background_task() def test_redis_execute_command_two_args_enable(): - r = redis.Redis(host=DB_SETTINGS["host"], port=DB_SETTINGS["port"], db=0) + r = redis.Redis(host=DB_SETTINGS['host'], + port=DB_SETTINGS['port'], db=0) exercise_redis_multi_args(r) - @override_application_settings(_disable_instance_settings) @validate_transaction_metrics( - "test_execute_command:test_redis_execute_command_two_args_disabled", - scoped_metrics=_base_scoped_metrics, - rollup_metrics=_disable_rollup_metrics, - background_task=True, -) + 'test_execute_command:test_redis_execute_command_two_args_disabled', + scoped_metrics=_base_scoped_metrics, + rollup_metrics=_disable_rollup_metrics, + background_task=True) @background_task() def test_redis_execute_command_two_args_disabled(): - r = redis.Redis(host=DB_SETTINGS["host"], port=DB_SETTINGS["port"], db=0) + r = redis.Redis(host=DB_SETTINGS['host'], + port=DB_SETTINGS['port'], db=0) exercise_redis_multi_args(r) - -@pytest.mark.skipif(REDIS_PY_VERSION < (2, 10), reason="This command is not implemented yet") +@pytest.mark.skipif(REDIS_PY_VERSION < (2, 10), + reason='This command is not implemented yet') @override_application_settings(_enable_instance_settings) @validate_transaction_metrics( - "test_execute_command:test_strict_redis_execute_command_as_one_arg_enable", - scoped_metrics=_base_scoped_metrics, - rollup_metrics=_enable_rollup_metrics, - background_task=True, -) + 'test_execute_command:test_strict_redis_execute_command_as_one_arg_enable', + scoped_metrics=_base_scoped_metrics, + rollup_metrics=_enable_rollup_metrics, + background_task=True) @background_task() def test_strict_redis_execute_command_as_one_arg_enable(): - r = redis.StrictRedis(host=DB_SETTINGS["host"], port=DB_SETTINGS["port"], db=0) + r = redis.StrictRedis(host=DB_SETTINGS['host'], + port=DB_SETTINGS['port'], db=0) exercise_redis_single_arg(r) - -@pytest.mark.skipif(REDIS_PY_VERSION < (2, 10), reason="This command is not implemented yet") +@pytest.mark.skipif(REDIS_PY_VERSION < (2, 10), + reason='This command is not implemented yet') @override_application_settings(_disable_instance_settings) @validate_transaction_metrics( - "test_execute_command:test_strict_redis_execute_command_as_one_arg_disabled", - scoped_metrics=_base_scoped_metrics, - rollup_metrics=_disable_rollup_metrics, - background_task=True, -) + 'test_execute_command:test_strict_redis_execute_command_as_one_arg_disabled', + scoped_metrics=_base_scoped_metrics, + rollup_metrics=_disable_rollup_metrics, + background_task=True) @background_task() def test_strict_redis_execute_command_as_one_arg_disabled(): - r = redis.StrictRedis(host=DB_SETTINGS["host"], port=DB_SETTINGS["port"], db=0) + r = redis.StrictRedis(host=DB_SETTINGS['host'], + port=DB_SETTINGS['port'], db=0) exercise_redis_single_arg(r) - -@pytest.mark.skipif(REDIS_PY_VERSION < (2, 10), reason="This command is not implemented yet") +@pytest.mark.skipif(REDIS_PY_VERSION < (2, 10), + reason='This command is not implemented yet') @override_application_settings(_enable_instance_settings) @validate_transaction_metrics( - "test_execute_command:test_redis_execute_command_as_one_arg_enable", - scoped_metrics=_base_scoped_metrics, - rollup_metrics=_enable_rollup_metrics, - background_task=True, -) + 'test_execute_command:test_redis_execute_command_as_one_arg_enable', + scoped_metrics=_base_scoped_metrics, + rollup_metrics=_enable_rollup_metrics, + background_task=True) @background_task() def test_redis_execute_command_as_one_arg_enable(): - r = redis.Redis(host=DB_SETTINGS["host"], port=DB_SETTINGS["port"], db=0) + r = redis.Redis(host=DB_SETTINGS['host'], + port=DB_SETTINGS['port'], db=0) exercise_redis_single_arg(r) - -@pytest.mark.skipif(REDIS_PY_VERSION < (2, 10), reason="This command is not implemented yet") +@pytest.mark.skipif(REDIS_PY_VERSION < (2, 10), + reason='This command is not implemented yet') @override_application_settings(_disable_instance_settings) @validate_transaction_metrics( - "test_execute_command:test_redis_execute_command_as_one_arg_disabled", - scoped_metrics=_base_scoped_metrics, - rollup_metrics=_disable_rollup_metrics, - background_task=True, -) + 'test_execute_command:test_redis_execute_command_as_one_arg_disabled', + scoped_metrics=_base_scoped_metrics, + rollup_metrics=_disable_rollup_metrics, + background_task=True) @background_task() def test_redis_execute_command_as_one_arg_disabled(): - r = redis.Redis(host=DB_SETTINGS["host"], port=DB_SETTINGS["port"], db=0) + r = redis.Redis(host=DB_SETTINGS['host'], + port=DB_SETTINGS['port'], db=0) exercise_redis_single_arg(r) diff --git a/tests/datastore_redis/test_get_and_set.py b/tests/datastore_redis/test_get_and_set.py index 92e6ef945..720433ae3 100644 --- a/tests/datastore_redis/test_get_and_set.py +++ b/tests/datastore_redis/test_get_and_set.py @@ -13,112 +13,109 @@ # limitations under the License. import redis -from testing_support.db_settings import redis_settings -from testing_support.fixtures import override_application_settings -from testing_support.util import instance_hostname -from testing_support.validators.validate_transaction_metrics import ( - validate_transaction_metrics, -) from newrelic.api.background_task import background_task +from testing_support.fixtures import override_application_settings +from testing_support.validators.validate_transaction_metrics import validate_transaction_metrics +from testing_support.db_settings import redis_settings +from testing_support.util import instance_hostname + DB_SETTINGS = redis_settings()[0] # Settings _enable_instance_settings = { - "datastore_tracer.instance_reporting.enabled": True, + 'datastore_tracer.instance_reporting.enabled': True, } _disable_instance_settings = { - "datastore_tracer.instance_reporting.enabled": False, + 'datastore_tracer.instance_reporting.enabled': False, } # Metrics _base_scoped_metrics = ( - ("Datastore/operation/Redis/get", 1), - ("Datastore/operation/Redis/set", 1), + ('Datastore/operation/Redis/get', 1), + ('Datastore/operation/Redis/set', 1), ) _base_rollup_metrics = ( - ("Datastore/all", 2), - ("Datastore/allOther", 2), - ("Datastore/Redis/all", 2), - ("Datastore/Redis/allOther", 2), - ("Datastore/operation/Redis/get", 1), - ("Datastore/operation/Redis/set", 1), + ('Datastore/all', 2), + ('Datastore/allOther', 2), + ('Datastore/Redis/all', 2), + ('Datastore/Redis/allOther', 2), + ('Datastore/operation/Redis/get', 1), + ('Datastore/operation/Redis/set', 1), ) _disable_rollup_metrics = list(_base_rollup_metrics) _enable_rollup_metrics = list(_base_rollup_metrics) -_host = instance_hostname(DB_SETTINGS["host"]) -_port = DB_SETTINGS["port"] +_host = instance_hostname(DB_SETTINGS['host']) +_port = DB_SETTINGS['port'] -_instance_metric_name = "Datastore/instance/Redis/%s/%s" % (_host, _port) +_instance_metric_name = 'Datastore/instance/Redis/%s/%s' % (_host, _port) -_enable_rollup_metrics.append((_instance_metric_name, 2)) +_enable_rollup_metrics.append( + (_instance_metric_name, 2) +) -_disable_rollup_metrics.append((_instance_metric_name, None)) +_disable_rollup_metrics.append( + (_instance_metric_name, None) +) # Operations - def exercise_redis(client): - client.set("key", "value") - client.get("key") - + client.set('key', 'value') + client.get('key') # Tests - @override_application_settings(_enable_instance_settings) @validate_transaction_metrics( - "test_get_and_set:test_strict_redis_operation_enable_instance", - scoped_metrics=_base_scoped_metrics, - rollup_metrics=_enable_rollup_metrics, - background_task=True, -) + 'test_get_and_set:test_strict_redis_operation_enable_instance', + scoped_metrics=_base_scoped_metrics, + rollup_metrics=_enable_rollup_metrics, + background_task=True) @background_task() def test_strict_redis_operation_enable_instance(): - client = redis.StrictRedis(host=DB_SETTINGS["host"], port=DB_SETTINGS["port"], db=0) + client = redis.StrictRedis(host=DB_SETTINGS['host'], + port=DB_SETTINGS['port'], db=0) exercise_redis(client) - @override_application_settings(_disable_instance_settings) @validate_transaction_metrics( - "test_get_and_set:test_strict_redis_operation_disable_instance", - scoped_metrics=_base_scoped_metrics, - rollup_metrics=_disable_rollup_metrics, - background_task=True, -) + 'test_get_and_set:test_strict_redis_operation_disable_instance', + scoped_metrics=_base_scoped_metrics, + rollup_metrics=_disable_rollup_metrics, + background_task=True) @background_task() def test_strict_redis_operation_disable_instance(): - client = redis.StrictRedis(host=DB_SETTINGS["host"], port=DB_SETTINGS["port"], db=0) + client = redis.StrictRedis(host=DB_SETTINGS['host'], + port=DB_SETTINGS['port'], db=0) exercise_redis(client) - @override_application_settings(_enable_instance_settings) @validate_transaction_metrics( - "test_get_and_set:test_redis_operation_enable_instance", - scoped_metrics=_base_scoped_metrics, - rollup_metrics=_enable_rollup_metrics, - background_task=True, -) + 'test_get_and_set:test_redis_operation_enable_instance', + scoped_metrics=_base_scoped_metrics, + rollup_metrics=_enable_rollup_metrics, + background_task=True) @background_task() def test_redis_operation_enable_instance(): - client = redis.Redis(host=DB_SETTINGS["host"], port=DB_SETTINGS["port"], db=0) + client = redis.Redis(host=DB_SETTINGS['host'], + port=DB_SETTINGS['port'], db=0) exercise_redis(client) - @override_application_settings(_disable_instance_settings) @validate_transaction_metrics( - "test_get_and_set:test_redis_operation_disable_instance", - scoped_metrics=_base_scoped_metrics, - rollup_metrics=_disable_rollup_metrics, - background_task=True, -) + 'test_get_and_set:test_redis_operation_disable_instance', + scoped_metrics=_base_scoped_metrics, + rollup_metrics=_disable_rollup_metrics, + background_task=True) @background_task() def test_redis_operation_disable_instance(): - client = redis.Redis(host=DB_SETTINGS["host"], port=DB_SETTINGS["port"], db=0) + client = redis.Redis(host=DB_SETTINGS['host'], + port=DB_SETTINGS['port'], db=0) exercise_redis(client) diff --git a/tests/datastore_redis/test_multiple_dbs.py b/tests/datastore_redis/test_multiple_dbs.py index 7d3dc75cb..9a5e299f0 100644 --- a/tests/datastore_redis/test_multiple_dbs.py +++ b/tests/datastore_redis/test_multiple_dbs.py @@ -14,16 +14,15 @@ import pytest import redis -from testing_support.db_settings import redis_settings -from testing_support.fixtures import override_application_settings -from testing_support.util import instance_hostname -from testing_support.validators.validate_transaction_metrics import ( - validate_transaction_metrics, -) from newrelic.api.background_task import background_task from newrelic.common.package_version_utils import get_package_version_tuple +from testing_support.fixtures import override_application_settings +from testing_support.validators.validate_transaction_metrics import validate_transaction_metrics +from testing_support.db_settings import redis_settings +from testing_support.util import instance_hostname + DB_MULTIPLE_SETTINGS = redis_settings() REDIS_PY_VERSION = get_package_version_tuple("redis") @@ -31,113 +30,101 @@ # Settings _enable_instance_settings = { - "datastore_tracer.instance_reporting.enabled": True, + 'datastore_tracer.instance_reporting.enabled': True, } _disable_instance_settings = { - "datastore_tracer.instance_reporting.enabled": False, + 'datastore_tracer.instance_reporting.enabled': False, } # Metrics _base_scoped_metrics = [ - ("Datastore/operation/Redis/get", 1), - ("Datastore/operation/Redis/set", 1), - ("Datastore/operation/Redis/client_list", 1), + ('Datastore/operation/Redis/get', 1), + ('Datastore/operation/Redis/set', 1), + ('Datastore/operation/Redis/client_list', 1), ] # client_setinfo was introduced in v5.0.0 and assigns info displayed in client_list output if REDIS_PY_VERSION >= (5, 0): - _base_scoped_metrics.append( - ("Datastore/operation/Redis/client_setinfo", 2), - ) + _base_scoped_metrics.append(('Datastore/operation/Redis/client_setinfo', 2),) datastore_all_metric_count = 5 if REDIS_PY_VERSION >= (5, 0) else 3 _base_rollup_metrics = [ - ("Datastore/all", datastore_all_metric_count), - ("Datastore/allOther", datastore_all_metric_count), - ("Datastore/Redis/all", datastore_all_metric_count), - ("Datastore/Redis/allOther", datastore_all_metric_count), - ("Datastore/operation/Redis/get", 1), - ("Datastore/operation/Redis/set", 1), - ("Datastore/operation/Redis/client_list", 1), + ('Datastore/all', datastore_all_metric_count), + ('Datastore/allOther', datastore_all_metric_count), + ('Datastore/Redis/all', datastore_all_metric_count), + ('Datastore/Redis/allOther', datastore_all_metric_count), + ('Datastore/operation/Redis/get', 1), + ('Datastore/operation/Redis/set', 1), + ('Datastore/operation/Redis/client_list', 1), ] # client_setinfo was introduced in v5.0.0 and assigns info displayed in client_list output if REDIS_PY_VERSION >= (5, 0): - _base_rollup_metrics.append( - ("Datastore/operation/Redis/client_setinfo", 2), - ) + _base_rollup_metrics.append(('Datastore/operation/Redis/client_setinfo', 2),) if len(DB_MULTIPLE_SETTINGS) > 1: redis_1 = DB_MULTIPLE_SETTINGS[0] redis_2 = DB_MULTIPLE_SETTINGS[1] - host_1 = instance_hostname(redis_1["host"]) - port_1 = redis_1["port"] + host_1 = instance_hostname(redis_1['host']) + port_1 = redis_1['port'] - host_2 = instance_hostname(redis_2["host"]) - port_2 = redis_2["port"] + host_2 = instance_hostname(redis_2['host']) + port_2 = redis_2['port'] - instance_metric_name_1 = "Datastore/instance/Redis/%s/%s" % (host_1, port_1) - instance_metric_name_2 = "Datastore/instance/Redis/%s/%s" % (host_2, port_2) + instance_metric_name_1 = 'Datastore/instance/Redis/%s/%s' % (host_1, port_1) + instance_metric_name_2 = 'Datastore/instance/Redis/%s/%s' % (host_2, port_2) instance_metric_name_1_count = 2 if REDIS_PY_VERSION >= (5, 0) else 2 instance_metric_name_2_count = 3 if REDIS_PY_VERSION >= (5, 0) else 1 - _enable_rollup_metrics = _base_rollup_metrics.extend( - [ + _enable_rollup_metrics = _base_rollup_metrics.extend([ (instance_metric_name_1, instance_metric_name_1_count), (instance_metric_name_2, instance_metric_name_2_count), - ] - ) + ]) - _disable_rollup_metrics = _base_rollup_metrics.extend( - [ + _disable_rollup_metrics = _base_rollup_metrics.extend([ (instance_metric_name_1, None), (instance_metric_name_2, None), - ] - ) + ]) def exercise_redis(client_1, client_2): - client_1.set("key", "value") - client_1.get("key") + client_1.set('key', 'value') + client_1.get('key') - client_2.execute_command("CLIENT", "LIST", parse="LIST") + client_2.execute_command('CLIENT', 'LIST', parse='LIST') - -@pytest.mark.skipif(len(DB_MULTIPLE_SETTINGS) < 2, reason="Test environment not configured with multiple databases.") +@pytest.mark.skipif(len(DB_MULTIPLE_SETTINGS) < 2, + reason='Test environment not configured with multiple databases.') @override_application_settings(_enable_instance_settings) -@validate_transaction_metrics( - "test_multiple_dbs:test_multiple_datastores_enabled", - scoped_metrics=_base_scoped_metrics, - rollup_metrics=_enable_rollup_metrics, - background_task=True, -) +@validate_transaction_metrics('test_multiple_dbs:test_multiple_datastores_enabled', + scoped_metrics=_base_scoped_metrics, + rollup_metrics=_enable_rollup_metrics, + background_task=True) @background_task() def test_multiple_datastores_enabled(): redis1 = DB_MULTIPLE_SETTINGS[0] redis2 = DB_MULTIPLE_SETTINGS[1] - client_1 = redis.StrictRedis(host=redis1["host"], port=redis1["port"], db=0) - client_2 = redis.StrictRedis(host=redis2["host"], port=redis2["port"], db=1) + client_1 = redis.StrictRedis(host=redis1['host'], port=redis1['port'], db=0) + client_2 = redis.StrictRedis(host=redis2['host'], port=redis2['port'], db=1) exercise_redis(client_1, client_2) - -@pytest.mark.skipif(len(DB_MULTIPLE_SETTINGS) < 2, reason="Test environment not configured with multiple databases.") +@pytest.mark.skipif(len(DB_MULTIPLE_SETTINGS) < 2, + reason='Test environment not configured with multiple databases.') @override_application_settings(_disable_instance_settings) -@validate_transaction_metrics( - "test_multiple_dbs:test_multiple_datastores_disabled", - scoped_metrics=_base_scoped_metrics, - rollup_metrics=_disable_rollup_metrics, - background_task=True, -) +@validate_transaction_metrics('test_multiple_dbs:test_multiple_datastores_disabled', + scoped_metrics=_base_scoped_metrics, + rollup_metrics=_disable_rollup_metrics, + background_task=True) @background_task() def test_multiple_datastores_disabled(): redis1 = DB_MULTIPLE_SETTINGS[0] redis2 = DB_MULTIPLE_SETTINGS[1] - client_1 = redis.StrictRedis(host=redis1["host"], port=redis1["port"], db=0) - client_2 = redis.StrictRedis(host=redis2["host"], port=redis2["port"], db=1) + client_1 = redis.StrictRedis(host=redis1['host'], port=redis1['port'], db=0) + client_2 = redis.StrictRedis(host=redis2['host'], port=redis2['port'], db=1) exercise_redis(client_1, client_2) diff --git a/tests/datastore_redis/test_rb.py b/tests/datastore_redis/test_rb.py index 8915b4e96..3b25593be 100644 --- a/tests/datastore_redis/test_rb.py +++ b/tests/datastore_redis/test_rb.py @@ -12,24 +12,24 @@ # See the License for the specific language governing permissions and # limitations under the License. -""" The purpose of these tests is to confirm that we will record +''' The purpose of these tests is to confirm that we will record record instance info for Redis Blaster commands that go through redis.Connection:send_command(). Commands that don't use send_command, like the one that use the fanout client, won't have instance info. -""" +''' import pytest +import redis import six -from testing_support.db_settings import redis_settings -from testing_support.fixtures import override_application_settings -from testing_support.util import instance_hostname -from testing_support.validators.validate_transaction_metrics import ( - validate_transaction_metrics, -) from newrelic.api.background_task import background_task from newrelic.common.package_version_utils import get_package_version_tuple +from testing_support.fixtures import override_application_settings +from testing_support.validators.validate_transaction_metrics import validate_transaction_metrics +from testing_support.db_settings import redis_settings +from testing_support.util import instance_hostname + DB_SETTINGS = redis_settings()[0] REDIS_PY_VERSION = get_package_version_tuple("redis") @@ -37,10 +37,10 @@ # Settings _enable_instance_settings = { - "datastore_tracer.instance_reporting.enabled": True, + 'datastore_tracer.instance_reporting.enabled': True, } _disable_instance_settings = { - "datastore_tracer.instance_reporting.enabled": False, + 'datastore_tracer.instance_reporting.enabled': False, } # Metrics @@ -49,78 +49,88 @@ # so we just check for base metrics. _base_scoped_metrics = ( - ("Datastore/operation/Redis/get", 1), - ("Datastore/operation/Redis/set", 1), + ('Datastore/operation/Redis/get', 1), + ('Datastore/operation/Redis/set', 1), ) _base_rollup_metrics = ( - ("Datastore/all", 2), - ("Datastore/allOther", 2), - ("Datastore/Redis/all", 2), - ("Datastore/Redis/allOther", 2), - ("Datastore/operation/Redis/get", 1), - ("Datastore/operation/Redis/set", 1), + ('Datastore/all', 2), + ('Datastore/allOther', 2), + ('Datastore/Redis/all', 2), + ('Datastore/Redis/allOther', 2), + ('Datastore/operation/Redis/get', 1), + ('Datastore/operation/Redis/set', 1), ) _disable_rollup_metrics = list(_base_rollup_metrics) _enable_rollup_metrics = list(_base_rollup_metrics) -_host = instance_hostname(DB_SETTINGS["host"]) -_port = DB_SETTINGS["port"] +_host = instance_hostname(DB_SETTINGS['host']) +_port = DB_SETTINGS['port'] -_instance_metric_name = "Datastore/instance/Redis/%s/%s" % (_host, _port) +_instance_metric_name = 'Datastore/instance/Redis/%s/%s' % (_host, _port) -_enable_rollup_metrics.append((_instance_metric_name, 2)) +_enable_rollup_metrics.append( + (_instance_metric_name, 2) +) -_disable_rollup_metrics.append((_instance_metric_name, None)) +_disable_rollup_metrics.append( + (_instance_metric_name, None) +) # Operations def exercise_redis(routing_client): - routing_client.set("key", "value") - routing_client.get("key") + routing_client.set('key', 'value') + routing_client.get('key') def exercise_fanout(cluster): - with cluster.fanout(hosts="all") as client: - client.execute_command("CLIENT", "LIST") + with cluster.fanout(hosts='all') as client: + client.execute_command('CLIENT', 'LIST') # Tests -@pytest.mark.skipif(six.PY3, reason="Redis Blaster is Python 2 only.") -@pytest.mark.skipif(REDIS_PY_VERSION < (2, 10, 2), reason="Redis Blaster requires redis>=2.10.2") +@pytest.mark.skipif(six.PY3, reason='Redis Blaster is Python 2 only.') +@pytest.mark.skipif(REDIS_PY_VERSION < (2, 10, 2), + reason='Redis Blaster requires redis>=2.10.2') @override_application_settings(_enable_instance_settings) @validate_transaction_metrics( - "test_rb:test_redis_blaster_operation_enable_instance", - scoped_metrics=_base_scoped_metrics, - rollup_metrics=_enable_rollup_metrics, - background_task=True, -) + 'test_rb:test_redis_blaster_operation_enable_instance', + scoped_metrics=_base_scoped_metrics, + rollup_metrics=_enable_rollup_metrics, + background_task=True) @background_task() def test_redis_blaster_operation_enable_instance(): from rb import Cluster - cluster = Cluster(hosts={0: {"port": DB_SETTINGS["port"]}}, host_defaults={"host": DB_SETTINGS["host"]}) + cluster = Cluster( + hosts={0: {'port': DB_SETTINGS['port']}}, + host_defaults={'host': DB_SETTINGS['host']} + ) exercise_fanout(cluster) client = cluster.get_routing_client() exercise_redis(client) -@pytest.mark.skipif(six.PY3, reason="Redis Blaster is Python 2 only.") -@pytest.mark.skipif(REDIS_PY_VERSION < (2, 10, 2), reason="Redis Blaster requires redis>=2.10.2") +@pytest.mark.skipif(six.PY3, reason='Redis Blaster is Python 2 only.') +@pytest.mark.skipif(REDIS_PY_VERSION < (2, 10,2 ), + reason='Redis Blaster requires redis>=2.10.2') @override_application_settings(_disable_instance_settings) @validate_transaction_metrics( - "test_rb:test_redis_blaster_operation_disable_instance", - scoped_metrics=_base_scoped_metrics, - rollup_metrics=_disable_rollup_metrics, - background_task=True, -) + 'test_rb:test_redis_blaster_operation_disable_instance', + scoped_metrics=_base_scoped_metrics, + rollup_metrics=_disable_rollup_metrics, + background_task=True) @background_task() def test_redis_blaster_operation_disable_instance(): from rb import Cluster - cluster = Cluster(hosts={0: {"port": DB_SETTINGS["port"]}}, host_defaults={"host": DB_SETTINGS["host"]}) + cluster = Cluster( + hosts={0: {'port': DB_SETTINGS['port']}}, + host_defaults={'host': DB_SETTINGS['host']} + ) exercise_fanout(cluster) client = cluster.get_routing_client() diff --git a/tox.ini b/tox.ini index f1fcf833c..b142cd840 100644 --- a/tox.ini +++ b/tox.ini @@ -47,14 +47,11 @@ skip_missing_interpreters = false envlist = python-adapter_cheroot-{py27,py37,py38,py39,py310,py311}, python-adapter_daphne-{py37,py38,py39,py310,py311}-daphnelatest, - python-adapter_daphne-py38-daphne{0204,0205}, python-adapter_gevent-{py27,py37,py38,py310,py311}, python-adapter_gunicorn-{py37,py38,py39,py310,py311}-aiohttp3-gunicornlatest, python-adapter_hypercorn-{py37,py38,py39,py310,py311}-hypercornlatest, python-adapter_hypercorn-py38-hypercorn{0010,0011,0012,0013}, - python-adapter_uvicorn-py37-uvicorn03, - python-adapter_uvicorn-{py37,py38,py39,py310,py311}-uvicornlatest, - python-adapter_waitress-{py37,py38,py39}-waitress010404, + python-adapter_uvicorn-{py37,py38,py39,py310,py311}-uvicorn{014,latest}, python-adapter_waitress-{py37,py38,py39,py310}-waitress02, python-adapter_waitress-{py37,py38,py39,py310,py311}-waitresslatest, python-agent_features-{py27,py37,py38,py39,py310,py311}-{with,without}_extensions, @@ -115,10 +112,7 @@ envlist = python-framework_aiohttp-{py37,py38,py39,py310,py311,pypy38}-aiohttp03, python-framework_ariadne-{py37,py38,py39,py310,py311}-ariadnelatest, python-framework_ariadne-py37-ariadne{0011,0012,0013}, - python-framework_bottle-py27-bottle{0008,0009,0010}, - python-framework_bottle-{py27,py37,py38,py39,pypy38}-bottle{0011,0012}, - python-framework_bottle-{py310,py311}-bottle0012, - python-framework_bottle-pypy27-bottle{0008,0009,0010,0011,0012}, + python-framework_bottle-{py27,py37,py38,py39,py310,py311,pypy27,pypy38}-bottle0012, ; CherryPy still uses inspect.getargspec, deprecated in favor of inspect.getfullargspec. Not supported in 3.11 python-framework_cherrypy-{py37,py38,py39,py310,py311,pypy38}-CherryPylatest, python-framework_django-{pypy27,py27}-Django0103, @@ -138,10 +132,9 @@ envlist = python-framework_graphql-py37-graphql{0300,0301,0302}, grpc-framework_grpc-py27-grpc0125, grpc-framework_grpc-{py37,py38,py39,py310,py311}-grpclatest, - python-framework_pyramid-{pypy27,py27,py38}-Pyramid0104, python-framework_pyramid-{pypy27,py27,pypy38,py37,py38,py39,py310,py311}-Pyramid0110-cornice, python-framework_pyramid-{py37,py38,py39,py310,py311,pypy38}-Pyramidlatest, - python-framework_sanic-{py38,pypy38}-sanic{190301,1906,1912,200904,210300,2109,2112,2203,2290}, + python-framework_sanic-{py38,pypy38}-sanic{200904,210300,2109,2112,2203,2290}, python-framework_sanic-{py37,py38,py39,py310,py311,pypy38}-saniclatest, python-framework_starlette-{py310,pypy38}-starlette{0014,0015,0019,0028}, python-framework_starlette-{py37,py38}-starlette{002001}, @@ -149,18 +142,17 @@ envlist = python-framework_strawberry-{py37,py38,py39,py310,py311}-strawberrylatest, python-logger_logging-{py27,py37,py38,py39,py310,py311,pypy27,pypy38}, python-logger_loguru-{py37,py38,py39,py310,py311,pypy38}-logurulatest, - python-logger_loguru-py39-loguru{06,05,04,03}, + python-logger_loguru-py39-loguru{06,05}, python-logger_structlog-{py37,py38,py39,py310,py311,pypy38}-structloglatest, python-framework_tornado-{py38,py39,py310,py311}-tornadolatest, python-framework_tornado-{py38,py39,py310,py311}-tornadomaster, - rabbitmq-messagebroker_pika-{py27,py37,py38,py39,pypy27,pypy38}-pika0.13, rabbitmq-messagebroker_pika-{py37,py38,py39,py310,py311,pypy38}-pikalatest, kafka-messagebroker_confluentkafka-{py37,py38,py39,py310,py311}-confluentkafkalatest, kafka-messagebroker_confluentkafka-{py27,py39}-confluentkafka{0107,0106}, ; confluent-kafka had a bug in 1.8.2's setup.py file which was incompatible with 2.7. kafka-messagebroker_confluentkafka-{py39}-confluentkafka{0108}, kafka-messagebroker_kafkapython-{pypy27,py27,py37,py38,pypy38}-kafkapythonlatest, - kafka-messagebroker_kafkapython-{py27,py38}-kafkapython{020001,020000,0104}, + kafka-messagebroker_kafkapython-{py27,py38}-kafkapython{020001,020000}, python-template_genshi-{py27,py37,py311}-genshilatest python-template_jinja2-{py37,py311}-jinja2latest python-template_mako-{py27,py37,py310,py311} @@ -177,8 +169,6 @@ deps = # Test Suite Dependencies adapter_cheroot: cheroot adapter_daphne-daphnelatest: daphne - adapter_daphne-daphne0205: daphne<2.6 - adapter_daphne-daphne0204: daphne<2.5 adapter_gevent: WSGIProxy2 adapter_gevent: gevent adapter_gevent: urllib3 @@ -191,12 +181,10 @@ deps = adapter_hypercorn-hypercorn0012: hypercorn<0.13 adapter_hypercorn-hypercorn0011: hypercorn<0.12 adapter_hypercorn-hypercorn0010: hypercorn<0.11 - adapter_uvicorn-uvicorn03: uvicorn<0.4 adapter_uvicorn-uvicorn014: uvicorn<0.15 adapter_uvicorn-uvicornlatest: uvicorn adapter_uvicorn: typing-extensions adapter_waitress: WSGIProxy2 - adapter_waitress-waitress010404: waitress<1.4.5 adapter_waitress-waitress02: waitress<2.1 adapter_waitress-waitresslatest: waitress agent_features: beautifulsoup4 @@ -283,10 +271,6 @@ deps = framework_ariadne-ariadne0011: ariadne<0.12 framework_ariadne-ariadne0012: ariadne<0.13 framework_ariadne-ariadne0013: ariadne<0.14 - framework_bottle-bottle0008: bottle<0.9.0 - framework_bottle-bottle0009: bottle<0.10.0 - framework_bottle-bottle0010: bottle<0.11.0 - framework_bottle-bottle0011: bottle<0.12.0 framework_bottle-bottle0012: bottle<0.13.0 framework_bottle: jinja2<3.1 framework_bottle: markupsafe<2.1 @@ -330,13 +314,8 @@ deps = protobuf04: protobuf<5 framework_pyramid: routes framework_pyramid-cornice: cornice!=5.0.0 - framework_pyramid-Pyramid0104: Pyramid<1.5 framework_pyramid-Pyramid0110: Pyramid<1.11 framework_pyramid-Pyramidlatest: Pyramid - framework_sanic-sanic1812: sanic<18.13 - framework_sanic-sanic190301: sanic<19.3.2 - framework_sanic-sanic1906: sanic<19.7 - framework_sanic-sanic1912: sanic<19.13 framework_sanic-sanic200904: sanic<20.9.5 framework_sanic-sanic210300: sanic<21.3.1 framework_sanic-sanic2109: sanic<21.10 @@ -344,8 +323,7 @@ deps = framework_sanic-sanic2203: sanic<22.4 framework_sanic-sanic2290: sanic<22.9.1 framework_sanic-saniclatest: sanic - framework_sanic-sanic{1812,190301,1906}: aiohttp - framework_sanic-sanic{1812,190301,1906,1912,200904,210300,2109,2112,2203,2290}: websockets<11 + framework_sanic-sanic{200904,210300,2109,2112,2203,2290}: websockets<11 ; For test_exception_in_middleware test, anyio is used: ; https://github.com/encode/starlette/pull/1157 ; but anyiolatest creates breaking changes to our tests @@ -366,10 +344,7 @@ deps = logger_loguru-logurulatest: loguru logger_loguru-loguru06: loguru<0.7 logger_loguru-loguru05: loguru<0.6 - logger_loguru-loguru04: loguru<0.5 - logger_loguru-loguru03: loguru<0.4 logger_structlog-structloglatest: structlog - messagebroker_pika-pika0.13: pika<0.14 messagebroker_pika-pikalatest: pika messagebroker_pika: tornado<5 messagebroker_pika-{py27,pypy27}: enum34 @@ -380,7 +355,6 @@ deps = messagebroker_kafkapython-kafkapythonlatest: kafka-python messagebroker_kafkapython-kafkapython020001: kafka-python<2.0.2 messagebroker_kafkapython-kafkapython020000: kafka-python<2.0.1 - messagebroker_kafkapython-kafkapython0104: kafka-python<1.5 template_genshi-genshilatest: genshi template_jinja2-jinja2latest: Jinja2 template_mako: mako