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.3 #2063

Merged
merged 12 commits into from
Jun 10, 2024
Merged
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
2 changes: 2 additions & 0 deletions .ci/.matrix_framework.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ FRAMEWORK:
- aiopg-newest
- asyncpg-newest
- tornado-newest
# this has a dependency on requests, run it to catch update issues before merging. Drop after baseline > 0.21.0
- starlette-0.14
- starlette-newest
- pymemcache-newest
- graphene-2
Expand Down
36 changes: 0 additions & 36 deletions .ci/snapshoty.yml

This file was deleted.

10 changes: 4 additions & 6 deletions .ci/updatecli/updatecli.d/update-gherkin-specs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,22 +5,20 @@ scms:
default:
kind: github
spec:
user: '{{ requiredEnv "GIT_USER" }}'
email: '{{ requiredEnv "GIT_EMAIL" }}'
user: '{{ requiredEnv "GITHUB_ACTOR" }}'
owner: "{{ .github.owner }}"
repository: "{{ .github.repository }}"
token: '{{ requiredEnv "GITHUB_TOKEN" }}'
username: '{{ requiredEnv "GIT_USER" }}'
username: '{{ requiredEnv "GITHUB_ACTOR" }}'
branch: "{{ .github.branch }}"
apm:
kind: github
spec:
user: '{{ requiredEnv "GIT_USER" }}'
email: '{{ requiredEnv "GIT_EMAIL" }}'
user: '{{ requiredEnv "GITHUB_ACTOR" }}'
owner: "{{ .github.owner }}"
repository: "{{ .github.apm_repository }}"
token: '{{ requiredEnv "GITHUB_TOKEN" }}'
username: '{{ requiredEnv "GIT_USER" }}'
username: '{{ requiredEnv "GITHUB_ACTOR" }}'
branch: "{{ .github.branch }}"

sources:
Expand Down
10 changes: 4 additions & 6 deletions .ci/updatecli/updatecli.d/update-json-specs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,22 +5,20 @@ scms:
default:
kind: github
spec:
user: '{{ requiredEnv "GIT_USER" }}'
email: '{{ requiredEnv "GIT_EMAIL" }}'
user: '{{ requiredEnv "GITHUB_ACTOR" }}'
owner: "{{ .github.owner }}"
repository: "{{ .github.repository }}"
token: '{{ requiredEnv "GITHUB_TOKEN" }}'
username: '{{ requiredEnv "GIT_USER" }}'
username: '{{ requiredEnv "GITHUB_ACTOR" }}'
branch: "{{ .github.branch }}"
apm:
kind: github
spec:
user: '{{ requiredEnv "GIT_USER" }}'
email: '{{ requiredEnv "GIT_EMAIL" }}'
user: '{{ requiredEnv "GITHUB_ACTOR" }}'
owner: "{{ .github.owner }}"
repository: "{{ .github.apm_repository }}"
token: '{{ requiredEnv "GITHUB_TOKEN" }}'
username: '{{ requiredEnv "GIT_USER" }}'
username: '{{ requiredEnv "GITHUB_ACTOR" }}'
branch: "{{ .github.branch }}"

sources:
Expand Down
10 changes: 4 additions & 6 deletions .ci/updatecli/updatecli.d/update-specs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,23 +5,21 @@ scms:
default:
kind: github
spec:
user: '{{ requiredEnv "GIT_USER" }}'
email: '{{ requiredEnv "GIT_EMAIL" }}'
user: '{{ requiredEnv "GITHUB_ACTOR" }}'
owner: "{{ .github.owner }}"
repository: "{{ .github.repository }}"
token: '{{ requiredEnv "GITHUB_TOKEN" }}'
username: '{{ requiredEnv "GIT_USER" }}'
username: '{{ requiredEnv "GITHUB_ACTOR" }}'
branch: "{{ .github.branch }}"

apm-data:
kind: github
spec:
user: '{{ requiredEnv "GIT_USER" }}'
email: '{{ requiredEnv "GIT_EMAIL" }}'
user: '{{ requiredEnv "GITHUB_ACTOR" }}'
owner: "{{ .github.owner }}"
repository: "{{ .github.apm_data_repository }}"
token: '{{ requiredEnv "GITHUB_TOKEN" }}'
username: '{{ requiredEnv "GIT_USER" }}'
username: '{{ requiredEnv "GITHUB_ACTOR" }}'
branch: "{{ .github.branch }}"

sources:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,4 +52,4 @@ The tag release follows the naming convention: `v.<major>.<minor>.<patch>`, wher

### OpenTelemetry

