Skip to content

Commit

Permalink
Merge main into develop-logging-attributes (#1034)
Browse files Browse the repository at this point in the history
* Remove RPM config workflow. (#1007)

* Nonced CSP Support (#998)

* Add nonce to CSP in browser agent

* Adjust nonce position

* Add testing for browser timing nonces

* Drop py27 from memcache testing. (#1018)

* Temporarily pin hypercorn version in tests (#1021)

* Temporarily pin hypercorn to <0.16

* Temporarily pin hypercorn to <0.16

* Add comment to tox.ini

---------

Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>

* Remove case sensitive check in ASGIBrowserMiddleware check. (#1017)

* Remove case sensitive check in should_insert_html.

* [Mega-Linter] Apply linters fixes

* Remove header decoding.

---------

Co-authored-by: umaannamalai <umaannamalai@users.noreply.github.com>

* Parallel Wheel Builds (#1024)

* Fix import issue in tests

* Parallelize wheel building and add muslinux support

---------

Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>

* Deprecate get_browser_timing_footer API (#999)

* Add nonce to CSP in browser agent

* Adjust nonce position

* Add testing for browser timing nonces

* Deprecated browser timing footer APIs.

* Full rip out of browser timing footer

* Remove cross agent tests for RUM footer (per repo)

* Update cat_map tests

* Adjust browser header generation timing accuracy

* Fix browser tests

* Linting

* Apply suggestions from code review

---------

Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>

* Deprecate ObjectWrapper API (#996)

* Update wrapt to 1.16.0

* Import duplicate functions directly from wrapt

* Update object wrappers for wrapt 1.16.0

* Add warning to wrapt duplicate code

* Linting

* Use super rather than hard coded Object proxy

* Formatting

* Add test file for wrapper attributes

* Unify ObjectWrapper with FunctionWrapper

* Remove ObjectWrapper from httplib

* Remove ObjectWrapper from tastypie

* Replace ObjectWrapper use in console

* Remove ObjectWrapper from celery

* Remove extra import

* Update agent APIs

* Deprecate ObjectWrapper

* Fix object wrapper imports

* More import issues

* Fix taskwrapper in celery

* Pin last supported flask restx version for 3.7

* Undo tox changes

* Change all api.object_wrapper references to use new locations

* Fixup: callable_name import

* Fixup: callable_name import

---------

Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
Co-authored-by: Hannah Stepanek <hstepanek@newrelic.com>

* Add checkout actions to deploy workflow (#1027)

* Remove Slack section in CONTRIBUTING.rst. (#1029)

* Remove duplicated function

* Pin starlette before 0.35.1

* Change starlette pin

---------

Co-authored-by: Uma Annamalai <uannamalai@newrelic.com>
Co-authored-by: Lalleh Rafeei <84813886+lrafeei@users.noreply.github.com>
Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
Co-authored-by: umaannamalai <umaannamalai@users.noreply.github.com>
Co-authored-by: Hannah Stepanek <hstepanek@newrelic.com>
  • Loading branch information
6 people committed Jan 11, 2024
1 parent 92cca1e commit d9c6462
Show file tree
Hide file tree
Showing 45 changed files with 1,495 additions and 1,848 deletions.
148 changes: 123 additions & 25 deletions .github/workflows/deploy-python.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,17 +20,125 @@ on:
- published

jobs:
deploy-linux:
build-linux-py3:
runs-on: ubuntu-latest
strategy:
fail-fast: true
matrix:
wheel:
- cp37-manylinux
- cp37-musllinux
- cp38-manylinux
- cp38-musllinux
- cp39-manylinux
- cp39-musllinux
- cp310-manylinux
- cp310-musllinux
- cp311-manylinux
- cp311-musllinux
- cp312-manylinux
- cp312-musllinux

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
persist-credentials: false
fetch-depth: 0

- name: Setup QEMU
uses: docker/setup-qemu-action@v1
uses: docker/setup-qemu-action@v3

- name: Build Wheels
uses: pypa/cibuildwheel@v2.16.2
env:
CIBW_PLATFORM: linux
CIBW_BUILD: "${{ matrix.wheel }}*"
CIBW_ARCHS_LINUX: x86_64 aarch64
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"
CIBW_TEST_REQUIRES: pytest
CIBW_TEST_COMMAND: "PYTHONPATH={project}/tests pytest {project}/tests/agent_unittests -vx"

- name: Upload Artifacts
uses: actions/upload-artifact@v4.0.0
with:
name: ${{ github.job }}-${{ matrix.wheel }}
path: ./wheelhouse/*.whl
retention-days: 1

build-linux-py2:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
with:
persist-credentials: false
fetch-depth: 0

- name: Setup QEMU
uses: docker/setup-qemu-action@v3

- name: Build Wheels
uses: pypa/cibuildwheel@v1.12.0
env:
CIBW_PLATFORM: linux
CIBW_BUILD: cp27-manylinux_x86_64
CIBW_ARCHS_LINUX: x86_64
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"
CIBW_TEST_REQUIRES: pytest==4.6.11
CIBW_TEST_COMMAND: "PYTHONPATH={project}/tests pytest {project}/tests/agent_unittests -vx"

- name: Upload Artifacts
uses: actions/upload-artifact@v4.0.0
with:
name: ${{ github.job }}
path: ./wheelhouse/*.whl
retention-days: 1

build-sdist:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
persist-credentials: false
fetch-depth: 0

- name: Install Dependencies
run: |
pip install -U pip
pip install -U setuptools
- name: Build Source Package
run: |
python setup.py sdist
- name: Prepare MD5 Hash File
run: |
tarball="$(python setup.py --fullname).tar.gz"
md5_file=${tarball}.md5
openssl md5 -binary dist/${tarball} | xxd -p | tr -d '\n' > dist/${md5_file}
- name: Upload Artifacts
uses: actions/upload-artifact@v4.0.0
with:
name: ${{ github.job }}-sdist
path: |
./dist/*.tar.gz
./dist/*.tar.gz.md5
retention-days: 1

deploy:
runs-on: ubuntu-latest

needs:
- build-linux-py3
- build-linux-py2
- build-sdist

steps:
- uses: actions/checkout@v4
with:
persist-credentials: false
fetch-depth: 0

- uses: actions/setup-python@v2
with:
Expand All @@ -42,32 +150,22 @@ jobs:
pip install -U pip
pip install -U wheel setuptools twine
- name: Build Source Package
run: python setup.py sdist

- name: Build Manylinux Wheels (Python 2)
uses: pypa/cibuildwheel@v1.12.0
env:
CIBW_PLATFORM: linux
CIBW_BUILD: cp27-manylinux_x86_64
CIBW_ARCHS: x86_64
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"
- name: Download Artifacts
uses: actions/download-artifact@v4.1.0
with:
path: ./artifacts/

- name: Build Manylinux Wheels (Python 3)
uses: pypa/cibuildwheel@v2.11.1
env:
CIBW_PLATFORM: linux
CIBW_BUILD: cp37-manylinux* cp38-manylinux* cp39-manylinux* cp310-manylinux* cp311-manylinux*
CIBW_ARCHS: x86_64 aarch64
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"
- name: Unpack Artifacts
run: |
mkdir -p dist/
mv artifacts/**/*{.whl,.tar.gz,.tar.gz.md5} dist/
- name: Upload Package to S3
run: |
tarball="$(python setup.py --fullname).tar.gz"
md5_file=$(mktemp)
openssl md5 -binary dist/$tarball | xxd -p | tr -d '\n' > $md5_file
aws s3 cp $md5_file $S3_DST/${tarball}.md5
aws s3 cp dist/$tarball $S3_DST/$tarball
md5_file=${tarball}.md5
aws s3 cp dist/${md5_file} $S3_DST/${md5_file}
aws s3 cp dist/${tarball} $S3_DST/${tarball}
env:
S3_DST: s3://nr-downloads-main/python_agent/release
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
Expand All @@ -76,7 +174,7 @@ jobs:

- name: Upload Package to PyPI
run: |
twine upload --non-interactive dist/*.tar.gz wheelhouse/*-manylinux*.whl
twine upload --non-interactive dist/*.tar.gz dist/*.whl
env:
TWINE_USERNAME: __token__
TWINE_PASSWORD: ${{ secrets.PYPI_TOKEN }}
11 changes: 0 additions & 11 deletions CONTRIBUTING.rst
Original file line number Diff line number Diff line change
Expand Up @@ -228,14 +228,3 @@ entering the directory of the tests you want to run. Then, run the
following command:

``tox -c tox.ini -e [test environment]``

*******
Slack
*******

We host a public Slack with a dedicated channel for contributors and
maintainers of open source projects hosted by New Relic. If you are
contributing to this project, you're welcome to request access to the
#oss-contributors channel in the newrelicusers.slack.com workspace. To
request access, please use this `link
<https://join.slack.com/t/newrelicusers/shared_invite/zt-1ayj69rzm-~go~Eo1whIQGYnu3qi15ng/>`__.
5 changes: 4 additions & 1 deletion newrelic/agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
from newrelic.api.application import application_instance as __application
from newrelic.api.application import application_settings as __application_settings
from newrelic.api.application import register_application as __register_application
from newrelic.api.log import NewRelicContextFormatter # noqa
from newrelic.api.log import NewRelicContextFormatter as __NewRelicContextFormatter
from newrelic.api.time_trace import (
add_custom_span_attribute as __add_custom_span_attribute,
)
Expand Down Expand Up @@ -177,6 +177,7 @@ def __asgi_application(*args, **kwargs):
from newrelic.common.object_wrapper import FunctionWrapper as __FunctionWrapper
from newrelic.common.object_wrapper import InFunctionWrapper as __InFunctionWrapper
from newrelic.common.object_wrapper import ObjectProxy as __ObjectProxy
from newrelic.common.object_wrapper import CallableObjectProxy as __CallableObjectProxy
from newrelic.common.object_wrapper import ObjectWrapper as __ObjectWrapper
from newrelic.common.object_wrapper import OutFunctionWrapper as __OutFunctionWrapper
from newrelic.common.object_wrapper import PostFunctionWrapper as __PostFunctionWrapper
Expand Down Expand Up @@ -276,6 +277,7 @@ def __asgi_application(*args, **kwargs):
wrap_background_task = __wrap_api_call(__wrap_background_task, "wrap_background_task")
LambdaHandlerWrapper = __wrap_api_call(__LambdaHandlerWrapper, "LambdaHandlerWrapper")
lambda_handler = __wrap_api_call(__lambda_handler, "lambda_handler")
NewRelicContextFormatter = __wrap_api_call(__NewRelicContextFormatter, "NewRelicContextFormatter")
transaction_name = __wrap_api_call(__transaction_name, "transaction_name")
TransactionNameWrapper = __wrap_api_call(__TransactionNameWrapper, "TransactionNameWrapper")
wrap_transaction_name = __wrap_api_call(__wrap_transaction_name, "wrap_transaction_name")
Expand Down Expand Up @@ -316,6 +318,7 @@ def __asgi_application(*args, **kwargs):
wrap_message_transaction = __wrap_api_call(__wrap_message_transaction, "wrap_message_transaction")
callable_name = __wrap_api_call(__callable_name, "callable_name")
ObjectProxy = __wrap_api_call(__ObjectProxy, "ObjectProxy")
CallableObjectProxy = __wrap_api_call(__CallableObjectProxy, "CallableObjectProxy")
wrap_object = __wrap_api_call(__wrap_object, "wrap_object")
wrap_object_attribute = __wrap_api_call(__wrap_object_attribute, "wrap_object_attribute")
resolve_path = __wrap_api_call(__resolve_path, "resolve_path")
Expand Down
13 changes: 3 additions & 10 deletions newrelic/api/asgi_application.py
Original file line number Diff line number Diff line change
Expand Up @@ -157,16 +157,9 @@ async def send_inject_browser_agent(self, message):

# if there's a valid body string, attempt to insert the HTML
if verify_body_exists(self.body):
header = self.transaction.browser_timing_header()
if not header:
# If there's no header, abort browser monitoring injection
await self.send_buffered()
return

footer = self.transaction.browser_timing_footer()
browser_agent_data = six.b(header) + six.b(footer)

body = insert_html_snippet(self.body, lambda: browser_agent_data, self.search_maximum)
body = insert_html_snippet(
self.body, lambda: six.b(self.transaction.browser_timing_header()), self.search_maximum
)

# If we have inserted the browser agent
if len(body) != len(self.body):
Expand Down
3 changes: 2 additions & 1 deletion newrelic/api/solr_trace.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

import newrelic.api.object_wrapper
import newrelic.api.time_trace
import newrelic.common.object_wrapper
import newrelic.core.solr_node


Expand Down Expand Up @@ -111,4 +112,4 @@ def decorator(wrapped):


def wrap_solr_trace(module, object_path, library, command):
newrelic.api.object_wrapper.wrap_object(module, object_path, SolrTraceWrapper, (library, command))
newrelic.common.object_wrapper.wrap_object(module, object_path, SolrTraceWrapper, (library, command))
7 changes: 4 additions & 3 deletions newrelic/api/transaction.py
Original file line number Diff line number Diff line change
Expand Up @@ -1957,9 +1957,10 @@ def get_browser_timing_header(nonce=None):


def get_browser_timing_footer(nonce=None):
transaction = current_transaction()
if transaction and hasattr(transaction, "browser_timing_footer"):
return transaction.browser_timing_footer(nonce)
warnings.warn(
"The get_browser_timing_footer function is deprecated. Please migrate to only using the get_browser_timing_header API instead.",
DeprecationWarning,
)
return ""


Expand Down
Loading

0 comments on commit d9c6462

Please sign in to comment.