Skip to content

Commit a726625

Browse files
committed
Merge branch 'main' into develop-scikitlearn
2 parents d10c9f7 + c2d4629 commit a726625

File tree

17 files changed

+515
-193
lines changed

17 files changed

+515
-193
lines changed

.github/actions/setup-python-matrix/action.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,4 +47,4 @@ runs:
4747
shell: bash
4848
run: |
4949
python3.10 -m pip install -U pip
50-
python3.10 -m pip install -U wheel setuptools 'tox<4' 'virtualenv<20.22.0'
50+
python3.10 -m pip install -U wheel setuptools tox 'virtualenv<20.22.0'

.github/workflows/tests.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -255,6 +255,14 @@ jobs:
255255
- uses: actions/checkout@v3
256256
- uses: ./.github/actions/setup-python-matrix
257257

258+
- name: Install odbc driver for postgresql
259+
run: |
260+
sudo apt-get update
261+
sudo sudo apt-get install odbc-postgresql
262+
sudo sed -i 's/Driver=psqlodbca.so/Driver=\/usr\/lib\/x86_64-linux-gnu\/odbc\/psqlodbca.so/g' /etc/odbcinst.ini
263+
sudo sed -i 's/Driver=psqlodbcw.so/Driver=\/usr\/lib\/x86_64-linux-gnu\/odbc\/psqlodbcw.so/g' /etc/odbcinst.ini
264+
sudo sed -i 's/Setup=libodbcpsqlS.so/Setup=\/usr\/lib\/x86_64-linux-gnu\/odbc\/libodbcpsqlS.so/g' /etc/odbcinst.ini
265+
258266
- name: Get Environments
259267
id: get-envs
260268
run: |

codecov.yml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
ignore:
2+
- "newrelic/packages/**/*"
3+
- "newrelic/packages/*"
4+
- "newrelic/hooks/adapter_meinheld.py"
5+
- "newrelic/hooks/adapter_flup.py"
6+
- "newrelic/hooks/component_piston.py"
7+
- "newrelic/hooks/datastore_pyelasticsearch.py"
8+
- "newrelic/hooks/external_pywapi.py"
9+
- "newrelic/hooks/external_dropbox.py"
10+
- "newrelic/hooks/external_facepy.py"
11+
- "newrelic/hooks/external_xmlrpclib.py"
12+
- "newrelic/hooks/framework_pylons.py"
13+
- "newrelic/hooks/framework_web2py.py"
14+
- "newrelic/hooks/middleware_weberror.py"
15+
- "newrelic/hooks/framework_webpy.py"
16+
- "newrelic/hooks/database_oursql.py"
17+
- "newrelic/hooks/database_psycopg2ct.py"
18+
- "newrelic/hooks/datastore_umemcache.py"
19+
# Temporarily disable kafka
20+
- "newrelic/hooks/messagebroker_kafkapython.py"
21+
- "newrelic/hooks/messagebroker_confluentkafka.py"

newrelic/hooks/adapter_waitress.py

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -12,17 +12,16 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15-
import newrelic.api.wsgi_application
16-
import newrelic.api.in_function
15+
from newrelic.api.in_function import wrap_in_function
16+
from newrelic.api.wsgi_application import WSGIApplicationWrapper
17+
from newrelic.common.package_version_utils import get_package_version
1718

18-
def instrument_waitress_server(module):
1919

20-
def wrap_wsgi_application_entry_point(server, application,
21-
*args, **kwargs):
22-
application = newrelic.api.wsgi_application.WSGIApplicationWrapper(
23-
application)
20+
def instrument_waitress_server(module):
21+
def wrap_wsgi_application_entry_point(server, application, *args, **kwargs):
22+
dispatcher_details = ("Waitress", get_package_version("waitress"))
23+
application = WSGIApplicationWrapper(application, dispatcher=dispatcher_details)
2424
args = [server, application] + list(args)
2525
return (args, kwargs)
2626

27-
newrelic.api.in_function.wrap_in_function(module,
28-
'WSGIServer.__init__', wrap_wsgi_application_entry_point)
27+
wrap_in_function(module, "WSGIServer.__init__", wrap_wsgi_application_entry_point)
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
# Copyright 2010 New Relic, Inc.
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
from threading import Thread
16+
from time import sleep
17+
18+
from testing_support.sample_applications import (
19+
raise_exception_application,
20+
raise_exception_finalize,
21+
raise_exception_response,
22+
simple_app_raw,
23+
)
24+
from testing_support.util import get_open_port
25+
26+
27+
def sample_application(environ, start_response):
28+
path_info = environ.get("PATH_INFO")
29+
30+
if path_info.startswith("/raise-exception-application"):
31+
return raise_exception_application(environ, start_response)
32+
elif path_info.startswith("/raise-exception-response"):
33+
return raise_exception_response(environ, start_response)
34+
elif path_info.startswith("/raise-exception-finalize"):
35+
return raise_exception_finalize(environ, start_response)
36+
37+
return simple_app_raw(environ, start_response)
38+
39+
40+
def setup_application():
41+
port = get_open_port()
42+
43+
def run_wsgi():
44+
from waitress import serve
45+
46+
serve(sample_application, host="127.0.0.1", port=port)
47+
48+
wsgi_thread = Thread(target=run_wsgi)
49+
wsgi_thread.daemon = True
50+
wsgi_thread.start()
51+
52+
sleep(1)
53+
54+
return port

