Skip to content

Commit f2c81fe

Browse files
authored
Merge branch 'feature-autogen-instrumentation' into patch-openai-span-id-bug
2 parents 158a1df + 50c7425 commit f2c81fe

File tree

95 files changed

+1254
-400
lines changed

Some content is hidden

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

95 files changed

+1254
-400
lines changed

.github/.trivyignore

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# =======================
2+
# Ignored Vulnerabilities
3+
# =======================
4+
5+
# Accepting risk due to Python 3.7 and 3.8 support.
6+
CVE-2025-50181
7+
8+
# Not relevant, only affects Pyodide
9+
CVE-2025-50182

.github/pull_request_template.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ Include a link to the related GitHub issue, if applicable
99
# Testing
1010
The agent includes a suite of tests which should be used to
1111
verify your changes don't break existing functionality. These tests will run with
12-
Github Actions when a pull request is made. More details on running the tests locally can be found
13-
[here](https://github.com/newrelic/newrelic-python-agent/blob/main/CONTRIBUTING.md#testing-guidelines),
12+
Github Actions when a pull request is made. More details on running the tests locally can be found in our
13+
[testing guidelines](https://github.com/newrelic/newrelic-python-agent/blob/main/CONTRIBUTING.md#testing-guidelines),
1414
For most contributions it is strongly recommended to add additional tests which
1515
exercise your changes.

.github/scripts/install_azure_functions_worker.sh

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,14 +33,15 @@ INVOKE="${BUILD_DIR}/.venv/bin/invoke"
3333
${PIP} install pip-tools build invoke
3434

3535
# Install proto build dependencies
36-
$(cd ${BUILD_DIR} && ${PIPCOMPILE} >${BUILD_DIR}/requirements.txt)
36+
$( cd ${BUILD_DIR}/workers/ && ${PIPCOMPILE} -o ${BUILD_DIR}/requirements.txt )
3737
${PIP} install -r ${BUILD_DIR}/requirements.txt
3838

39-
# Build proto files into pb2 files
40-
cd ${BUILD_DIR}/tests && ${INVOKE} -c test_setup build-protos
39+
# Build proto files into pb2 files (invoke handles fixing include paths for the protos)
40+
cd ${BUILD_DIR}/workers/tests && ${INVOKE} -c test_setup build-protos
4141

4242
# Build and install the package into the original environment (not the build venv)
43-
pip install ${BUILD_DIR}
43+
# Do NOT use ${PIP} from the venv
44+
pip install ${BUILD_DIR}/workers/
4445

4546
# Clean up and return to the original directory
4647
rm -rf ${BUILD_DIR}

.github/workflows/addlicense.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,9 @@ on:
2222
- "**"
2323
pull_request:
2424

25+
permissions:
26+
contents: read
27+
2528
concurrency:
2629
group: ${{ github.ref || github.run_id }}-${{ github.workflow }}
2730
cancel-in-progress: true

.github/workflows/build-ci-image.yml

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@ name: Build CI Image
1717
on:
1818
workflow_dispatch: # Allow manual trigger
1919

20+
permissions:
21+
contents: read
22+
2023
concurrency:
2124
group: ${{ github.ref || github.run_id }}
2225
cancel-in-progress: true
@@ -25,6 +28,10 @@ jobs:
2528
build:
2629
runs-on: ubuntu-24.04
2730

31+
permissions:
32+
contents: read
33+
packages: write
34+
2835
steps:
2936
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # 4.2.2
3037
with:
@@ -33,11 +40,11 @@ jobs:
3340

3441
- name: Set up Docker Buildx
3542
id: buildx
36-
uses: docker/setup-buildx-action@18ce135bb5112fa8ce4ed6c17ab05699d7f3a5e0 # 3.11.0
43+
uses: docker/setup-buildx-action@e468171a9de216ec08956ac3ada2f0791b6bd435 # 3.11.1
3744

3845
- name: Generate Docker Metadata (Tags and Labels)
3946
id: meta
40-
uses: docker/metadata-action@902fa8ec7d6ecbf8d84d538b9b233a880e428804 # 5.7.0
47+
uses: docker/metadata-action@c1e51972afc2121e065aed6d45c65596fe445f3f # 5.8.0
4148
with:
4249
images: ghcr.io/${{ github.repository }}-ci
4350
flavor: |
@@ -52,7 +59,7 @@ jobs:
5259
5360
- name: Login to GitHub Container Registry
5461
if: github.event_name != 'pull_request'
55-
uses: docker/login-action@74a5d142397b4f367a81961eba4e8cd7edddf772 # 3.4.0
62+
uses: docker/login-action@184bdaa0721073962dff0199f1fb9940f07167d1 # 3.5.0
5663
with:
5764
registry: ghcr.io
5865
username: ${{ github.repository_owner }}

.github/workflows/deploy-python.yml renamed to .github/workflows/deploy.yml

Lines changed: 29 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,9 @@ on:
1919
types:
2020
- published
2121

22+
permissions:
23+
contents: read
24+
2225
jobs:
2326
build-linux-py3-legacy:
2427
runs-on: ubuntu-24.04
@@ -110,18 +113,22 @@ jobs:
110113
persist-credentials: false
111114
fetch-depth: 0
112115

116+
- uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # 5.6.0
117+
with:
118+
python-version: "3.12"
119+
113120
- name: Install Dependencies
114121
run: |
115122
pip install -U pip
116-
pip install -U setuptools packaging
123+
pip install -U build
117124
118125
- name: Build Source Package
119126
run: |
120-
python setup.py sdist
127+
python -m build --sdist
121128
122129
- name: Prepare MD5 Hash File
123130
run: |
124-
tarball="$(python setup.py --fullname).tar.gz"
131+
tarball="$(basename ./dist/*.tar.gz)"
125132
md5_file="${tarball}.md5"
126133
openssl md5 -binary "dist/${tarball}" | xxd -p | tr -d '\n' > "dist/${md5_file}"
127134
@@ -135,58 +142,46 @@ jobs:
135142
if-no-files-found: error
136143
retention-days: 1
137144

138-
deploy:
145+
publish:
139146
runs-on: ubuntu-24.04
147+
environment: pypi
148+
permissions:
149+
contents: read
150+
id-token: write # IMPORTANT: this permission is mandatory for trusted publishing
151+
attestations: write
140152

141153
needs:
142154
- build-linux-py3-legacy
143155
- build-linux-py3
144156
- build-sdist
145157

146158
steps:
147-
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # 4.2.2
148-
with:
149-
persist-credentials: false
150-
fetch-depth: 0
151-
152-
- uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # 5.6.0
153-
with:
154-
python-version: "3.x"
155-
architecture: x64
156-
157-
- name: Install Dependencies
158-
run: |
159-
pip install -U pip
160-
pip install -U wheel setuptools packaging twine
161-
162-
- name: Download Artifacts
163-
uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # 4.3.0@95815c38cf2ff2164869cbab79da8d1f422bc89e # 4.3.0
159+
- uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # 4.3.0
164160
with:
165-
path: ./artifacts/
166-
167-
- name: Unpack Artifacts
168-
run: |
169-
mkdir -p dist/
170-
mv artifacts/**/*{.whl,.tar.gz,.tar.gz.md5} dist/
161+
path: ./dist/
162+
merge-multiple: true
171163

172164
- name: Upload Package to S3
173165
run: |
174-
tarball="$(python setup.py --fullname).tar.gz"
166+
tarball="$(basename ./dist/*.tar.gz)"
175167
md5_file="${tarball}.md5"
176168
aws s3 cp "dist/${md5_file}" "${S3_DST}/${md5_file}"
177169
aws s3 cp "dist/${tarball}" "${S3_DST}/${tarball}"
170+
rm "dist/${md5_file}"
178171
env:
179172
S3_DST: s3://nr-downloads-main/python_agent/release
180173
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
181174
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
182175
AWS_DEFAULT_REGION: us-west-2
183176

184-
- name: Upload Package to PyPI
185-
run: |
186-
twine upload --non-interactive dist/*.tar.gz dist/*.whl
187-
env:
188-
TWINE_USERNAME: __token__
189-
TWINE_PASSWORD: ${{ secrets.PYPI_TOKEN }}
177+
- name: Upload Package
178+
uses: pypa/gh-action-pypi-publish@76f52bc884231f62b9a034ebfe128415bbaabdfc # 1.12.4
179+
180+
- name: Attest
181+
uses: actions/attest-build-provenance@e8998f949152b193b063cb0ec769d69d929409be # 2.4.0
182+
id: attest
183+
with:
184+
subject-path: ./dist/*
190185

191186
- name: Wait for release to be available
192187
id: wait

.github/workflows/mega-linter.yml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,9 @@ on:
2222
# push: # Comment this line to trigger action only on pull-requests (not recommended if you don't pay for GH Actions)
2323
pull_request:
2424

25+
permissions:
26+
contents: read
27+
2528
env: # Comment env block if you don't want to apply fixes
2629
# Apply linter fixes configuration
2730
APPLY_FIXES: all # When active, APPLY_FIXES must also be defined as environment variable (in github/workflows/mega-linter.yml or other CI tool)
@@ -42,7 +45,6 @@ jobs:
4245
contents: write
4346
issues: write
4447
pull-requests: write
45-
statuses: write
4648
steps:
4749
# Git Checkout
4850
- name: Checkout Code
@@ -62,7 +64,6 @@ jobs:
6264
VALIDATE_ALL_CODEBASE: "true"
6365
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
6466
# ADD YOUR CUSTOM ENV VARIABLES HERE OR DEFINE THEM IN A FILE .mega-linter.yml AT THE ROOT OF YOUR REPOSITORY
65-
GITHUB_STATUS_REPORTER: "true"
6667
GITHUB_COMMENT_REPORTER: "true"
6768
PYTHON_RUFF_ARGUMENTS: --config pyproject.toml --config 'output-format="github"'
6869
PYTHON_RUFF_FORMAT_ARGUMENTS: --config pyproject.toml --config 'output-format="github"'

.github/workflows/tests.yml

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ jobs:
4444
- firestore
4545
- grpc
4646
- kafka
47+
- oracledb
4748
- memcached
4849
- mongodb3
4950
- mongodb8
@@ -800,6 +801,73 @@ jobs:
800801
if-no-files-found: error
801802
retention-days: 1
802803

804+
oracledb:
805+
env:
806+
TOTAL_GROUPS: 1
807+
808+
strategy:
809+
fail-fast: false
810+
matrix:
811+
group-number: [1]
812+
813+
runs-on: ubuntu-24.04
814+
container:
815+
image: ghcr.io/newrelic/newrelic-python-agent-ci:latest
816+
options: >-
817+
--add-host=host.docker.internal:host-gateway
818+
timeout-minutes: 30
819+
services:
820+
oracledb:
821+
image: container-registry.oracle.com/database/free:latest-lite
822+
ports:
823+
- 8080:1521
824+
- 8081:1521
825+
env:
826+
ORACLE_CHARACTERSET: utf8
827+
ORACLE_PWD: oracle
828+
# Set health checks to wait until container has started
829+
options: >-
830+
--health-cmd "timeout 5 bash -c 'cat < /dev/null > /dev/udp/127.0.0.1/11211'"
831+
--health-interval 10s
832+
--health-timeout 5s
833+
--health-retries 5
834+
835+
steps:
836+
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # 4.2.2
837+
838+
- name: Fetch git tags
839+
run: |
840+
git config --global --add safe.directory "$GITHUB_WORKSPACE"
841+
git fetch --tags origin
842+
843+
- name: Configure pip cache
844+
run: |
845+
mkdir -p /github/home/.cache/pip
846+
chown -R "$(whoami)" /github/home/.cache/pip
847+
848+
- name: Get Environments
849+
id: get-envs
850+
run: |
851+
echo "envs=$(tox -l | grep '^${{ github.job }}\-' | ./.github/workflows/get-envs.py)" >> "$GITHUB_OUTPUT"
852+
env:
853+
GROUP_NUMBER: ${{ matrix.group-number }}
854+
855+
- name: Test
856+
run: |
857+
tox -vv -e ${{ steps.get-envs.outputs.envs }} -p auto
858+
env:
859+
TOX_PARALLEL_NO_SPINNER: 1
860+
PY_COLORS: 0
861+
862+
- name: Upload Coverage Artifacts
863+
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # 4.6.2
864+
with:
865+
name: coverage-${{ github.job }}-${{ strategy.job-index }}
866+
path: ./**/.coverage.*
867+
include-hidden-files: true
868+
if-no-files-found: error
869+
retention-days: 1
870+
803871
memcached:
804872
env:
805873
TOTAL_GROUPS: 2

.github/workflows/trivy.yml

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,9 @@ concurrency:
2121
group: ${{ github.ref || github.run_id }}-${{ github.workflow }}
2222
cancel-in-progress: true
2323

24+
permissions:
25+
contents: read
26+
2427
jobs:
2528
# Upload Trivy data
2629
trivy:
@@ -36,26 +39,28 @@ jobs:
3639

3740
- name: Run Trivy vulnerability scanner in repo mode
3841
if: ${{ github.event_name == 'pull_request' }}
39-
uses: aquasecurity/trivy-action@76071ef0d7ec797419534a183b498b4d6366cf37 # v0.31.0
42+
uses: aquasecurity/trivy-action@dc5a429b52fcf669ce959baa2c2dd26090d2a6c4 # v0.32.0
4043
with:
4144
scan-type: "fs"
4245
ignore-unfixed: true
4346
format: table
4447
exit-code: 1
4548
severity: "CRITICAL,HIGH,MEDIUM,LOW"
49+
trivyignores: ".github/.trivyignore"
4650

4751
- name: Run Trivy vulnerability scanner in repo mode
4852
if: ${{ github.event_name == 'schedule' }}
49-
uses: aquasecurity/trivy-action@76071ef0d7ec797419534a183b498b4d6366cf37 # v0.31.0
53+
uses: aquasecurity/trivy-action@dc5a429b52fcf669ce959baa2c2dd26090d2a6c4 # v0.32.0
5054
with:
5155
scan-type: "fs"
5256
ignore-unfixed: true
5357
format: "sarif"
5458
output: "trivy-results.sarif"
5559
severity: "CRITICAL,HIGH,MEDIUM,LOW"
60+
trivyignores: ".github/.trivyignore"
5661

5762
- name: Upload Trivy scan results to GitHub Security tab
5863
if: ${{ github.event_name == 'schedule' }}
59-
uses: github/codeql-action/upload-sarif@ce28f5bb42b7a9f2c824e633a3f6ee835bab6858 # 3.29.0
64+
uses: github/codeql-action/upload-sarif@51f77329afa6477de8c49fc9c7046c15b9a4e79d # 3.29.5
6065
with:
6166
sarif_file: "trivy-results.sarif"

.pre-commit-config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ default_install_hook_types:
2929
repos:
3030
- repo: https://github.com/astral-sh/ruff-pre-commit
3131
# Ruff version.
32-
rev: v0.11.5
32+
rev: v0.12.4
3333
hooks:
3434
# Run the linter.
3535
- id: ruff

0 commit comments

Comments
 (0)