Skip to content
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
77 changes: 77 additions & 0 deletions .ci/.matrix_exclude.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,53 @@ exclude:
# Django 4.0 requires Python 3.8+
- VERSION: pypy-3 # current pypy-3 is compatible with Python 3.7
FRAMEWORK: django-4.0
- VERSION: python-3.6
FRAMEWORK: django-4.0
- VERSION: python-3.7
FRAMEWORK: django-4.0
# Django 4.2 requires Python 3.8+
- VERSION: python-3.6
FRAMEWORK: django-4.2
- VERSION: python-3.7
FRAMEWORK: django-4.2
# Django 5.0 requires Python 3.10+
- VERSION: python-3.6
FRAMEWORK: django-5.0
- VERSION: python-3.7
FRAMEWORK: django-5.0
- VERSION: python-3.8
FRAMEWORK: django-5.0
- VERSION: python-3.9
FRAMEWORK: django-5.0
- VERSION: pypy-3 # current pypy-3 is compatible with Python 3.7
FRAMEWORK: celery-5-django-4
- VERSION: python-3.6
FRAMEWORK: celery-5-django-4
- VERSION: python-3.7
FRAMEWORK: celery-5-django-4
- VERSION: python-3.6
FRAMEWORK: celery-5-django-5
- VERSION: python-3.7
FRAMEWORK: celery-5-django-5
- VERSION: python-3.8
FRAMEWORK: celery-5-django-5
- VERSION: python-3.9
FRAMEWORK: celery-5-django-5
# Flask
- VERSION: pypy-3
FRAMEWORK: flask-0.11 # see https://github.com/pallets/flask/commit/6e46d0cd, 0.11.2 was never released
- VERSION: python-3.6
FRAMEWORK: flask-2.1
- VERSION: python-3.6
FRAMEWORK: flask-2.2
- VERSION: python-3.6
FRAMEWORK: flask-2.3
- VERSION: python-3.6
FRAMEWORK: flask-3.0
- VERSION: python-3.7
FRAMEWORK: flask-2.3
- VERSION: python-3.7
FRAMEWORK: flask-3.0
# Python 3.10 removed a bunch of classes from collections, now in collections.abc
- VERSION: python-3.10
FRAMEWORK: django-1.11
Expand Down Expand Up @@ -152,6 +185,8 @@ exclude:
# pymssql
- VERSION: pypy-3 # currently fails with error on pypy3
FRAMEWORK: pymssql-newest
- VERSION: python-3.6 # dropped support for py3.6
FRAMEWORK: pymssql-newest
# pyodbc
- VERSION: pypy-3
FRAMEWORK: pyodbc-newest
Expand All @@ -175,49 +210,81 @@ exclude:
# aiohttp client, only supported in Python 3.7+
- VERSION: pypy-3
FRAMEWORK: aiohttp-3.0
- VERSION: python-3.6
FRAMEWORK: aiohttp-3.0
- VERSION: pypy-3
FRAMEWORK: aiohttp-4.0
- VERSION: python-3.6
FRAMEWORK: aiohttp-4.0
- VERSION: pypy-3
FRAMEWORK: aiohttp-newest
- VERSION: python-3.6
FRAMEWORK: aiohttp-newest
# tornado, only supported in Python 3.7+
- VERSION: pypy-3
FRAMEWORK: tornado-newest
- VERSION: python-3.6
FRAMEWORK: tornado-newest
# Starlette, only supported in python 3.7+
- VERSION: pypy-3
FRAMEWORK: starlette-0.13
- VERSION: python-3.6
FRAMEWORK: starlette-0.13
- VERSION: pypy-3
FRAMEWORK: starlette-0.14
- VERSION: python-3.6
FRAMEWORK: starlette-0.14
- VERSION: pypy-3
FRAMEWORK: starlette-newest
- VERSION: python-3.6
FRAMEWORK: starlette-newest
# aiopg
- VERSION: pypy-3
FRAMEWORK: aiopg-newest
- VERSION: python-3.6
FRAMEWORK: aiopg-newest
# asyncpg
- VERSION: pypy-3
FRAMEWORK: asyncpg-newest
- VERSION: pypy-3
FRAMEWORK: asyncpg-0.28
- VERSION: python-3.6
FRAMEWORK: asyncpg-newest
- VERSION: python-3.6
FRAMEWORK: asyncpg-0.28
- VERSION: python-3.13
FRAMEWORK: asyncpg-0.28
# sanic
- VERSION: pypy-3
FRAMEWORK: sanic-newest
- VERSION: pypy-3
FRAMEWORK: sanic-20.12
- VERSION: python-3.6
FRAMEWORK: sanic-20.12
- VERSION: python-3.6
FRAMEWORK: sanic-newest
- VERSION: python-3.8
FRAMEWORK: sanic-newest
- VERSION: python-3.13
FRAMEWORK: sanic-20.12
# aioredis
- VERSION: pypy-3
FRAMEWORK: aioredis-newest
- VERSION: python-3.6
FRAMEWORK: aioredis-newest
# aiomysql
- VERSION: pypy-3
FRAMEWORK: aiomysql-newest
- VERSION: python-3.6
FRAMEWORK: aiomysql-newest
# aiobotocore
- VERSION: pypy-3
FRAMEWORK: aiobotocore-newest
- VERSION: python-3.6
FRAMEWORK: aiobotocore-newest
# mysql-connector-python
- VERSION: python-3.6
FRAMEWORK: mysql_connector-newest
# twisted
- VERSION: python-3.11
FRAMEWORK: twisted-18
Expand Down Expand Up @@ -251,6 +318,10 @@ exclude:
- VERSION: python-3.13
FRAMEWORK: pylibmc-1.4
# grpc
- VERSION: python-3.6
FRAMEWORK: grpc-newest
- VERSION: python-3.7
FRAMEWORK: grpc-1.24
- VERSION: python-3.8
FRAMEWORK: grpc-1.24
- VERSION: python-3.9
Expand All @@ -263,6 +334,12 @@ exclude:
FRAMEWORK: grpc-1.24
- VERSION: python-3.13
FRAMEWORK: grpc-1.24
- VERSION: python-3.7
FRAMEWORK: flask-1.0
- VERSION: python-3.7
FRAMEWORK: flask-1.1
- VERSION: python-3.7
FRAMEWORK: jinja2-2
# TODO py3.12
- VERSION: python-3.12
FRAMEWORK: sanic-20.12 # no wheels available yet
Expand Down
2 changes: 1 addition & 1 deletion .ci/.matrix_python.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
VERSION:
- python-3.8
- python-3.6
- python-3.13
2 changes: 2 additions & 0 deletions .ci/.matrix_python_full.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
VERSION:
- python-3.6
- python-3.7
- python-3.8
- python-3.9
- python-3.10
Expand Down
2 changes: 1 addition & 1 deletion .ci/publish-aws.sh
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ for region in $ALL_AWS_REGIONS; do
--layer-name="${FULL_LAYER_NAME}" \
--description="AWS Lambda Extension Layer for the Elastic APM Python Agent" \
--license-info="BSD-3-Clause" \
--compatible-runtimes python3.8 python3.9 python3.10 python3.11 python3.12 python3.13\
--compatible-runtimes python3.6 python3.7 python3.8 python3.9 python3.10 python3.11 python3.12 python3.13\
--zip-file="fileb://${zip_file}")
echo "${publish_output}" > "${AWS_FOLDER}/${region}"
layer_version=$(echo "${publish_output}" | jq '.Version')
Expand Down
6 changes: 6 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,12 @@ jobs:
fail-fast: false
matrix:
include:
# - version: "3.6"
# framework: "none"
# asyncio: "true"
# - version: "3.7"
# framework: none
# asyncio: true
- version: "3.8"
framework: none
asyncio: true
Expand Down
10 changes: 8 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,14 @@ flake8:
test:
# delete any __pycache__ folders to avoid hard-to-debug caching issues
find . -type f -name '*.py[co]' -delete -o -type d -name __pycache__ -delete
echo "Python 3.7+, with asyncio"; \
pytest -v $(PYTEST_ARGS) --showlocals $(PYTEST_MARKER) $(PYTEST_JUNIT); \
# pypy3 should be added to the first `if` once it supports py3.7
if [[ "$$PYTHON_VERSION" =~ ^(3.7|3.8|3.9|3.10|3.11|3.12|3.13|nightly)$$ ]] ; then \
echo "Python 3.7+, with asyncio"; \
pytest -v $(PYTEST_ARGS) --showlocals $(PYTEST_MARKER) $(PYTEST_JUNIT); \
else \
echo "Python < 3.7, without asyncio"; \
pytest -v $(PYTEST_ARGS) --showlocals $(PYTEST_MARKER) $(PYTEST_JUNIT) --ignore-glob='*/asyncio*/*'; \
fi

