diff --git a/src/instana/instrumentation/logging.py b/src/instana/instrumentation/logging.py index 040df5b4..9bb58885 100644 --- a/src/instana/instrumentation/logging.py +++ b/src/instana/instrumentation/logging.py @@ -2,11 +2,12 @@ # (c) Copyright Instana Inc. 2019 -import sys -import wrapt import logging +import sys from collections.abc import Mapping -from typing import Any, Tuple, Dict, Callable +from typing import Any, Callable, Dict, Tuple + +import wrapt from instana.log import logger from instana.util.runtime import get_runtime_env_info @@ -26,7 +27,7 @@ def log_with_instana( # We take into consideration if `stacklevel` is already present in `kwargs`. # This prevents the error `_log() got multiple values for keyword argument 'stacklevel'` - stacklevel_in = kwargs.pop("stacklevel", 1 if get_runtime_env_info()[0] != "ppc64le" else 2) + stacklevel_in = kwargs.pop("stacklevel", 1 if get_runtime_env_info()[0] not in ["ppc64le", "s390x"] else 2) stacklevel = stacklevel_in + 1 + (sys.version_info >= (3, 14)) try: diff --git a/tests/clients/test_logging.py b/tests/clients/test_logging.py index 239dc0c5..e924ac1c 100644 --- a/tests/clients/test_logging.py +++ b/tests/clients/test_logging.py @@ -8,8 +8,8 @@ import pytest from opentelemetry.trace import SpanKind -from instana.util.runtime import get_runtime_env_info from instana.singletons import agent, tracer +from instana.util.runtime import get_runtime_env_info class TestLogging: @@ -147,7 +147,7 @@ def test_log_caller_with_stacklevel( ) self.logger.addHandler(handler) - if get_runtime_env_info()[0] == "ppc64le": + if get_runtime_env_info()[0] in ["ppc64le", "s390x"]: stacklevel += 1 def log_custom_warning(): diff --git a/tests/clients/test_sqlalchemy.py b/tests/clients/test_sqlalchemy.py index 6cbd8a87..9ace784c 100644 --- a/tests/clients/test_sqlalchemy.py +++ b/tests/clients/test_sqlalchemy.py @@ -276,7 +276,7 @@ def test_error_before_tracing(self) -> None: invalid_connection_url = "postgresql://user1:pwd1@localhost:9999/mydb1" with pytest.raises( OperationalError, - match=r"\(psycopg2.OperationalError\) connection .* failed.*", + match=r"^(\(psycopg2\.OperationalError\)).*", ) as context_manager: engine = create_engine(invalid_connection_url) with engine.connect() as connection: diff --git a/tests/conftest.py b/tests/conftest.py index 18f89443..4f890b01 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -31,12 +31,16 @@ "*agent/test_google*", ] -# ppc64le has limitations with some supported libraries. +# ppc64le and s390x have limitations with some supported libraries. machine, py_version = get_runtime_env_info() -if machine == "ppc64le": - collect_ignore_glob.append("*test_grpcio*") - collect_ignore_glob.append("*test_google-cloud*") - collect_ignore_glob.append("*test_pymongo*") +if machine in ["ppc64le", "s390x"]: + collect_ignore_glob.extend([ + "*test_google-cloud*", + "*test_pymongo*", + ]) + + if machine == "ppc64le": + collect_ignore_glob.append("*test_grpcio*") # # Cassandra and gevent tests are run in dedicated jobs on CircleCI and will # # be run explicitly. (So always exclude them here) @@ -47,8 +51,10 @@ collect_ignore_glob.append("*test_couchbase*") if not os.environ.get("GEVENT_STARLETTE_TEST"): - collect_ignore_glob.append("*test_gevent*") - collect_ignore_glob.append("*test_starlette*") + collect_ignore_glob.extend([ + "*test_gevent*", + "*test_starlette*", + ]) if not os.environ.get("KAFKA_TEST"): collect_ignore_glob.append("*kafka/test*") @@ -59,13 +65,14 @@ if sys.version_info >= (3, 14): - # Currently not installable dependencies because of 3.14 incompatibilities - collect_ignore_glob.append("*test_fastapi*") - # aiohttp-server tests failing due to deprecated methods used - collect_ignore_glob.append("*test_aiohttp_server*") - # Currently Sanic does not support python >= 3.14 - collect_ignore_glob.append("*test_sanic*") - + collect_ignore_glob.extend([ + # Currently not installable dependencies because of 3.14 incompatibilities + "*test_fastapi*", + # aiohttp-server tests failing due to deprecated methods used + "*test_aiohttp_server*", + # Currently Sanic does not support python >= 3.14 + "*test_sanic*", + ]) @pytest.fixture(scope="session") def celery_config(): diff --git a/tests/recorder/test_stan_recorder.py b/tests/recorder/test_stan_recorder.py index 5f9940f6..c5b2eb91 100644 --- a/tests/recorder/test_stan_recorder.py +++ b/tests/recorder/test_stan_recorder.py @@ -1,15 +1,16 @@ -from multiprocessing import Queue import sys +from multiprocessing import Queue from unittest import TestCase from unittest.mock import NonCallableMagicMock, PropertyMock import pytest from instana.recorder import StanRecorder +from instana.util.runtime import get_runtime_env_info @pytest.mark.skipif( - sys.platform == "darwin", + sys.platform == "darwin" or get_runtime_env_info()[0] == "s390x", reason="Avoiding NotImplementedError when calling multiprocessing.Queue.qsize()", ) class TestStanRecorderTC(TestCase): diff --git a/tests_aws/conftest.py b/tests_aws/conftest.py index 767147fa..9f71c315 100644 --- a/tests_aws/conftest.py +++ b/tests_aws/conftest.py @@ -1,5 +1,4 @@ -# (c) Copyright IBM Corp. 2021 -# (c) Copyright Instana Inc. 2020 +# (c) Copyright IBM Corp. 2024 import os import platform @@ -7,9 +6,12 @@ os.environ["INSTANA_ENDPOINT_URL"] = "https://localhost/notreal" os.environ["INSTANA_AGENT_KEY"] = "Fake_Key" -# ppc64le is not supported by AWS Serverless Services. +# ppc64le and s390x are not supported by AWS Serverless Services. collect_ignore_glob = [] -if platform.machine() == "ppc64le": - collect_ignore_glob.append("*test_lambda*") - collect_ignore_glob.append("*test_fargate*") - collect_ignore_glob.append("*test_eks*") \ No newline at end of file +if platform.machine() in ["ppc64le", "s390x"]: + collect_ignore_glob.extend([ + "*test_lambda*", + "*test_fargate*", + "*test_eks*", + ]) + \ No newline at end of file