Skip to content

Commit 4a765bb

Browse files
committed
feat: Drop support for Python 2, webapp2, suds-jurko, asynqp
* Drop support for Python 2, and everything below the last supported version of the Python Software Foundation, which is everyting below Python 3.7 * Modernise the code accordingly - Import from collections.abc - Stop using distutils as it is slasted for removal, and already emits constant warnings. * Add full support for Python 3.10 * Drop webapp2 as it was Python 2 only, now abandoned * Drop suds-jurko as it is an abandoned library * Drop asynqp as it is an abandoned library * Drop support for the `INSTANA_MAGIC` mechanism, which has been removed from `autotrace-dynamic` more than two years ago.
1 parent 5f27bd4 commit 4a765bb

36 files changed

+277
-1584
lines changed

.circleci/config.yml

Lines changed: 5 additions & 143 deletions
Original file line numberDiff line numberDiff line change
@@ -5,24 +5,6 @@ version: 2.1
55
# ruby: circleci/[email protected]
66

77
commands:
8-
pip-install-deps-27:
9-
parameters:
10-
requirements:
11-
default: "tests/requirements-27.txt"
12-
type: string
13-
steps:
14-
- run:
15-
name: Install Python 2.7 Dependencies
16-
command: |
17-
rm -rf venv
18-
export PATH=/home/circleci/.local/bin:$PATH
19-
pip install -U pip setuptools virtualenv wheel
20-
virtualenv --python=python2.7 --always-copy venv
21-
. venv/bin/activate
22-
pip install 'wheel>=0.29.0'
23-
pip install -r requirements.txt
24-
pip install -r <<parameters.requirements>>
25-
268
pip-install-deps:
279
parameters:
2810
requirements:
@@ -31,12 +13,9 @@ commands:
3113
steps:
3214
- run:
3315
name: Install Python Dependencies
34-
# TODO: Remove the pinning of setuptools
35-
# as soon as we get rid of suds-jurko
3616
command: |
3717
python -m venv venv
3818
. venv/bin/activate
39-
pip install --upgrade 'setuptools<58'
4019
pip install --upgrade pip
4120
pip install 'wheel>=0.29.0'
4221
pip install -r requirements.txt
@@ -57,39 +36,6 @@ commands:
5736
sudo apt install libcouchbase-dev -y
5837
5938
jobs:
60-
python27:
61-
docker:
62-
- image: cimg/python:2.7.18
63-
- image: cimg/postgres:9.6.24
64-
environment:
65-
POSTGRES_USER: root
66-
POSTGRES_PASSWORD: ''
67-
POSTGRES_DB: circle_test
68-
- image: cimg/mariadb:10.6.7
69-
- image: cimg/redis:5.0.14
70-
- image: rabbitmq:3.9.13
71-
- image: mongo:4.2.3
72-
- image: singularities/pubsub-emulator
73-
environment:
74-
PUBSUB_PROJECT_ID: "project-test"
75-
PUBSUB_LISTEN_ADDRESS: "0.0.0.0:8432"
76-
working_directory: ~/repo
77-
steps:
78-
- checkout
79-
- run:
80-
name: Install MySQL Dependencies
81-
command: |
82-
sudo apt update
83-
sudo apt install libmysqlclient-dev
84-
- pip-install-deps-27
85-
- run:
86-
name: run tests
87-
environment:
88-
INSTANA_TEST: "true"
89-
command: |
90-
. venv/bin/activate
91-
pytest -v
92-
9339
python37:
9440
docker:
9541
- image: cimg/python:3.7.13
@@ -228,49 +174,9 @@ jobs:
228174
. venv/bin/activate
229175
pytest -v tests/clients/test_couchbase.py
230176
231-
py27couchbase:
232-
docker:
233-
- image: cimg/python:2.7.18
234-
- image: couchbase/server-sandbox:5.5.0
235-
working_directory: ~/repo
236-
steps:
237-
- checkout
238-
- install-couchbase-deps
239-
- pip-install-deps-27:
240-
requirements: "tests/requirements-couchbase.txt"
241-
- run:
242-
name: run tests
243-
environment:
244-
INSTANA_TEST: "true"
245-
COUCHBASE_TEST: "true"
246-
command: |
247-
. venv/bin/activate
248-
pytest -v tests/clients/test_couchbase.py
249-
250-
py27cassandra:
177+
py37cassandra:
251178
docker:
252-
- image: cimg/python:2.7.16
253-
- image: cassandra:3.11
254-
environment:
255-
MAX_HEAP_SIZE: 2048m
256-
HEAP_NEWSIZE: 512m
257-
working_directory: ~/repo
258-
steps:
259-
- checkout
260-
- pip-install-deps-27:
261-
requirements: "tests/requirements-cassandra.txt"
262-
- run:
263-
name: run tests
264-
environment:
265-
INSTANA_TEST: "true"
266-
CASSANDRA_TEST: "true"
267-
command: |
268-
. venv/bin/activate
269-
pytest -v tests/clients/test_cassandra-driver.py
270-
271-
py36cassandra:
272-
docker:
273-
- image: cimg/python:3.6.15
179+
- image: cimg/python:3.7.13
274180
- image: cassandra:3.11
275181
environment:
276182
MAX_HEAP_SIZE: 2048m
@@ -289,47 +195,7 @@ jobs:
289195
. venv/bin/activate
290196
pytest -v tests/clients/test_cassandra-driver.py
291197
292-
py37asynqp:
293-
docker:
294-
- image: cimg/python:3.7.13
295-
- image: rabbitmq:3.9.13
296-
working_directory: ~/repo
297-
steps:
298-
- checkout
299-
- pip-install-deps:
300-
requirements: "tests/requirements-asynqp.txt"
301-
- run:
302-
name: run tests
303-
environment:
304-
INSTANA_TEST: "true"
305-
ASYNQP_TEST: "true"
306-
command: |
307-
. venv/bin/activate
308-
# We uninstall uvloop as it interferes with asyncio changing the event loop policy
309-
pip uninstall -y uvloop
310-
pytest -v tests/clients/test_asynqp.py
311-
312-
py37asynqp-legacy:
313-
docker:
314-
- image: cimg/python:3.7.13
315-
- image: rabbitmq:3.9.13
316-
working_directory: ~/repo
317-
steps:
318-
- checkout
319-
- pip-install-deps:
320-
requirements: "tests/requirements-asynqp-legacy-flask-markupsafe.txt"
321-
- run:
322-
name: run tests
323-
environment:
324-
INSTANA_TEST: "true"
325-
ASYNQP_TEST: "true"
326-
command: |
327-
. venv/bin/activate
328-
# We uninstall uvloop as it interferes with asyncio changing the event loop policy
329-
pip uninstall -y uvloop
330-
pytest -v tests/clients/test_asynqp.py
331-
332-
gevent38:
198+
py38gevent:
333199
docker:
334200
- image: cimg/python:3.8.12
335201
working_directory: ~/repo
@@ -350,14 +216,10 @@ workflows:
350216
version: 2
351217
build:
352218
jobs:
353-
- python27
354219
- python37
355220
- python38
356221
- python39
357222
- python310
358-
- py27cassandra
359-
- py36cassandra
360-
- py37asynqp
361-
- py37asynqp-legacy
223+
- py37cassandra
362224
- py38couchbase
363-
- gevent38
225+
- py38gevent

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
The `instana` Python package collects key metrics and distributed traces for [Instana](https://www.instana.com/).
88

9-
This package supports Python 2.7 or greater.
9+
This package supports Python 3.7 or greater.
1010

1111
Any and all feedback is welcome. Happy Python visibility.
1212

bin/aws-lambda/build_and_publish_lambda_layer.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@
8585
"Provides Instana tracing and monitoring of AWS Lambda functions built with Python",
8686
"--license-info", "MIT", "--output", "json",
8787
"--layer-name", LAYER_NAME, "--zip-file", aws_zip_filename,
88-
"--compatible-runtimes", "python2.7", "python3.6", "python3.7", "python3.8"])
88+
"--compatible-runtimes", "python3.7", "python3.8", "python3.9", "python3.10"])
8989