coverage: PYTEST_ARGS=--cov --cov-context=test --cov-config=setup.cfg --cov-branch
coverage: export COVERAGE_FILE=.coverage.docker.$(PYTHON_FULL_VERSION).$(FRAMEWORK)
Expand Down
2 changes: 1 addition & 1 deletion docs/reference/run-tests-locally.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ $ ./tests/scripts/docker/run_tests.sh python-version framework-version <pip-cach
```

::::{note}
The `python-version` must be of format `python-version`, e.g. `python-3.8` or `pypy-3`. The `framework` must be of format `framework-version`, e.g. `django-1.10` or `flask-0.12`.
The `python-version` must be of format `python-version`, e.g. `python-3.6` or `pypy-2`. The `framework` must be of format `framework-version`, e.g. `django-1.10` or `flask-0.12`.
::::


Expand Down
4 changes: 2 additions & 2 deletions elasticapm/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@
VERSION = "unknown"


if sys.version_info < (3, 8):
raise DeprecationWarning("The Elastic APM agent requires Python 3.8+")
if sys.version_info <= (3, 5):
raise DeprecationWarning("The Elastic APM agent requires Python 3.6+")

from elasticapm.contrib.asyncio.traces import async_capture_span # noqa: F401 E402
4 changes: 2 additions & 2 deletions elasticapm/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -704,8 +704,8 @@ def should_ignore_topic(self, topic: str) -> bool:

def check_python_version(self) -> None:
v = tuple(map(int, platform.python_version_tuple()[:2]))
if v < (3, 8):
warnings.warn("The Elastic APM agent only supports Python 3.8+", DeprecationWarning)
if v < (3, 6):
warnings.warn("The Elastic APM agent only supports Python 3.6+", DeprecationWarning)

def check_server_version(
self, gte: Optional[Tuple[int, ...]] = None, lte: Optional[Tuple[int, ...]] = None
Expand Down
50 changes: 29 additions & 21 deletions elasticapm/instrumentation/register.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@
# 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.

import sys

from elasticapm.utils.module_import import import_string

_cls_register = {
Expand Down Expand Up @@ -68,29 +70,35 @@
"elasticapm.instrumentation.packages.kafka.KafkaInstrumentation",
"elasticapm.instrumentation.packages.grpc.GRPCClientInstrumentation",
"elasticapm.instrumentation.packages.grpc.GRPCServerInstrumentation",
"elasticapm.instrumentation.packages.asyncio.sleep.AsyncIOSleepInstrumentation",
"elasticapm.instrumentation.packages.asyncio.aiohttp_client.AioHttpClientInstrumentation",
"elasticapm.instrumentation.packages.httpx.async.httpx.HttpxAsyncClientInstrumentation",
"elasticapm.instrumentation.packages.asyncio.elasticsearch.ElasticSearchAsyncConnection",
"elasticapm.instrumentation.packages.asyncio.elasticsearch.ElasticsearchAsyncTransportInstrumentation",
"elasticapm.instrumentation.packages.asyncio.aiopg.AioPGInstrumentation",
"elasticapm.instrumentation.packages.asyncio.asyncpg.AsyncPGInstrumentation",
"elasticapm.instrumentation.packages.tornado.TornadoRequestExecuteInstrumentation",
"elasticapm.instrumentation.packages.tornado.TornadoHandleRequestExceptionInstrumentation",
"elasticapm.instrumentation.packages.tornado.TornadoRenderInstrumentation",
"elasticapm.instrumentation.packages.httpx.async.httpcore.HTTPCoreAsyncInstrumentation",
"elasticapm.instrumentation.packages.asyncio.aioredis.RedisConnectionPoolInstrumentation",
"elasticapm.instrumentation.packages.asyncio.aioredis.RedisPipelineInstrumentation",
"elasticapm.instrumentation.packages.asyncio.aioredis.RedisConnectionInstrumentation",
"elasticapm.instrumentation.packages.asyncio.aiomysql.AioMySQLInstrumentation",
"elasticapm.instrumentation.packages.asyncio.aiobotocore.AioBotocoreInstrumentation",
"elasticapm.instrumentation.packages.asyncio.starlette.StarletteServerErrorMiddlewareInstrumentation",
"elasticapm.instrumentation.packages.asyncio.redis_asyncio.RedisAsyncioInstrumentation",
"elasticapm.instrumentation.packages.asyncio.redis_asyncio.RedisPipelineInstrumentation",
"elasticapm.instrumentation.packages.asyncio.psycopg_async.AsyncPsycopgInstrumentation",
"elasticapm.instrumentation.packages.grpc.GRPCAsyncServerInstrumentation",
}

if sys.version_info >= (3, 7):
_cls_register.update(
[
"elasticapm.instrumentation.packages.asyncio.sleep.AsyncIOSleepInstrumentation",
"elasticapm.instrumentation.packages.asyncio.aiohttp_client.AioHttpClientInstrumentation",
"elasticapm.instrumentation.packages.httpx.async.httpx.HttpxAsyncClientInstrumentation",
"elasticapm.instrumentation.packages.asyncio.elasticsearch.ElasticSearchAsyncConnection",
"elasticapm.instrumentation.packages.asyncio.elasticsearch.ElasticsearchAsyncTransportInstrumentation",
"elasticapm.instrumentation.packages.asyncio.aiopg.AioPGInstrumentation",
"elasticapm.instrumentation.packages.asyncio.asyncpg.AsyncPGInstrumentation",
"elasticapm.instrumentation.packages.tornado.TornadoRequestExecuteInstrumentation",
"elasticapm.instrumentation.packages.tornado.TornadoHandleRequestExceptionInstrumentation",
"elasticapm.instrumentation.packages.tornado.TornadoRenderInstrumentation",
"elasticapm.instrumentation.packages.httpx.async.httpcore.HTTPCoreAsyncInstrumentation",
"elasticapm.instrumentation.packages.asyncio.aioredis.RedisConnectionPoolInstrumentation",
"elasticapm.instrumentation.packages.asyncio.aioredis.RedisPipelineInstrumentation",
"elasticapm.instrumentation.packages.asyncio.aioredis.RedisConnectionInstrumentation",
"elasticapm.instrumentation.packages.asyncio.aiomysql.AioMySQLInstrumentation",
"elasticapm.instrumentation.packages.asyncio.aiobotocore.AioBotocoreInstrumentation",
"elasticapm.instrumentation.packages.asyncio.starlette.StarletteServerErrorMiddlewareInstrumentation",
"elasticapm.instrumentation.packages.asyncio.redis_asyncio.RedisAsyncioInstrumentation",
"elasticapm.instrumentation.packages.asyncio.redis_asyncio.RedisPipelineInstrumentation",
"elasticapm.instrumentation.packages.asyncio.psycopg_async.AsyncPsycopgInstrumentation",
"elasticapm.instrumentation.packages.grpc.GRPCAsyncServerInstrumentation",
]
)

# These instrumentations should only be enabled if we're instrumenting via the
# wrapper script, which calls register_wrapper_instrumentations() below.
_wrapper_register = {
Expand Down
4 changes: 3 additions & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ classifiers =
Operating System :: OS Independent
Topic :: Software Development
Programming Language :: Python
Programming Language :: Python :: 3.6
Programming Language :: Python :: 3.7
Programming Language :: Python :: 3.8
Programming Language :: Python :: 3.9
Programming Language :: Python :: 3.10
Expand All @@ -31,7 +33,7 @@ project_urls =
Tracker = https://github.com/elastic/apm-agent-python/issues

[options]
python_requires = >=3.8, <4
python_requires = >=3.6, <4
packages = find:
include_package_data = true
zip_safe = false
Expand Down
2 changes: 1 addition & 1 deletion tests/client/client_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@
import time
import warnings
from collections import defaultdict
from unittest import mock

import mock
import pytest
from pytest_localserver.http import ContentServer
from pytest_localserver.https import DEFAULT_CERTIFICATE
Expand Down
2 changes: 1 addition & 1 deletion tests/client/exception_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

import os
from unittest import mock

import mock
import pytest

import elasticapm
Expand Down
2 changes: 1 addition & 1 deletion tests/client/py3_exception_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
#
#

from unittest import mock
import mock

from elasticapm.conf.constants import ERROR

Expand Down
3 changes: 1 addition & 2 deletions tests/config/central_config_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,7 @@
# 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.

from unittest import mock

import mock
import pytest


Expand Down
2 changes: 1 addition & 1 deletion tests/config/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@
import platform
import stat
from datetime import timedelta
from unittest import mock

import mock
import pytest

import elasticapm.conf
Expand Down
Loading
Loading