tests/adapter_waitress/conftest.py

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
# Copyright 2010 New Relic, Inc.
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
import pytest
16+
import webtest
17+
from testing_support.fixtures import ( # noqa: F401; pylint: disable=W0611
18+
collector_agent_registration_fixture,
19+
collector_available_fixture,
20+
)
21+
22+
_default_settings = {
23+
"transaction_tracer.explain_threshold": 0.0,
24+
"transaction_tracer.transaction_threshold": 0.0,
25+
"transaction_tracer.stack_trace_threshold": 0.0,
26+
"debug.log_data_collector_payloads": True,
27+
"debug.record_transaction_failure": True,
28+
}
29+
30+
collector_agent_registration = collector_agent_registration_fixture(
31+
app_name="Python Agent Test (Waitress)", default_settings=_default_settings
32+
)
33+
34+
35+
@pytest.fixture(autouse=True, scope="session")
36+
def target_application():
37+
import _application
38+
39+
port = _application.setup_application()
40+
return webtest.TestApp("http://localhost:%d" % port)

tests/adapter_waitress/test_wsgi.py

Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
# Copyright 2010 New Relic, Inc.
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
16+
from testing_support.fixtures import (
17+
override_application_settings,
18+
raise_background_exceptions,
19+
wait_for_background_threads,
20+
)
21+
from testing_support.validators.validate_transaction_errors import (
22+
validate_transaction_errors,
23+
)
24+
from testing_support.validators.validate_transaction_metrics import (
25+
validate_transaction_metrics,
26+
)
27+
28+
from newrelic.common.package_version_utils import get_package_version
29+
30+
WAITRESS_VERSION = get_package_version("waitress")
31+
32+
33+
@override_application_settings({"transaction_name.naming_scheme": "framework"})
34+
def test_wsgi_application_index(target_application):
35+
@validate_transaction_metrics(
36+
"_application:sample_application",
37+
custom_metrics=[
38+
("Python/Dispatcher/Waitress/%s" % WAITRESS_VERSION, 1),
39+
],
40+
)
41+
@raise_background_exceptions()
42+
@wait_for_background_threads()
43+
def _test():
44+
response = target_application.get("/")
45+
assert response.status == "200 OK"
46+
47+
_test()
48+
49+
50+
@override_application_settings({"transaction_name.naming_scheme": "framework"})
51+
def test_raise_exception_application(target_application):
52+
@validate_transaction_errors(["builtins:RuntimeError"])
53+
@validate_transaction_metrics(
54+
"_application:sample_application",
55+
custom_metrics=[
56+
("Python/Dispatcher/Waitress/%s" % WAITRESS_VERSION, 1),
57+
],
58+
)
59+
@raise_background_exceptions()
60+
@wait_for_background_threads()
61+
def _test():
62+
response = target_application.get("/raise-exception-application/", status=500)
63+
assert response.status == "500 Internal Server Error"
64+
65+
_test()
66+
67+
68+
@override_application_settings({"transaction_name.naming_scheme": "framework"})
69+
def test_raise_exception_response(target_application):
70+
@validate_transaction_errors(["builtins:RuntimeError"])
71+
@validate_transaction_metrics(
72+
"_application:sample_application",
73+
custom_metrics=[
74+
("Python/Dispatcher/Waitress/%s" % WAITRESS_VERSION, 1),
75+
],
76+
)
77+
@raise_background_exceptions()
78+
@wait_for_background_threads()
79+
def _test():
80+
response = target_application.get("/raise-exception-response/", status=500)
81+
assert response.status == "500 Internal Server Error"
82+
83+
_test()
84+
85+
86+
@override_application_settings({"transaction_name.naming_scheme": "framework"})
87+
def test_raise_exception_finalize(target_application):
88+
@validate_transaction_errors(["builtins:RuntimeError"])
89+
@validate_transaction_metrics(
90+
"_application:sample_application",
91+
custom_metrics=[
92+
("Python/Dispatcher/Waitress/%s" % WAITRESS_VERSION, 1),
93+
],
94+
)
95+
@raise_background_exceptions()
96+
@wait_for_background_threads()
97+
def _test():
98+
response = target_application.get("/raise-exception-finalize/", status=500)
99+
assert response.status == "500 Internal Server Error"
100+
101+
_test()

tests/datastore_aioredis/test_uninstrumented_methods.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
"channels",
2020
"client_tracking_off",
2121
"client_tracking_on",
22+
"client_no_touch",
2223
"close",
2324
"closed",
2425
"connection_pool",

tests/datastore_pyodbc/conftest.py

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
# Copyright 2010 New Relic, Inc.
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
from testing_support.fixtures import ( # noqa: F401; pylint: disable=W0611
16+
collector_agent_registration_fixture,
17+
collector_available_fixture,
18+
)
19+
20+
_default_settings = {
21+
"transaction_tracer.explain_threshold": 0.0,
22+
"transaction_tracer.transaction_threshold": 0.0,
23+
"transaction_tracer.stack_trace_threshold": 0.0,
24+
"debug.log_data_collector_payloads": True,
25+
"debug.record_transaction_failure": True,
26+
"debug.log_explain_plan_queries": True,
27+
}
28+
29+
collector_agent_registration = collector_agent_registration_fixture(
30+
app_name="Python Agent Test (datastore_pyodbc)",
31+
default_settings=_default_settings,
32+
linked_applications=["Python Agent Test (datastore)"],
33+
)

0 commit comments

Comments
 (0)