9090
json_data = json.loads(response)
9191
version = json_data['Version']

example/asyncio/README.md

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
# Asyncio Examples
22

3-
This directory includes an example asyncio application and client with aiohttp and asynqp used for testing.
3+
This directory includes an example asyncio application and client with aiohttp and aio-pika used for testing.
44

55
# Requirements
66

7-
* Python 3.5 or greater
8-
* instana, aiohttp and asynqp Python packages installed
7+
* Python 3.7 or greater
8+
* instana, aiohttp and aio-pika Python packages installed
99
* A RabbitMQ server with it's location specified in the `RABBITMQ_HOST` environment variable
1010

1111

@@ -36,5 +36,8 @@ Some example traces from local tests.
3636
aiohttp client calling aiohttp server:
3737
![screen shot 2019-02-25 at 19 12 28](https://user-images.githubusercontent.com/395132/53401921-0f49cc00-39b1-11e9-8606-24844925a478.png)
3838

39-
aiohttp server making multiple asynqp calls (publish & consume)
39+
aiohttp server making multiple aio-pika calls (publish & consume)
40+
<!--
41+
#TODO: Add new screenshot once we actually have the aio-pika support
42+
-->
4043
![screen shot 2019-02-26 at 10 21 50](https://user-images.githubusercontent.com/395132/53401997-2e485e00-39b1-11e9-97fd-460b136cf92a.png)

example/asyncio/aioclient.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ async def test():
1414
await asyncio.sleep(2)
1515
with async_tracer.start_active_span('JobRunner'):
1616
async with aiohttp.ClientSession() as session:
17-
# aioserver exposes /, /401, /500 & /publish (via asynqp)
17+
# aioserver exposes /, /401, /500 & /publish
1818
async with session.get("http://localhost:5102/publish?secret=iloveyou") as response:
1919
print(response.status)
2020

example/asyncio/aioserver.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33

44
import os
55
import asyncio
6+
# TODO: Change asynqp to aio-pika once it is fully supported
67
import asynqp
78
from aiohttp import web
89

instana/__init__.py

Lines changed: 11 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -107,15 +107,6 @@ def lambda_handler(event, context):
107107
print("Couldn't determine and locate default function handler: %s.%s" % (module_name, function_name))
108108

109109

110-
def boot_agent_later():
111-
""" Executes <boot_agent> in the future! """
112-
if 'gevent' in sys.modules:
113-
import gevent # pylint: disable=import-outside-toplevel
114-
gevent.spawn_later(2.0, boot_agent)
115-
else:
116-
Timer(2.0, boot_agent).start()
117-
118-
119110
def boot_agent():
120111
"""Initialize the Instana agent and conditionally load auto-instrumentation."""
121112
# Disable all the unused-import violations in this function
@@ -129,31 +120,21 @@ def boot_agent():
129120
# Import & initialize instrumentation
130121
from .instrumentation.aws import lambda_inst
131122

132-
if sys.version_info >= (3, 7, 0):
133-
from .instrumentation import sanic_inst
123+
from .instrumentation import sanic_inst
134124

135-
if sys.version_info >= (3, 6, 0):
136-
from .instrumentation import fastapi_inst
137-
from .instrumentation import starlette_inst
125+
from .instrumentation import fastapi_inst
126+
from .instrumentation import starlette_inst
138127

139-
if sys.version_info >= (3, 5, 3):
140-
from .instrumentation import asyncio
141-
from .instrumentation.aiohttp import client
142-
from .instrumentation.aiohttp import server
143-
from .instrumentation import boto3_inst
128+
from .instrumentation import asyncio
129+
from .instrumentation.aiohttp import client
130+
from .instrumentation.aiohttp import server
131+
from .instrumentation import boto3_inst
144132

145-
if sys.version_info >= (3, 5, 3) and sys.version_info < (3, 8, 0):
146-
from .instrumentation import asynqp
147133

148-
if sys.version_info[0] < 3:
149-
from .instrumentation import mysqlpython
150-
from .instrumentation import webapp2_inst
151-
else:
152-
from .instrumentation import mysqlclient
134+
from .instrumentation import mysqlclient
153135

154-
if sys.version_info[0] >= 3:
155-
from .instrumentation.google.cloud import storage
156-
from .instrumentation.google.cloud import pubsub
136+
from .instrumentation.google.cloud import storage
137+
from .instrumentation.google.cloud import pubsub
157138

158139
from .instrumentation.celery import hooks
159140

@@ -170,7 +151,6 @@ def boot_agent():
170151
from .instrumentation import psycopg2
171152
from .instrumentation import redis
172153
from .instrumentation import sqlalchemy
173-
from .instrumentation import sudsjurko
174154
from .instrumentation import urllib3
175155
from .instrumentation.django import middleware
176156
from .instrumentation import pymongo
@@ -195,12 +175,4 @@ def boot_agent():
195175
if profiler:
196176
profiler.start()
197177

198-
if "INSTANA_MAGIC" in os.environ:
199-
pkg_resources.working_set.add_entry("/tmp/.instana/python")
200-
# The following path is deprecated: To be removed at a future date
201-
pkg_resources.working_set.add_entry("/tmp/instana/python")
202-
203-
# If we're being loaded into an already running process, then delay agent initialization
204-
boot_agent_later()
205-
else:
206-
boot_agent()
178+
boot_agent()

instana/autoprofile/runtime.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,6 @@ class runtime_info(object):
1010
OS_LINUX = (sys.platform.startswith('linux'))
1111
OS_DARWIN = (sys.platform == 'darwin')
1212
OS_WIN = (sys.platform == 'win32')
13-
PYTHON_2 = (sys.version_info.major == 2)
14-
PYTHON_3 = (sys.version_info.major == 3)
1513
GEVENT = False
1614

1715
try:

0 commit comments

Comments
 (0)