From 3a55722c39d0a18770c5abec4791cde1ae1a7dd2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ferenc=20G=C3=A9czi?= Date: Thu, 15 Sep 2022 00:00:00 +0000 Subject: [PATCH 1/3] Add support for Flask 2.2 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Keeps backwards compatibility with 2.1, 2.0, 1.x Signed-off-by: Ferenc Géczi --- instana/instrumentation/flask/common.py | 11 ++++++----- tests/requirements-310.txt | 9 +++------ 2 files changed, 9 insertions(+), 11 deletions(-) diff --git a/instana/instrumentation/flask/common.py b/instana/instrumentation/flask/common.py index a21aa4736..5537ba777 100644 --- a/instana/instrumentation/flask/common.py +++ b/instana/instrumentation/flask/common.py @@ -14,15 +14,16 @@ @wrapt.patch_function_wrapper('flask', 'templating._render') def render_with_instana(wrapped, instance, argv, kwargs): - ctx = argv[1] - # If we're not tracing, just return - if not hasattr(ctx['g'], 'scope'): + if not (hasattr(flask, 'g') and hasattr(flask.g, 'scope')): return wrapped(*argv, **kwargs) - with tracer.start_active_span("render", child_of=ctx['g'].scope.span) as rscope: + parent_span = flask.g.scope.span + + with tracer.start_active_span("render", child_of=parent_span) as rscope: try: - template = argv[0] + flask_version = tuple(map(int, flask.__version__.split('.'))) + template = argv[1] if flask_version >= (2, 2, 0) else argv[0] rscope.span.set_tag("type", "template") if template.name is None: diff --git a/tests/requirements-310.txt b/tests/requirements-310.txt index 041c533e3..28bb9b59c 100644 --- a/tests/requirements-310.txt +++ b/tests/requirements-310.txt @@ -14,16 +14,13 @@ celery>=5.0.5 coverage>=5.5 Django>=3.2.10 fastapi>=0.65.1 -flask>=2.0.0 -markupsafe>=2.1.0 +flask>=1.1.4,<2.0.0 grpcio>=1.37.1 google-cloud-pubsub<=2.1.0 google-cloud-storage>=1.24.0 lxml>=4.6.3 mock>=4.0.3 - -# We have to increase the minimum moto version so we can keep markupsafe on the required minimum -moto>=2.0 +moto>=1.3.16,<2.0 mysqlclient>=2.0.3 nose>=1.3.7 PyMySQL[rsa]>=1.0.2 @@ -45,7 +42,7 @@ pytest-celery redis>=3.5.3 requests-mock responses<=0.17.0 -sanic>=19.0.0,<21.9.0 +sanic==21.6.2 sqlalchemy>=1.4.15 spyne>=2.13.16 suds-jurko>=0.6 From 544c978368ade06ffc02112d9d8976afa8e64f8f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ferenc=20G=C3=A9czi?= Date: Fri, 16 Sep 2022 00:00:00 +0000 Subject: [PATCH 2/3] feat(test): Test with Flask 2.2 on Python 3.10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Ferenc Géczi --- tests/requirements-310.txt | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/tests/requirements-310.txt b/tests/requirements-310.txt index 28bb9b59c..ea0e83173 100644 --- a/tests/requirements-310.txt +++ b/tests/requirements-310.txt @@ -14,13 +14,16 @@ celery>=5.0.5 coverage>=5.5 Django>=3.2.10 fastapi>=0.65.1 -flask>=1.1.4,<2.0.0 +flask>=2.2.0 +markupsafe>=2.1.0 grpcio>=1.37.1 google-cloud-pubsub<=2.1.0 google-cloud-storage>=1.24.0 lxml>=4.6.3 mock>=4.0.3 -moto>=1.3.16,<2.0 +# We have to increase the minimum moto version so we can keep markupsafe on the required minimum +# TODO: This appears to break 'test_get_secret_value' in test_boto3_secretsmanager.py +moto>=2.0 mysqlclient>=2.0.3 nose>=1.3.7 PyMySQL[rsa]>=1.0.2 From 831f5b8e2e4ed92f4f7e40f02a232f770a5844eb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ferenc=20G=C3=A9czi?= Date: Fri, 16 Sep 2022 00:00:00 +0000 Subject: [PATCH 3/3] fix(test): Skip one more flaky asynqp TC MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Ferenc Géczi --- tests/clients/test_asynqp.py | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/clients/test_asynqp.py b/tests/clients/test_asynqp.py index 17c7ea8ab..f44e3933f 100644 --- a/tests/clients/test_asynqp.py +++ b/tests/clients/test_asynqp.py @@ -73,6 +73,7 @@ async def fetch(self, session, url, headers=None): except aiohttp.web_exceptions.HTTPException: pass + @pytest.mark.skip(reason="Asynqp is an abandoned library, sometimes messages are duplicated randomly") def test_publish(self): @asyncio.coroutine def test():