Skip to content

Commit d9c6462

Browse files
TimPansinoumaannamalailrafeeimergify[bot]hmstepanek
authored
Merge main into develop-logging-attributes (#1034)
* Remove RPM config workflow. (#1007) * Nonced CSP Support (#998) * Add nonce to CSP in browser agent * Adjust nonce position * Add testing for browser timing nonces * Drop py27 from memcache testing. (#1018) * Temporarily pin hypercorn version in tests (#1021) * Temporarily pin hypercorn to <0.16 * Temporarily pin hypercorn to <0.16 * Add comment to tox.ini --------- Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com> * Remove case sensitive check in ASGIBrowserMiddleware check. (#1017) * Remove case sensitive check in should_insert_html. * [Mega-Linter] Apply linters fixes * Remove header decoding. --------- Co-authored-by: umaannamalai <[email protected]> * Parallel Wheel Builds (#1024) * Fix import issue in tests * Parallelize wheel building and add muslinux support --------- Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com> * Deprecate get_browser_timing_footer API (#999) * Add nonce to CSP in browser agent * Adjust nonce position * Add testing for browser timing nonces * Deprecated browser timing footer APIs. * Full rip out of browser timing footer * Remove cross agent tests for RUM footer (per repo) * Update cat_map tests * Adjust browser header generation timing accuracy * Fix browser tests * Linting * Apply suggestions from code review --------- Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com> * Deprecate ObjectWrapper API (#996) * Update wrapt to 1.16.0 * Import duplicate functions directly from wrapt * Update object wrappers for wrapt 1.16.0 * Add warning to wrapt duplicate code * Linting * Use super rather than hard coded Object proxy * Formatting * Add test file for wrapper attributes * Unify ObjectWrapper with FunctionWrapper * Remove ObjectWrapper from httplib * Remove ObjectWrapper from tastypie * Replace ObjectWrapper use in console * Remove ObjectWrapper from celery * Remove extra import * Update agent APIs * Deprecate ObjectWrapper * Fix object wrapper imports * More import issues * Fix taskwrapper in celery * Pin last supported flask restx version for 3.7 * Undo tox changes * Change all api.object_wrapper references to use new locations * Fixup: callable_name import * Fixup: callable_name import --------- Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com> Co-authored-by: Hannah Stepanek <[email protected]> * Add checkout actions to deploy workflow (#1027) * Remove Slack section in CONTRIBUTING.rst. (#1029) * Remove duplicated function * Pin starlette before 0.35.1 * Change starlette pin --------- Co-authored-by: Uma Annamalai <[email protected]> Co-authored-by: Lalleh Rafeei <[email protected]> Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com> Co-authored-by: umaannamalai <[email protected]> Co-authored-by: Hannah Stepanek <[email protected]>
1 parent 92cca1e commit d9c6462

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

45 files changed

+1495
-1848
lines changed

.github/workflows/deploy-python.yml

Lines changed: 123 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -20,17 +20,125 @@ on:
2020
- published
2121

2222
jobs:
23-
deploy-linux:
23+
build-linux-py3:
2424
runs-on: ubuntu-latest
25+
strategy:
26+
fail-fast: true
27+
matrix:
28+
wheel:
29+
- cp37-manylinux
30+
- cp37-musllinux
31+
- cp38-manylinux
32+
- cp38-musllinux
33+
- cp39-manylinux
34+
- cp39-musllinux
35+
- cp310-manylinux
36+
- cp310-musllinux
37+
- cp311-manylinux
38+
- cp311-musllinux
39+
- cp312-manylinux
40+
- cp312-musllinux
2541

2642
steps:
27-
- uses: actions/checkout@v3
43+
- uses: actions/checkout@v4
2844
with:
2945
persist-credentials: false
3046
fetch-depth: 0
3147

3248
- name: Setup QEMU
33-
uses: docker/setup-qemu-action@v1
49+
uses: docker/setup-qemu-action@v3
50+
51+
- name: Build Wheels
52+
uses: pypa/[email protected]
53+
env:
54+
CIBW_PLATFORM: linux
55+
CIBW_BUILD: "${{ matrix.wheel }}*"
56+
CIBW_ARCHS_LINUX: x86_64 aarch64
57+
CIBW_ENVIRONMENT: "LD_LIBRARY_PATH=/opt/rh/devtoolset-8/root/usr/lib64:/opt/rh/devtoolset-8/root/usr/lib:/opt/rh/devtoolset-8/root/usr/lib64/dyninst:/opt/rh/devtoolset-8/root/usr/lib/dyninst:/usr/local/lib64:/usr/local/lib"
58+
CIBW_TEST_REQUIRES: pytest
59+
CIBW_TEST_COMMAND: "PYTHONPATH={project}/tests pytest {project}/tests/agent_unittests -vx"
60+
61+
- name: Upload Artifacts
62+
uses: actions/[email protected]
63+
with:
64+
name: ${{ github.job }}-${{ matrix.wheel }}
65+
path: ./wheelhouse/*.whl
66+
retention-days: 1
67+
68+
build-linux-py2:
69+
runs-on: ubuntu-latest
70+
71+
steps:
72+
- uses: actions/checkout@v4
73+
with:
74+
persist-credentials: false
75+
fetch-depth: 0
76+
77+
- name: Setup QEMU
78+
uses: docker/setup-qemu-action@v3
79+
80+
- name: Build Wheels
81+
uses: pypa/[email protected]
82+
env:
83+
CIBW_PLATFORM: linux
84+
CIBW_BUILD: cp27-manylinux_x86_64
85+
CIBW_ARCHS_LINUX: x86_64
86+
CIBW_ENVIRONMENT: "LD_LIBRARY_PATH=/opt/rh/devtoolset-8/root/usr/lib64:/opt/rh/devtoolset-8/root/usr/lib:/opt/rh/devtoolset-8/root/usr/lib64/dyninst:/opt/rh/devtoolset-8/root/usr/lib/dyninst:/usr/local/lib64:/usr/local/lib"
87+
CIBW_TEST_REQUIRES: pytest==4.6.11
88+
CIBW_TEST_COMMAND: "PYTHONPATH={project}/tests pytest {project}/tests/agent_unittests -vx"
89+
90+
- name: Upload Artifacts
91+
uses: actions/[email protected]
92+
with:
93+
name: ${{ github.job }}
94+
path: ./wheelhouse/*.whl
95+
retention-days: 1
96+
97+
build-sdist:
98+
runs-on: ubuntu-latest
99+
steps:
100+
- uses: actions/checkout@v4
101+
with:
102+
persist-credentials: false
103+
fetch-depth: 0
104+
105+
- name: Install Dependencies
106+
run: |
107+
pip install -U pip
108+
pip install -U setuptools
109+
110+
- name: Build Source Package
111+
run: |
112+
python setup.py sdist
113+
114+
- name: Prepare MD5 Hash File
115+
run: |
116+
tarball="$(python setup.py --fullname).tar.gz"
117+
md5_file=${tarball}.md5
118+
openssl md5 -binary dist/${tarball} | xxd -p | tr -d '\n' > dist/${md5_file}
119+
120+
- name: Upload Artifacts
121+
uses: actions/[email protected]
122+
with:
123+
name: ${{ github.job }}-sdist
124+
path: |
125+
./dist/*.tar.gz
126+
./dist/*.tar.gz.md5
127+
retention-days: 1
128+
129+
deploy:
130+
runs-on: ubuntu-latest
131+
132+
needs:
133+
- build-linux-py3
134+
- build-linux-py2
135+
- build-sdist
136+
137+
steps:
138+
- uses: actions/checkout@v4
139+
with:
140+
persist-credentials: false
141+
fetch-depth: 0
34142

35143
- uses: actions/setup-python@v2
36144
with:
@@ -42,32 +150,22 @@ jobs:
42150
pip install -U pip
43151
pip install -U wheel setuptools twine
44152
45-
- name: Build Source Package
46-
run: python setup.py sdist
47-
48-
- name: Build Manylinux Wheels (Python 2)
49-
uses: pypa/[email protected]
50-
env:
51-
CIBW_PLATFORM: linux
52-
CIBW_BUILD: cp27-manylinux_x86_64
53-
CIBW_ARCHS: x86_64
54-
CIBW_ENVIRONMENT: "LD_LIBRARY_PATH=/opt/rh/=vtoolset-8/root/usr/lib64:/opt/rh/devtoolset-8/root/usr/lib:/opt/rh/devtoolset-8/root/usr/lib64/dyninst:/opt/rh/devtoolset-8/root/usr/lib/dyninst:/usr/local/lib64:/usr/local/lib"
153+
- name: Download Artifacts
154+
uses: actions/[email protected]
155+
with:
156+
path: ./artifacts/
55157

56-
- name: Build Manylinux Wheels (Python 3)
57-
uses: pypa/[email protected]
58-
env:
59-
CIBW_PLATFORM: linux
60-
CIBW_BUILD: cp37-manylinux* cp38-manylinux* cp39-manylinux* cp310-manylinux* cp311-manylinux*
61-
CIBW_ARCHS: x86_64 aarch64
62-
CIBW_ENVIRONMENT: "LD_LIBRARY_PATH=/opt/rh/devtoolset-8/root/usr/lib64:/opt/rh/devtoolset-8/root/usr/lib:/opt/rh/devtoolset-8/root/usr/lib64/dyninst:/opt/rh/devtoolset-8/root/usr/lib/dyninst:/usr/local/lib64:/usr/local/lib"
158+
- name: Unpack Artifacts
159+
run: |
160+
mkdir -p dist/
161+
mv artifacts/**/*{.whl,.tar.gz,.tar.gz.md5} dist/
63162
64163
- name: Upload Package to S3
65164
run: |
66165
tarball="$(python setup.py --fullname).tar.gz"
67-
md5_file=$(mktemp)
68-
openssl md5 -binary dist/$tarball | xxd -p | tr -d '\n' > $md5_file
69-
aws s3 cp $md5_file $S3_DST/${tarball}.md5
70-
aws s3 cp dist/$tarball $S3_DST/$tarball
166+
md5_file=${tarball}.md5
167+
aws s3 cp dist/${md5_file} $S3_DST/${md5_file}
168+
aws s3 cp dist/${tarball} $S3_DST/${tarball}
71169
env:
72170
S3_DST: s3://nr-downloads-main/python_agent/release
73171
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
@@ -76,7 +174,7 @@ jobs:
76174

77175
- name: Upload Package to PyPI
78176
run: |
79-
twine upload --non-interactive dist/*.tar.gz wheelhouse/*-manylinux*.whl
177+
twine upload --non-interactive dist/*.tar.gz dist/*.whl
80178
env:
81179
TWINE_USERNAME: __token__
82180
TWINE_PASSWORD: ${{ secrets.PYPI_TOKEN }}

CONTRIBUTING.rst

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -228,14 +228,3 @@ entering the directory of the tests you want to run. Then, run the
228228
following command:
229229

230230
``tox -c tox.ini -e [test environment]``
231-
232-
*******
233-
Slack
234-
*******
235-
236-
We host a public Slack with a dedicated channel for contributors and
237-
maintainers of open source projects hosted by New Relic. If you are
238-
contributing to this project, you're welcome to request access to the
239-
#oss-contributors channel in the newrelicusers.slack.com workspace. To
240-
request access, please use this `link
241-
<https://join.slack.com/t/newrelicusers/shared_invite/zt-1ayj69rzm-~go~Eo1whIQGYnu3qi15ng/>`__.

newrelic/agent.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
from newrelic.api.application import application_instance as __application
1616
from newrelic.api.application import application_settings as __application_settings
1717
from newrelic.api.application import register_application as __register_application
18-
from newrelic.api.log import NewRelicContextFormatter # noqa
18+
from newrelic.api.log import NewRelicContextFormatter as __NewRelicContextFormatter
1919
from newrelic.api.time_trace import (
2020
add_custom_span_attribute as __add_custom_span_attribute,
2121
)
@@ -177,6 +177,7 @@ def __asgi_application(*args, **kwargs):
177177
from newrelic.common.object_wrapper import FunctionWrapper as __FunctionWrapper
178178
from newrelic.common.object_wrapper import InFunctionWrapper as __InFunctionWrapper
179179
from newrelic.common.object_wrapper import ObjectProxy as __ObjectProxy
180+
from newrelic.common.object_wrapper import CallableObjectProxy as __CallableObjectProxy
180181
from newrelic.common.object_wrapper import ObjectWrapper as __ObjectWrapper
181182
from newrelic.common.object_wrapper import OutFunctionWrapper as __OutFunctionWrapper
182183
from newrelic.common.object_wrapper import PostFunctionWrapper as __PostFunctionWrapper
@@ -276,6 +277,7 @@ def __asgi_application(*args, **kwargs):
276277
wrap_background_task = __wrap_api_call(__wrap_background_task, "wrap_background_task")
277278
LambdaHandlerWrapper = __wrap_api_call(__LambdaHandlerWrapper, "LambdaHandlerWrapper")
278279
lambda_handler = __wrap_api_call(__lambda_handler, "lambda_handler")
280+
NewRelicContextFormatter = __wrap_api_call(__NewRelicContextFormatter, "NewRelicContextFormatter")
279281
transaction_name = __wrap_api_call(__transaction_name, "transaction_name")
280282
TransactionNameWrapper = __wrap_api_call(__TransactionNameWrapper, "TransactionNameWrapper")
281283
wrap_transaction_name = __wrap_api_call(__wrap_transaction_name, "wrap_transaction_name")
@@ -316,6 +318,7 @@ def __asgi_application(*args, **kwargs):
316318
wrap_message_transaction = __wrap_api_call(__wrap_message_transaction, "wrap_message_transaction")
317319
callable_name = __wrap_api_call(__callable_name, "callable_name")
318320
ObjectProxy = __wrap_api_call(__ObjectProxy, "ObjectProxy")
321+
CallableObjectProxy = __wrap_api_call(__CallableObjectProxy, "CallableObjectProxy")
319322
wrap_object = __wrap_api_call(__wrap_object, "wrap_object")
320323
wrap_object_attribute = __wrap_api_call(__wrap_object_attribute, "wrap_object_attribute")
321324
resolve_path = __wrap_api_call(__resolve_path, "resolve_path")

newrelic/api/asgi_application.py

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -157,16 +157,9 @@ async def send_inject_browser_agent(self, message):
157157

158158
# if there's a valid body string, attempt to insert the HTML
159159
if verify_body_exists(self.body):
160-
header = self.transaction.browser_timing_header()
161-
if not header:
162-
# If there's no header, abort browser monitoring injection
163-
await self.send_buffered()
164-
return
165-
166-
footer = self.transaction.browser_timing_footer()
167-
browser_agent_data = six.b(header) + six.b(footer)
168-
169-
body = insert_html_snippet(self.body, lambda: browser_agent_data, self.search_maximum)
160+
body = insert_html_snippet(
161+
self.body, lambda: six.b(self.transaction.browser_timing_header()), self.search_maximum
162+
)
170163

171164
# If we have inserted the browser agent
172165
if len(body) != len(self.body):

newrelic/api/solr_trace.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414

1515
import newrelic.api.object_wrapper
1616
import newrelic.api.time_trace
17+
import newrelic.common.object_wrapper
1718
import newrelic.core.solr_node
1819

1920

@@ -111,4 +112,4 @@ def decorator(wrapped):
111112

112113

113114
def wrap_solr_trace(module, object_path, library, command):
114-
newrelic.api.object_wrapper.wrap_object(module, object_path, SolrTraceWrapper, (library, command))
115+
newrelic.common.object_wrapper.wrap_object(module, object_path, SolrTraceWrapper, (library, command))

newrelic/api/transaction.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1957,9 +1957,10 @@ def get_browser_timing_header(nonce=None):
19571957

19581958

19591959
def get_browser_timing_footer(nonce=None):
1960-
transaction = current_transaction()
1961-
if transaction and hasattr(transaction, "browser_timing_footer"):
1962-
return transaction.browser_timing_footer(nonce)
1960+
warnings.warn(
1961+
"The get_browser_timing_footer function is deprecated. Please migrate to only using the get_browser_timing_header API instead.",
1962+
DeprecationWarning,
1963+
)
19631964
return ""
19641965

19651966

0 commit comments

Comments
 (0)