Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sync 6.x with 6.22.1 #2045

Closed
wants to merge 16 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions .github/actions/build-distribution/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
---

name: common build distribution tasks
description: Run the build distribution

runs:
using: "composite"
steps:
- uses: actions/setup-python@v5
with:
python-version: "3.10"

- name: Build lambda layer zip
run: ./dev-utils/make-distribution.sh
shell: bash

- uses: actions/upload-artifact@v4
with:
name: build-distribution
path: ./build/
if-no-files-found: error
27 changes: 27 additions & 0 deletions .github/actions/packages/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
---

name: common package tasks
description: Run the packages

runs:
using: "composite"
steps:
- uses: actions/setup-python@v5
with:
python-version: "3.10"
- name: Override the version if there is no tag release.
run: |
if [[ "${GITHUB_REF}" != refs/tags/* ]]; then
echo "ELASTIC_CI_POST_VERSION=${{ github.run_id }}" >> "${GITHUB_ENV}"
fi
shell: bash
- name: Build packages
run: ./dev-utils/make-packages.sh
shell: bash
- name: Upload Packages
uses: actions/upload-artifact@v4
with:
name: packages
path: |
dist/*.whl
dist/*tar.gz
27 changes: 27 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,30 @@ updates:
github-actions:
patterns:
- "*"

# GitHub composite actions
- package-ecosystem: "github-actions"
directory: "/.github/actions/packages"
reviewers:
- "elastic/observablt-ci"
schedule:
interval: "weekly"
day: "sunday"
time: "22:00"
groups:
github-actions:
patterns:
- "*"

- package-ecosystem: "github-actions"
directory: "/.github/actions/build-distribution"
reviewers:
- "elastic/observablt-ci"
schedule:
interval: "weekly"
day: "sunday"
time: "22:00"
groups:
github-actions:
patterns:
- "*"
23 changes: 0 additions & 23 deletions .github/workflows/build-distribution.yml

This file was deleted.

22 changes: 0 additions & 22 deletions .github/workflows/opentelemetry.yml

This file was deleted.

22 changes: 1 addition & 21 deletions .github/workflows/packages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,24 +21,4 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: "3.10"
- name: Override the version if there is no tag release.
run: |
if [[ "${GITHUB_REF}" != refs/tags/* ]]; then
echo "ELASTIC_CI_POST_VERSION=${{ github.run_id }}" >> "${GITHUB_ENV}"
fi
- name: Install wheel
run: pip install --user wheel
- name: Building universal wheel
run: python setup.py bdist_wheel
- name: Building source distribution
run: python setup.py sdist
- name: Upload Packages
uses: actions/upload-artifact@v4
with:
name: packages
path: |
dist/*.whl
dist/*tar.gz
- uses: ./.github/actions/packages
94 changes: 65 additions & 29 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,18 @@ jobs:
enabled: ${{ startsWith(github.ref, 'refs/tags') }}

packages:
uses: ./.github/workflows/packages.yml
permissions:
attestations: write
id-token: write
contents: write
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: ./.github/actions/packages
- name: generate build provenance
uses: actions/attest-build-provenance@951c0c5f8e375ad4efad33405ab77f7ded2358e4 # v1.1.1
with:
subject-path: "${{ github.workspace }}/dist/*"

publish-pypi:
needs:
Expand Down Expand Up @@ -46,7 +57,18 @@ jobs:
repository-url: https://test.pypi.org/legacy/

build-distribution:
uses: ./.github/workflows/build-distribution.yml
permissions:
attestations: write
id-token: write
contents: write
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: ./.github/actions/build-distribution
- name: generate build provenance
uses: actions/attest-build-provenance@951c0c5f8e375ad4efad33405ab77f7ded2358e4 # v1.1.1
with:
subject-path: "${{ github.workspace }}/build/dist/elastic-apm-python-lambda-layer.zip"

publish-lambda-layers:
needs:
Expand All @@ -63,7 +85,7 @@ jobs:
secrets: |
secret/observability-team/ci/service-account/apm-agent-python access_key_id | AWS_ACCESS_KEY_ID ;
secret/observability-team/ci/service-account/apm-agent-python secret_access_key | AWS_SECRET_ACCESS_KEY
- uses: actions/download-artifact@v3
- uses: actions/download-artifact@v4
with:
name: build-distribution
path: ./build
Expand All @@ -86,6 +108,14 @@ jobs:
needs:
- build-distribution
runs-on: ubuntu-latest
permissions:
attestations: write
id-token: write
contents: write
strategy:
fail-fast: false
matrix:
dockerfile: [ 'Dockerfile', 'Dockerfile.wolfi' ]
env:
DOCKER_IMAGE_NAME: docker.elastic.co/observability/apm-agent-python
steps:
Expand All @@ -97,35 +127,41 @@ jobs:
url: ${{ secrets.VAULT_ADDR }}
roleId: ${{ secrets.VAULT_ROLE_ID }}
secretId: ${{ secrets.VAULT_SECRET_ID }}
- uses: actions/download-artifact@v3

- uses: actions/download-artifact@v4
with:
name: build-distribution
path: ./build
- id: setup-docker
name: Set up docker variables
run: |-
if [ "${{ startsWith(github.ref, 'refs/tags') }}" == "false" ] ; then
# for testing purposes
echo "tag=test" >> "${GITHUB_OUTPUT}"
else
# version without v prefix (e.g. 1.2.3)
echo "tag=${GITHUB_REF_NAME/v/}" >> "${GITHUB_OUTPUT}"
fi
- name: Docker build
run: >-
docker build
-t ${{ env.DOCKER_IMAGE_NAME }}:${{ steps.setup-docker.outputs.tag }}
--build-arg AGENT_DIR=./build/dist/package/python
.
- name: Docker retag
run: >-
docker tag
${{ env.DOCKER_IMAGE_NAME }}:${{ steps.setup-docker.outputs.tag }}
${{ env.DOCKER_IMAGE_NAME }}:latest
- name: Docker push
if: startsWith(github.ref, 'refs/tags')
run: |-
docker push --all-tags ${{ env.DOCKER_IMAGE_NAME }}

- name: Extract metadata (tags, labels)
id: docker-meta
uses: docker/metadata-action@8e5442c4ef9f78752691e2d8f8d19755c6f78e81 # v5.5.1
with:
images: ${{ env.DOCKER_IMAGE_NAME }}
tags: |
type=raw,value=latest,prefix=test-,enable={{is_default_branch}}
type=semver,pattern={{version}}
flavor: |
suffix=${{ contains(matrix.dockerfile, 'wolfi') && '-wolfi' || '' }}

- name: Build and push image
id: push
uses: docker/build-push-action@2cdde995de11925a030ce8070c3d77a52ffcf1c0 # v5.3.0
with:
context: .
push: true
file: ${{ matrix.dockerfile }}
tags: ${{ steps.docker-meta.outputs.tags }}
labels: ${{ steps.docker-meta.outputs.labels }}
build-args: |
AGENT_DIR=./build/dist/package/python

- name: generate build provenance (containers)
uses: actions/attest-build-provenance@951c0c5f8e375ad4efad33405ab77f7ded2358e4 # v1.1.1
with:
subject-name: "${{ env.DOCKER_IMAGE_NAME }}"
subject-digest: ${{ steps.push.outputs.digest }}
push-to-registry: true

github-draft:
permissions:
Expand Down
6 changes: 5 additions & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,11 @@ permissions:

jobs:
build-distribution:
uses: ./.github/workflows/build-distribution.yml
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: ./.github/actions/build-distribution


create-matrix:
runs-on: ubuntu-latest
Expand Down
8 changes: 8 additions & 0 deletions CHANGELOG.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,14 @@ endif::[]
[[release-notes-6.x]]
=== Python Agent version 6.x

[[release-notes-6.22.1]]
==== 6.22.1 - 2024-05-17

[float]
===== Features

* Relax wrapt dependency to only exclude 1.15.0 {pull}2005[#2005]

[[release-notes-6.22.0]]
==== 6.22.0 - 2024-04-03

Expand Down
3 changes: 2 additions & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,8 @@ If you have commit access, the process is as follows:
1. Tag the commit with `git tag -s vX.Y.Z`, for example `git tag -s v1.2.3`.
Copy the changelog for the release to the tag message, removing any leading `#`.
1. Push tag upstream with `git push upstream --tags` (and optionally to your own fork as well)
1. Open a PR from `main` to the major branch, e.g. `1.x` to update it. In order to keep history you may want to
1. Open a PR from `main` to the major branch, e.g. `1.x` to update it. In order to keep history create a
branch from the `main` branch, rebase it on top of the major branch to drop duplicated commits and then
merge with the `rebase` strategy. It is crucial that `main` and the major branch have the same content.
1. After tests pass, Github Actions will automatically build and push the new release to PyPI.
1. Edit and publish the [draft Github release](https://github.com/elastic/apm-agent-python/releases)
Expand Down
3 changes: 3 additions & 0 deletions Dockerfile.wolfi
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
FROM docker.elastic.co/wolfi/chainguard-base@sha256:9f940409f96296ef56140bcc4665c204dd499af4c32c96cc00e792558097c3f1
ARG AGENT_DIR
COPY ${AGENT_DIR} /opt/python
16 changes: 16 additions & 0 deletions dev-utils/make-packages.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#!/bin/bash
#
# Make a Python APM agent distribution
#

echo "::group::Install wheel"
pip install --user wheel
echo "::endgroup::"

echo "::group::Building universal wheel"
python setup.py bdist_wheel
echo "::endgroup::"

echo "::group::Building source distribution"
python setup.py sdist
echo "::endgroup::"
2 changes: 1 addition & 1 deletion elasticapm/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -374,7 +374,7 @@ def get_service_info(self):
def get_process_info(self):
result = {
"pid": os.getpid(),
"ppid": os.getppid() if hasattr(os, "getppid") else None,
"ppid": os.getppid(),
"title": None, # Note: if we implement this, the value needs to be wrapped with keyword_field
}
if self.config.include_process_args:
Expand Down
2 changes: 0 additions & 2 deletions elasticapm/contrib/serverless/azure.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,6 @@
from elasticapm.utils.disttracing import TraceParent
from elasticapm.utils.logging import get_logger

SERVERLESS_HTTP_REQUEST = ("api", "elb")

logger = get_logger("elasticapm.serverless")

_AnnotatedFunctionT = TypeVar("_AnnotatedFunctionT")
Expand Down
2 changes: 1 addition & 1 deletion elasticapm/version.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,5 +28,5 @@
# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

__version__ = (6, 22, 0)
__version__ = (6, 22, 1)
VERSION = ".".join(map(str, __version__))
2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ zip_safe = false
install_requires =
urllib3!=2.0.0,<3.0.0
certifi
wrapt>=1.14.1,<1.15.0 # https://github.com/elastic/apm-agent-python/issues/1894
wrapt>=1.14.1,!=1.15.0 # https://github.com/elastic/apm-agent-python/issues/1894
ecs_logging
test_suite=tests

Expand Down
2 changes: 1 addition & 1 deletion tests/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ services:
- pymssqldata:/var/opt/mssql

mysql:
image: mysql
image: mysql:8.0
command: --default-authentication-plugin=mysql_native_password --log_error_verbosity=3
environment:
- MYSQL_DATABASE=eapm_tests
Expand Down
2 changes: 1 addition & 1 deletion tests/requirements/reqs-asgi-2.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
quart==0.6.13
MarkupSafe<2.1
jinja2==3.0.3
jinja2==3.1.4
async-asgi-testclient
asgiref
-r reqs-base.txt
Loading
Loading