There is a GitHub workflow in charge to populate what the workflow run in terms of jobs and steps. Those details can be seen in [here](https://ela.st/oblt-ci-cd-stats) (**NOTE**: only available for Elasticians).
Every workflow and its logs are exported to OpenTelemetry traces/logs/metrics. Those details can be seen [here](https://ela.st/oblt-ci-cd-stats) (**NOTE**: only available for Elasticians).
30 changes: 7 additions & 23 deletions .github/workflows/microbenchmark.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,32 +16,16 @@ permissions:
jobs:
microbenchmark:
runs-on: ubuntu-latest
# wait up to 1 hour
timeout-minutes: 60
timeout-minutes: 5
steps:
- id: buildkite
name: Run buildkite pipeline
uses: elastic/apm-pipeline-library/.github/actions/buildkite@current
- name: Run microbenchmark
uses: elastic/oblt-actions/buildkite/run@v1.5.0
with:
vaultUrl: ${{ secrets.VAULT_ADDR }}
vaultRoleId: ${{ secrets.VAULT_ROLE_ID }}
vaultSecretId: ${{ secrets.VAULT_SECRET_ID }}
pipeline: apm-agent-microbenchmark
waitFor: true
printBuildLogs: true
buildEnvVars: |
pipeline: "apm-agent-microbenchmark"
token: ${{ secrets.BUILDKITE_TOKEN }}
wait-for: false
env-vars: |
script=.ci/bench.sh
repo=apm-agent-python
sha=${{ github.sha }}
BRANCH_NAME=${{ github.ref_name }}

- if: ${{ failure() }}
uses: elastic/apm-pipeline-library/.github/actions/slack-message@current
with:
url: ${{ secrets.VAULT_ADDR }}
roleId: ${{ secrets.VAULT_ROLE_ID }}
secretId: ${{ secrets.VAULT_SECRET_ID }}
channel: "#apm-agent-python"
message: |
:ghost: [${{ github.repository }}] microbenchmark *${{ github.ref_name }}* failed to run in Buildkite.
Build: (<${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}|here>)
28 changes: 13 additions & 15 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ jobs:
- uses: actions/checkout@v4
- uses: ./.github/actions/packages
- name: generate build provenance
uses: actions/attest-build-provenance@951c0c5f8e375ad4efad33405ab77f7ded2358e4 # v1.1.1
uses: actions/attest-build-provenance@49df96e17e918a15956db358890b08e61c704919 # v1.2.0
with:
subject-path: "${{ github.workspace }}/dist/*"

Expand Down Expand Up @@ -66,7 +66,7 @@ jobs:
- uses: actions/checkout@v4
- uses: ./.github/actions/build-distribution
- name: generate build provenance
uses: actions/attest-build-provenance@951c0c5f8e375ad4efad33405ab77f7ded2358e4 # v1.1.1
uses: actions/attest-build-provenance@49df96e17e918a15956db358890b08e61c704919 # v1.2.0
with:
subject-path: "${{ github.workspace }}/build/dist/elastic-apm-python-lambda-layer.zip"

Expand Down Expand Up @@ -120,13 +120,13 @@ jobs:
DOCKER_IMAGE_NAME: docker.elastic.co/observability/apm-agent-python
steps:
- uses: actions/checkout@v4
- uses: elastic/apm-pipeline-library/.github/actions/docker-login@current

- name: Log in to the Elastic Container registry
uses: docker/login-action@0d4c9c5ea7693da7b068278f7b52bda2a190a446 # v3.2.0
with:
registry: docker.elastic.co
secret: secret/observability-team/ci/docker-registry/prod
url: ${{ secrets.VAULT_ADDR }}
roleId: ${{ secrets.VAULT_ROLE_ID }}
secretId: ${{ secrets.VAULT_SECRET_ID }}
registry: ${{ secrets.ELASTIC_DOCKER_REGISTRY }}
username: ${{ secrets.ELASTIC_DOCKER_USERNAME }}
password: ${{ secrets.ELASTIC_DOCKER_PASSWORD }}

- uses: actions/download-artifact@v3
with:
Expand Down Expand Up @@ -157,7 +157,7 @@ jobs:
AGENT_DIR=./build/dist/package/python

- name: generate build provenance (containers)
uses: actions/attest-build-provenance@951c0c5f8e375ad4efad33405ab77f7ded2358e4 # v1.1.1
uses: actions/attest-build-provenance@49df96e17e918a15956db358890b08e61c704919 # v1.2.0
with:
subject-name: "${{ env.DOCKER_IMAGE_NAME }}"
subject-digest: ${{ steps.push.outputs.digest }}
Expand Down Expand Up @@ -198,11 +198,9 @@ jobs:
uses: elastic/apm-pipeline-library/.github/actions/check-dependent-jobs@current
with:
needs: ${{ toJSON(needs) }}
- uses: elastic/apm-pipeline-library/.github/actions/notify-build-status@current
if: startsWith(github.ref, 'refs/tags')
- if: startsWith(github.ref, 'refs/tags')
uses: elastic/oblt-actions/slack/notify-result@v1.7.0
with:
bot-token: ${{ secrets.SLACK_BOT_TOKEN }}
channel-id: "#apm-agent-python"
status: ${{ steps.check.outputs.status }}
vaultUrl: ${{ secrets.VAULT_ADDR }}
vaultRoleId: ${{ secrets.VAULT_ROLE_ID }}
vaultSecretId: ${{ secrets.VAULT_SECRET_ID }}
slackChannel: "#apm-agent-python"
35 changes: 0 additions & 35 deletions .github/workflows/snapshoty.yml

This file was deleted.

21 changes: 10 additions & 11 deletions .github/workflows/updatecli.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,16 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: elastic/apm-pipeline-library/.github/actions/updatecli@current

- uses: elastic/oblt-actions/updatecli/run@v1
with:
vaultUrl: ${{ secrets.VAULT_ADDR }}
vaultRoleId: ${{ secrets.VAULT_ROLE_ID }}
vaultSecretId: ${{ secrets.VAULT_SECRET_ID }}
pipeline: .ci/updatecli/updatecli.d
values: .ci/updatecli/values.yml
command: "apply --config .ci/updatecli/updatecli.d --values .ci/updatecli/values.yml"
env:
GITHUB_TOKEN: ${{ secrets.UPDATECLI_GH_TOKEN }}

- if: failure()
uses: elastic/apm-pipeline-library/.github/actions/notify-build-status@current
uses: elastic/oblt-actions/slack/send@v1
with:
vaultUrl: ${{ secrets.VAULT_ADDR }}
vaultRoleId: ${{ secrets.VAULT_ROLE_ID }}
vaultSecretId: ${{ secrets.VAULT_SECRET_ID }}
slackChannel: "#apm-agent-python"
bot-token: ${{ secrets.SLACK_BOT_TOKEN }}
channel-id: "#apm-agent-python"
message: ":traffic_cone: updatecli failed for `${{ github.repository }}@${{ github.ref_name }}`, @robots-ci please look what's going on <https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}|here>"
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.3]]
==== 6.22.3 - 2024-06-10
[float]
===== Bug fixes
* Fix outcome in ASGI and Starlette apps on error status codes without an exception {pull}2060[#2060]
[[release-notes-6.22.2]]
==== 6.22.2 - 2024-05-20
Expand Down
2 changes: 1 addition & 1 deletion dev-utils/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# These are the pinned requirements for the lambda layer/docker image
certifi==2024.2.2
certifi==2024.6.2
urllib3==1.26.18
wrapt==1.14.1
1 change: 1 addition & 0 deletions elasticapm/contrib/asgi.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ async def wrapped_send(message) -> None:
await set_context(lambda: middleware.get_data_from_response(message, constants.TRANSACTION), "response")
result = "HTTP {}xx".format(message["status"] // 100)
elasticapm.set_transaction_result(result, override=False)
elasticapm.set_transaction_outcome(http_status_code=message["status"], override=False)
await send(message)

return wrapped_send
Expand Down
1 change: 1 addition & 0 deletions elasticapm/contrib/starlette/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,7 @@ async def wrapped_send(message) -> None:
)
result = "HTTP {}xx".format(message["status"] // 100)
elasticapm.set_transaction_result(result, override=False)
elasticapm.set_transaction_outcome(http_status_code=message["status"], override=False)
await send(message)

_mocked_receive = None
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, 2)
__version__ = (6, 22, 3)
VERSION = ".".join(map(str, __version__))
5 changes: 5 additions & 0 deletions tests/contrib/asgi/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,3 +59,8 @@ async def boom() -> None:
@app.route("/body")
async def json():
return jsonify({"hello": "world"})


@app.route("/500", methods=["GET"])
async def error():
return "KO", 500
17 changes: 17 additions & 0 deletions tests/contrib/asgi/asgi_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,23 @@ async def test_transaction_span(instrumented_app, elasticapm_client):
assert span["sync"] == False


@pytest.mark.asyncio
async def test_transaction_span(instrumented_app, elasticapm_client):
async with async_asgi_testclient.TestClient(instrumented_app) as client:
resp = await client.get("/500")
assert resp.status_code == 500
assert resp.text == "KO"

assert len(elasticapm_client.events[constants.TRANSACTION]) == 1
assert len(elasticapm_client.events[constants.SPAN]) == 0
transaction = elasticapm_client.events[constants.TRANSACTION][0]
assert transaction["name"] == "GET unknown route"
assert transaction["result"] == "HTTP 5xx"
assert transaction["outcome"] == "failure"
assert transaction["context"]["request"]["url"]["full"] == "/500"
assert transaction["context"]["response"]["status_code"] == 500


@pytest.mark.asyncio
async def test_transaction_ignore_url(instrumented_app, elasticapm_client):
elasticapm_client.config.update("1", transaction_ignore_urls="/foo*")
Expand Down
Loading
Loading