From 60f2eb87c9a2afcd4061fefaf964a4220c957540 Mon Sep 17 00:00:00 2001 From: erikayasuda Date: Fri, 16 Feb 2024 10:04:01 -0500 Subject: [PATCH 01/22] updated trace methods to accept both legacy and updated dd_trace_methods syntax --- ddtrace/internal/tracemethods.py | 106 +++++++++++++++++++++---------- 1 file changed, 74 insertions(+), 32 deletions(-) diff --git a/ddtrace/internal/tracemethods.py b/ddtrace/internal/tracemethods.py index f6553e11a28..f556160eda5 100644 --- a/ddtrace/internal/tracemethods.py +++ b/ddtrace/internal/tracemethods.py @@ -1,19 +1,57 @@ -import typing # noqa:F401 +from typing import List import wrapt -def _parse_trace_methods(raw_dd_trace_methods): - # type: (str) -> typing.List[str] - """Return the methods to trace based on the specification of DD_TRACE_METHODS. +def _parse_trace_methods(raw_dd_trace_methods: str) -> List[(str, str)]: + """Return a list of the module,methodname tuples to trace based on the + specification of DD_TRACE_METHODS. - DD_TRACE_METHODS is specified to be FullyQualifiedClassOrModuleName[comma-separated-methods] + DD_TRACE_METHODS is specified to be FullyQualifiedModuleName:comma-separated-methods;... + The square bracket notation will be deprecated in favor of this new syntax Note that support for wildcard methods ([*]) is not implemented. - """ - if not raw_dd_trace_methods: - return [] + """ + dd_trace_methods = [] + for qualified_methods in raw_dd_trace_methods.split(";"): + # Validate that methods are specified + if ":" not in qualified_methods: + raise ValueError( + ( + "Invalid DD_TRACE_METHODS: %s. " + "Methods must be specified after a colon following the fully qualified module." + ) + % qualified_methods + ) + + # Store the prefix and the methods (eg. for "foo.bar.baz:qux,quux", + # this is "foo.bar.baz" for the prefix and "qux,quux" for the methods) + qualified_method_prefix, methods = qualified_methods.split(":") + + if qualified_method_prefix == "__main__": + # __main__ cannot be used since the __main__ that exists now is not the same as the __main__ that the user + # application will have. __main__ when sitecustomize module is run is the builtin __main__. + raise ValueError( + "Invalid DD_TRACE_METHODS: %s. Methods cannot be traced on the __main__ module." % qualified_methods + ) + + # Add the methods to the list of methods to trace + for method in methods.split(","): + if not str.isidentifier(method): + raise ValueError( + "Invalid method name: %r. %s" + % ( + method, + "You might have a trailing comma." + if method == "" + else "Method names must be valid Python identifiers.", + ) + ) + dd_trace_methods.append((qualified_method_prefix, method)) + return dd_trace_methods + +def _parse_legacy_trace_methods(raw_dd_trace_methods: str) -> List[str]: dd_trace_methods = [] for qualified_methods in raw_dd_trace_methods.split(";"): # Validate that methods are specified @@ -56,34 +94,38 @@ def _parse_trace_methods(raw_dd_trace_methods): ) ) dd_trace_methods.append("%s.%s" % (qualified_method_prefix, method)) - return dd_trace_methods -def _install_trace_methods(raw_dd_trace_methods): - # type: (str) -> None +def _install_trace_methods(raw_dd_trace_methods: str) -> None: """Install tracing on the given methods.""" - for qualified_method in _parse_trace_methods(raw_dd_trace_methods): - # We don't know if the method is a class method or a module method, so we need to assume it's a module - # and if the import fails then go a level up and try again. - base_module_guess = ".".join(qualified_method.split(".")[:-1]) - method_name = qualified_method.split(".")[-1] - module = None - - while base_module_guess: - try: - module = __import__(base_module_guess) - except ImportError: - # Add the class to the method name - method_name = "%s.%s" % (base_module_guess.split(".")[-1], method_name) - base_module_guess = ".".join(base_module_guess.split(".")[:-1]) - else: - break - - if module is None: - raise ImportError("Could not import module for %r" % qualified_method) - - trace_method(base_module_guess, method_name) + if "[" in raw_dd_trace_methods: + # Using legacy syntax + for qualified_method in _parse_legacy_trace_methods(raw_dd_trace_methods): + # We don't know if the method is a class method or a module method, so we need to assume it's a module + # and if the import fails then go a level up and try again. + base_module_guess = ".".join(qualified_method.split(".")[:-1]) + method_name = qualified_method.split(".")[-1] + module = None + + while base_module_guess: + try: + module = __import__(base_module_guess) + except ImportError: + # Add the class to the method name + method_name = "%s.%s" % (base_module_guess.split(".")[-1], method_name) + base_module_guess = ".".join(base_module_guess.split(".")[:-1]) + else: + break + + if module is None: + raise ImportError("Could not import module for %r" % qualified_method) + + trace_method(base_module_guess, method_name) + else: + # Using updated syntax, no need to try to import + for module, method_name in _parse_trace_methods(raw_dd_trace_methods): + trace_method(module, method_name) def trace_method(module, method_name): From fd4b52db2f06087def1ee7ab0cc8796ca8b95e0b Mon Sep 17 00:00:00 2001 From: erikayasuda Date: Fri, 16 Feb 2024 10:04:50 -0500 Subject: [PATCH 02/22] linting --- ddtrace/internal/tracemethods.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/ddtrace/internal/tracemethods.py b/ddtrace/internal/tracemethods.py index f556160eda5..45ab0937904 100644 --- a/ddtrace/internal/tracemethods.py +++ b/ddtrace/internal/tracemethods.py @@ -1,9 +1,10 @@ from typing import List +from typing import Tuple import wrapt -def _parse_trace_methods(raw_dd_trace_methods: str) -> List[(str, str)]: +def _parse_trace_methods(raw_dd_trace_methods: str) -> List[Tuple[str, str]]: """Return a list of the module,methodname tuples to trace based on the specification of DD_TRACE_METHODS. @@ -11,7 +12,7 @@ def _parse_trace_methods(raw_dd_trace_methods: str) -> List[(str, str)]: The square bracket notation will be deprecated in favor of this new syntax Note that support for wildcard methods ([*]) is not implemented. - """ + """ dd_trace_methods = [] for qualified_methods in raw_dd_trace_methods.split(";"): # Validate that methods are specified @@ -48,7 +49,7 @@ def _parse_trace_methods(raw_dd_trace_methods: str) -> List[(str, str)]: ) ) dd_trace_methods.append((qualified_method_prefix, method)) - return dd_trace_methods + return dd_trace_methods def _parse_legacy_trace_methods(raw_dd_trace_methods: str) -> List[str]: @@ -124,8 +125,8 @@ def _install_trace_methods(raw_dd_trace_methods: str) -> None: trace_method(base_module_guess, method_name) else: # Using updated syntax, no need to try to import - for module, method_name in _parse_trace_methods(raw_dd_trace_methods): - trace_method(module, method_name) + for module_name, method_name in _parse_trace_methods(raw_dd_trace_methods): + trace_method(module_name, method_name) def trace_method(module, method_name): From 4eedc10c15cfa95f48bc0d6e8a59dc9e707bcda5 Mon Sep 17 00:00:00 2001 From: erikayasuda Date: Fri, 16 Feb 2024 12:05:04 -0500 Subject: [PATCH 03/22] added tests --- riotfile.py | 1 + tests/contrib/django/django_app/settings.py | 8 +++++ tests/contrib/django/test_django_snapshots.py | 34 +++++++++++++------ 3 files changed, 33 insertions(+), 10 deletions(-) diff --git a/riotfile.py b/riotfile.py index f5169712e20..6568360d5fc 100644 --- a/riotfile.py +++ b/riotfile.py @@ -784,6 +784,7 @@ def select_pys(min_version=MIN_PYTHON_VERSION, max_version=MAX_PYTHON_VERSION): "pylibmc": latest, "python-memcached": latest, "pytest-randomly": latest, + "django-q": latest }, env={ "DD_IAST_REQUEST_SAMPLING": "100", # Override default 30% to analyze all IAST requests diff --git a/tests/contrib/django/django_app/settings.py b/tests/contrib/django/django_app/settings.py index af92d01fff3..1d0dae6acbe 100644 --- a/tests/contrib/django/django_app/settings.py +++ b/tests/contrib/django/django_app/settings.py @@ -95,4 +95,12 @@ "django.contrib.auth", "django.contrib.contenttypes", "django.contrib.sessions", + "django_q", ] + +Q_CLUSTER = { + 'name': 'DjangORM', + 'timeout': 60*30, + 'retry': 10000000000, + 'max_attempts': 1, # Dont re-attempt tasks +} diff --git a/tests/contrib/django/test_django_snapshots.py b/tests/contrib/django/test_django_snapshots.py index 3af89a84dbd..787b22aa586 100644 --- a/tests/contrib/django/test_django_snapshots.py +++ b/tests/contrib/django/test_django_snapshots.py @@ -19,7 +19,7 @@ @contextmanager -def daphne_client(django_asgi, additional_env=None): +def daphne_client(django_asgi, additional_env=None, django_settings_module="tests.contrib.django.django_app.settings"): """Runs a django app hosted with a daphne webserver in a subprocess and returns a client which can be used to query it. @@ -34,7 +34,7 @@ def daphne_client(django_asgi, additional_env=None): assert "_DD_TRACE_WRITER_ADDITIONAL_HEADERS" in env, "Client fixture needs test token in headers" env.update( { - "DJANGO_SETTINGS_MODULE": "tests.contrib.django.django_app.settings", + "DJANGO_SETTINGS_MODULE": django_settings_module, } ) @@ -55,7 +55,7 @@ def daphne_client(django_asgi, additional_env=None): client.wait() try: - yield client + yield (client, proc) finally: resp = client.get_ignored("/shutdown-tracer") assert resp.status_code == 200 @@ -234,7 +234,7 @@ def test_psycopg3_query_default(client, snapshot_context, psycopg3_patched): ) @pytest.mark.parametrize("django_asgi", ["application", "channels_application"]) def test_asgi_200(django_asgi): - with daphne_client(django_asgi) as client: + with daphne_client(django_asgi) as (client, _): resp = client.get("/") assert resp.status_code == 200 assert resp.content == b"Hello, test app." @@ -246,7 +246,7 @@ def test_asgi_200(django_asgi): def test_asgi_200_simple_app(): # The path simple-asgi-app/ routes to an ASGI Application that is not traced # This test should generate an empty snapshot - with daphne_client("channels_application") as client: + with daphne_client("channels_application") as (client, _): resp = client.get("/simple-asgi-app/") assert resp.status_code == 200 assert resp.content == b"Hello World. It's me simple asgi app" @@ -255,7 +255,7 @@ def test_asgi_200_simple_app(): @pytest.mark.skipif(django.VERSION < (3, 0, 0), reason="ASGI not supported in django<3") @snapshot(ignores=SNAPSHOT_IGNORES + ["meta.http.useragent"]) def test_asgi_200_traced_simple_app(): - with daphne_client("channels_application") as client: + with daphne_client("channels_application") as (client, _): resp = client.get("/traced-simple-asgi-app/") assert resp.status_code == 200 assert resp.content == b"Hello World. It's me simple asgi app" @@ -269,7 +269,7 @@ def test_asgi_200_traced_simple_app(): }, ) def test_asgi_500(): - with daphne_client("application") as client: + with daphne_client("application") as (client, _): resp = client.get("/error-500/") assert resp.status_code == 500 @@ -283,7 +283,7 @@ def test_asgi_500(): ) def test_templates_enabled(): """Default behavior to compare with disabled variant""" - with daphne_client("application") as client: + with daphne_client("application") as (client, _): resp = client.get("/template-view/") assert resp.status_code == 200 assert resp.content == b"some content\n" @@ -298,7 +298,7 @@ def test_templates_enabled(): ) def test_templates_disabled(): """Template instrumentation disabled""" - with daphne_client("application", additional_env={"DD_DJANGO_INSTRUMENT_TEMPLATES": "false"}) as client: + with daphne_client("application", additional_env={"DD_DJANGO_INSTRUMENT_TEMPLATES": "false"}) as (client, _): resp = client.get("/template-view/") assert resp.status_code == 200 assert resp.content == b"some content\n" @@ -313,6 +313,20 @@ def test_streamed_file(client): @pytest.mark.skipif(django.VERSION > (3, 0, 0), reason="ASGI not supported in django<3") def test_django_resource_handler(): # regression test for: DataDog/dd-trace-py/issues/5711 - with daphne_client("application", additional_env={"DD_DJANGO_USE_HANDLER_RESOURCE_FORMAT": "true"}) as client: + with daphne_client("application", additional_env={"DD_DJANGO_USE_HANDLER_RESOURCE_FORMAT": "true"}) as (client, _): # Request a class based view assert client.get("simple/").status_code == 200 + +@pytest.mark.parametrize( + "dd_trace_methods,error_expected", + [ + ("django_q.tasks[async_task]", True), # legacy syntax + ("django_q.tasks:async_task", False) # updated syntax + ] +) +def test_djangoq_dd_trace_methods(dd_trace_methods, error_expected): + with daphne_client("application", additional_env={"DD_TRACE_METHODS": dd_trace_methods, "_DD_TRACE_WRITER_ADDITIONAL_HEADERS": ""}, django_settings_module="tests.contrib.django.django_app.settings") as (client, proc): + assert client.get("simple/").status_code == 200 + + _, stderr = proc.communicate(timeout=5) + assert (b"error configuring Datadog tracing" in stderr) == error_expected \ No newline at end of file From d535dfec57fb2e33b7ecc9ee9b08d11eaf69bd8d Mon Sep 17 00:00:00 2001 From: erikayasuda Date: Fri, 16 Feb 2024 12:06:05 -0500 Subject: [PATCH 04/22] linting --- riotfile.py | 2 +- tests/contrib/django/django_app/settings.py | 8 ++++---- tests/contrib/django/test_django_snapshots.py | 18 ++++++++++-------- 3 files changed, 15 insertions(+), 13 deletions(-) diff --git a/riotfile.py b/riotfile.py index 6568360d5fc..b207c0300ae 100644 --- a/riotfile.py +++ b/riotfile.py @@ -784,7 +784,7 @@ def select_pys(min_version=MIN_PYTHON_VERSION, max_version=MAX_PYTHON_VERSION): "pylibmc": latest, "python-memcached": latest, "pytest-randomly": latest, - "django-q": latest + "django-q": latest, }, env={ "DD_IAST_REQUEST_SAMPLING": "100", # Override default 30% to analyze all IAST requests diff --git a/tests/contrib/django/django_app/settings.py b/tests/contrib/django/django_app/settings.py index 1d0dae6acbe..5bd53d693e2 100644 --- a/tests/contrib/django/django_app/settings.py +++ b/tests/contrib/django/django_app/settings.py @@ -99,8 +99,8 @@ ] Q_CLUSTER = { - 'name': 'DjangORM', - 'timeout': 60*30, - 'retry': 10000000000, - 'max_attempts': 1, # Dont re-attempt tasks + "name": "DjangORM", + "timeout": 60 * 30, + "retry": 10000000000, + "max_attempts": 1, # Dont re-attempt tasks } diff --git a/tests/contrib/django/test_django_snapshots.py b/tests/contrib/django/test_django_snapshots.py index 787b22aa586..ea605f53a85 100644 --- a/tests/contrib/django/test_django_snapshots.py +++ b/tests/contrib/django/test_django_snapshots.py @@ -317,16 +317,18 @@ def test_django_resource_handler(): # Request a class based view assert client.get("simple/").status_code == 200 + @pytest.mark.parametrize( - "dd_trace_methods,error_expected", - [ - ("django_q.tasks[async_task]", True), # legacy syntax - ("django_q.tasks:async_task", False) # updated syntax - ] + "dd_trace_methods,error_expected", + [("django_q.tasks[async_task]", True), ("django_q.tasks:async_task", False)], # legacy syntax # updated syntax ) def test_djangoq_dd_trace_methods(dd_trace_methods, error_expected): - with daphne_client("application", additional_env={"DD_TRACE_METHODS": dd_trace_methods, "_DD_TRACE_WRITER_ADDITIONAL_HEADERS": ""}, django_settings_module="tests.contrib.django.django_app.settings") as (client, proc): + with daphne_client( + "application", + additional_env={"DD_TRACE_METHODS": dd_trace_methods, "_DD_TRACE_WRITER_ADDITIONAL_HEADERS": ""}, + django_settings_module="tests.contrib.django.django_app.settings", + ) as (client, proc): assert client.get("simple/").status_code == 200 - + _, stderr = proc.communicate(timeout=5) - assert (b"error configuring Datadog tracing" in stderr) == error_expected \ No newline at end of file + assert (b"error configuring Datadog tracing" in stderr) == error_expected From deff833ecc7d844c0b1f6ac19587a51a40a17570 Mon Sep 17 00:00:00 2001 From: erikayasuda Date: Fri, 16 Feb 2024 12:41:51 -0500 Subject: [PATCH 05/22] moved test to more relevant test file --- tests/contrib/django/test_django.py | 16 ++++++++++++++++ tests/contrib/django/test_django_snapshots.py | 16 ---------------- 2 files changed, 16 insertions(+), 16 deletions(-) diff --git a/tests/contrib/django/test_django.py b/tests/contrib/django/test_django.py index f44935717f8..172d7ed8376 100644 --- a/tests/contrib/django/test_django.py +++ b/tests/contrib/django/test_django.py @@ -36,6 +36,7 @@ from ddtrace.propagation.http import HTTP_HEADER_SAMPLING_PRIORITY from ddtrace.propagation.http import HTTP_HEADER_TRACE_ID from ddtrace.vendor import wrapt +from tests.contrib.django.test_django_snapshots import daphne_client from tests.opentracer.utils import init_tracer from tests.utils import assert_dict_issuperset from tests.utils import flaky @@ -2424,3 +2425,18 @@ def test_django_base_handler_failure(client, test_spans): pass # We expect an error root = test_spans.get_root_span() assert root.resource == "GET ^$" + +@pytest.mark.parametrize( + "dd_trace_methods,error_expected", + [("django_q.tasks[async_task]", True), ("django_q.tasks:async_task", False)], # legacy syntax, updated syntax +) +def test_djangoq_dd_trace_methods(dd_trace_methods, error_expected): + with daphne_client( + "application", + additional_env={"DD_TRACE_METHODS": dd_trace_methods, "_DD_TRACE_WRITER_ADDITIONAL_HEADERS": ""}, + django_settings_module="tests.contrib.django.django_app.settings", + ) as (client, proc): + assert client.get("simple/").status_code == 200 + + _, stderr = proc.communicate(timeout=5) + assert (b"error configuring Datadog tracing" in stderr) == error_expected \ No newline at end of file diff --git a/tests/contrib/django/test_django_snapshots.py b/tests/contrib/django/test_django_snapshots.py index ea605f53a85..1b2f6974a91 100644 --- a/tests/contrib/django/test_django_snapshots.py +++ b/tests/contrib/django/test_django_snapshots.py @@ -316,19 +316,3 @@ def test_django_resource_handler(): with daphne_client("application", additional_env={"DD_DJANGO_USE_HANDLER_RESOURCE_FORMAT": "true"}) as (client, _): # Request a class based view assert client.get("simple/").status_code == 200 - - -@pytest.mark.parametrize( - "dd_trace_methods,error_expected", - [("django_q.tasks[async_task]", True), ("django_q.tasks:async_task", False)], # legacy syntax # updated syntax -) -def test_djangoq_dd_trace_methods(dd_trace_methods, error_expected): - with daphne_client( - "application", - additional_env={"DD_TRACE_METHODS": dd_trace_methods, "_DD_TRACE_WRITER_ADDITIONAL_HEADERS": ""}, - django_settings_module="tests.contrib.django.django_app.settings", - ) as (client, proc): - assert client.get("simple/").status_code == 200 - - _, stderr = proc.communicate(timeout=5) - assert (b"error configuring Datadog tracing" in stderr) == error_expected From e8d35555ae368a27a5f7495768bb418d17da7ff3 Mon Sep 17 00:00:00 2001 From: erikayasuda Date: Fri, 16 Feb 2024 12:46:02 -0500 Subject: [PATCH 06/22] comment on legacy method to be deleted --- ddtrace/internal/tracemethods.py | 3 +++ tests/contrib/django/test_django.py | 3 ++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/ddtrace/internal/tracemethods.py b/ddtrace/internal/tracemethods.py index 45ab0937904..c7d05efb86a 100644 --- a/ddtrace/internal/tracemethods.py +++ b/ddtrace/internal/tracemethods.py @@ -53,6 +53,9 @@ def _parse_trace_methods(raw_dd_trace_methods: str) -> List[Tuple[str, str]]: def _parse_legacy_trace_methods(raw_dd_trace_methods: str) -> List[str]: + """ + TODO: This method can be deleted once the legacy syntax is officially deprecated + """ dd_trace_methods = [] for qualified_methods in raw_dd_trace_methods.split(";"): # Validate that methods are specified diff --git a/tests/contrib/django/test_django.py b/tests/contrib/django/test_django.py index 172d7ed8376..852afcb0461 100644 --- a/tests/contrib/django/test_django.py +++ b/tests/contrib/django/test_django.py @@ -2426,6 +2426,7 @@ def test_django_base_handler_failure(client, test_spans): root = test_spans.get_root_span() assert root.resource == "GET ^$" + @pytest.mark.parametrize( "dd_trace_methods,error_expected", [("django_q.tasks[async_task]", True), ("django_q.tasks:async_task", False)], # legacy syntax, updated syntax @@ -2439,4 +2440,4 @@ def test_djangoq_dd_trace_methods(dd_trace_methods, error_expected): assert client.get("simple/").status_code == 200 _, stderr = proc.communicate(timeout=5) - assert (b"error configuring Datadog tracing" in stderr) == error_expected \ No newline at end of file + assert (b"error configuring Datadog tracing" in stderr) == error_expected From 5c040418ebee583bfda42c98aa47f83036c84c55 Mon Sep 17 00:00:00 2001 From: erikayasuda Date: Fri, 16 Feb 2024 12:55:57 -0500 Subject: [PATCH 07/22] added deprecation warning --- ddtrace/internal/tracemethods.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/ddtrace/internal/tracemethods.py b/ddtrace/internal/tracemethods.py index c7d05efb86a..dfbba3264e2 100644 --- a/ddtrace/internal/tracemethods.py +++ b/ddtrace/internal/tracemethods.py @@ -3,6 +3,9 @@ import wrapt +from ddtrace.internal.utils.deprecations import DDTraceDeprecationWarning +from ddtrace.vendor.debtcollector import deprecate + def _parse_trace_methods(raw_dd_trace_methods: str) -> List[Tuple[str, str]]: """Return a list of the module,methodname tuples to trace based on the @@ -104,6 +107,12 @@ def _parse_legacy_trace_methods(raw_dd_trace_methods: str) -> List[str]: def _install_trace_methods(raw_dd_trace_methods: str) -> None: """Install tracing on the given methods.""" if "[" in raw_dd_trace_methods: + deprecate( + "Using DD_TRACE_METHODS with the square bracket notation is deprecated", + message="Please use DD_TRACE_METHODS with the new ':' syntax instead", + removal_version="3.0.0", + category=DDTraceDeprecationWarning, + ) # Using legacy syntax for qualified_method in _parse_legacy_trace_methods(raw_dd_trace_methods): # We don't know if the method is a class method or a module method, so we need to assume it's a module From 3a3488b3c904f3aae67d9a11f158f2e7ca5d7524 Mon Sep 17 00:00:00 2001 From: erikayasuda Date: Fri, 16 Feb 2024 12:57:47 -0500 Subject: [PATCH 08/22] fixed some typos --- ddtrace/internal/tracemethods.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ddtrace/internal/tracemethods.py b/ddtrace/internal/tracemethods.py index dfbba3264e2..b6cab548eb9 100644 --- a/ddtrace/internal/tracemethods.py +++ b/ddtrace/internal/tracemethods.py @@ -108,8 +108,8 @@ def _install_trace_methods(raw_dd_trace_methods: str) -> None: """Install tracing on the given methods.""" if "[" in raw_dd_trace_methods: deprecate( - "Using DD_TRACE_METHODS with the square bracket notation is deprecated", - message="Please use DD_TRACE_METHODS with the new ':' syntax instead", + "Using DD_TRACE_METHODS with the '[]' notation is deprecated", + message="Please use DD_TRACE_METHODS with the new ':' notation instead", removal_version="3.0.0", category=DDTraceDeprecationWarning, ) From 6feac53e9cd20a8a0227d0aa33ec2c6b02875ff6 Mon Sep 17 00:00:00 2001 From: erikayasuda Date: Fri, 16 Feb 2024 13:23:05 -0500 Subject: [PATCH 09/22] updated public docs --- docs/configuration.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/configuration.rst b/docs/configuration.rst index 9047088595e..0cb716b23b2 100644 --- a/docs/configuration.rst +++ b/docs/configuration.rst @@ -465,7 +465,7 @@ The following environment variables for the tracer are supported: type: String default: "" description: | - Specify methods to trace. For example: ``mod.submod[method1,method2];mod.submod.Class[method1]``. + Specify methods to trace. For example: ``mod.submod:method1,method2;mod.submod:Class.method1``. Note that this setting is only compatible with ``ddtrace-run``, and that it doesn't work for methods implemented by libraries for which there's an integration in ``ddtrace/contrib``. version_added: From d473bebbe6ed3c89bab49b053c06143803644078 Mon Sep 17 00:00:00 2001 From: erikayasuda Date: Fri, 16 Feb 2024 13:48:01 -0500 Subject: [PATCH 10/22] added release note --- .../notes/fix-dd-trace-methods-2c1b4af30a7bf3ef.yaml | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 releasenotes/notes/fix-dd-trace-methods-2c1b4af30a7bf3ef.yaml diff --git a/releasenotes/notes/fix-dd-trace-methods-2c1b4af30a7bf3ef.yaml b/releasenotes/notes/fix-dd-trace-methods-2c1b4af30a7bf3ef.yaml new file mode 100644 index 00000000000..3ad73e52de9 --- /dev/null +++ b/releasenotes/notes/fix-dd-trace-methods-2c1b4af30a7bf3ef.yaml @@ -0,0 +1,5 @@ +--- +deprecations: + - | + tracing: Using [] for DD_TRACE_METHODS ("mymod.mysubmod.myclass[myfunc,otherfunc];...") is deprecated and will be removed in 3.0.0. + You can use the new notation with : instead ("mymod.mysubmod:myclass.myfunc,myclass.otherfunc;...") \ No newline at end of file From 47520de2a70c298a047541b14a32ca78f891cf5e Mon Sep 17 00:00:00 2001 From: erikayasuda Date: Fri, 16 Feb 2024 14:46:11 -0500 Subject: [PATCH 11/22] generated missing req files --- .riot/requirements/164c9d2.txt | 64 ++++++++++++++++++++++++++++++++ .riot/requirements/1692fb0.txt | 67 ++++++++++++++++++++++++++++++++++ .riot/requirements/7f107f8.txt | 67 ++++++++++++++++++++++++++++++++++ 3 files changed, 198 insertions(+) create mode 100644 .riot/requirements/164c9d2.txt create mode 100644 .riot/requirements/1692fb0.txt create mode 100644 .riot/requirements/7f107f8.txt diff --git a/.riot/requirements/164c9d2.txt b/.riot/requirements/164c9d2.txt new file mode 100644 index 00000000000..55284778172 --- /dev/null +++ b/.riot/requirements/164c9d2.txt @@ -0,0 +1,64 @@ +# +# This file is autogenerated by pip-compile with Python 3.11 +# by the following command: +# +# pip-compile --no-annotate .riot/requirements/164c9d2.in +# +arrow==1.3.0 +asgiref==3.7.2 +attrs==23.2.0 +autobahn==23.6.2 +automat==22.10.0 +blessed==1.20.0 +certifi==2024.2.2 +cffi==1.16.0 +channels==4.0.0 +charset-normalizer==3.3.2 +constantly==23.10.4 +coverage[toml]==7.4.1 +cryptography==42.0.3 +daphne==4.1.0 +django==4.2.10 +django-picklefield==3.1 +django-pylibmc==0.6.1 +django-q==1.3.6 +django-redis==4.5.0 +hyperlink==21.0.0 +hypothesis==6.45.0 +idna==3.6 +incremental==22.10.0 +iniconfig==2.0.0 +mock==5.1.0 +opentracing==2.4.0 +packaging==23.2 +pluggy==1.4.0 +psycopg==3.1.18 +psycopg2-binary==2.9.9 +pyasn1==0.5.1 +pyasn1-modules==0.3.0 +pycparser==2.21 +pylibmc==1.6.3 +pyopenssl==24.0.0 +pytest==8.0.0 +pytest-cov==4.1.0 +pytest-django==3.10.0 +pytest-mock==3.12.0 +pytest-randomly==3.15.0 +python-dateutil==2.8.2 +python-memcached==1.62 +redis==2.10.6 +requests==2.31.0 +service-identity==24.1.0 +six==1.16.0 +sortedcontainers==2.4.0 +sqlparse==0.4.4 +twisted[tls]==23.10.0 +txaio==23.1.1 +types-python-dateutil==2.8.19.20240106 +typing-extensions==4.9.0 +urllib3==2.2.0 +wcwidth==0.2.13 +zope-interface==6.2 + +# The following packages are considered to be unsafe in a requirements file: +# setuptools diff --git a/.riot/requirements/1692fb0.txt b/.riot/requirements/1692fb0.txt new file mode 100644 index 00000000000..2e83cc45a4d --- /dev/null +++ b/.riot/requirements/1692fb0.txt @@ -0,0 +1,67 @@ +# +# This file is autogenerated by pip-compile with Python 3.7 +# by the following command: +# +# pip-compile --config=pyproject.toml --no-annotate --resolver=backtracking .riot/requirements/1692fb0.in +# +arrow==1.2.3 +asgiref==3.7.2 +attrs==23.2.0 +autobahn==23.1.2 +automat==22.10.0 +blessed==1.20.0 +certifi==2024.2.2 +cffi==1.15.1 +channels==4.0.0 +charset-normalizer==3.3.2 +constantly==15.1.0 +coverage[toml]==7.2.7 +cryptography==42.0.3 +daphne==4.0.0 +django==3.2.24 +django-picklefield==3.1 +django-pylibmc==0.6.1 +django-q==1.3.6 +django-redis==4.5.0 +exceptiongroup==1.2.0 +hyperlink==21.0.0 +hypothesis==6.45.0 +idna==3.6 +importlib-metadata==6.7.0 +incremental==22.10.0 +iniconfig==2.0.0 +mock==5.1.0 +opentracing==2.4.0 +packaging==23.2 +pluggy==1.2.0 +psycopg2-binary==2.9.9 +pyasn1==0.5.1 +pyasn1-modules==0.3.0 +pycparser==2.21 +pylibmc==1.6.3 +pyopenssl==24.0.0 +pytest==7.4.4 +pytest-cov==4.1.0 +pytest-django==3.10.0 +pytest-mock==3.11.1 +pytest-randomly==3.12.0 +python-dateutil==2.8.2 +python-memcached==1.62 +pytz==2024.1 +redis==2.10.6 +requests==2.31.0 +service-identity==21.1.0 +six==1.16.0 +sortedcontainers==2.4.0 +sqlparse==0.4.4 +tomli==2.0.1 +twisted[tls]==23.8.0 +txaio==23.1.1 +typing-extensions==4.7.1 +urllib3==2.0.7 +wcwidth==0.2.13 +zipp==3.15.0 +zope-interface==6.2 + +# The following packages are considered to be unsafe in a requirements file: +# setuptools diff --git a/.riot/requirements/7f107f8.txt b/.riot/requirements/7f107f8.txt new file mode 100644 index 00000000000..0b2eba9cada --- /dev/null +++ b/.riot/requirements/7f107f8.txt @@ -0,0 +1,67 @@ +# +# This file is autogenerated by pip-compile with Python 3.7 +# by the following command: +# +# pip-compile --config=pyproject.toml --no-annotate --resolver=backtracking .riot/requirements/7f107f8.in +# +arrow==1.2.3 +asgiref==3.7.2 +attrs==23.2.0 +autobahn==23.1.2 +automat==22.10.0 +blessed==1.20.0 +certifi==2024.2.2 +cffi==1.15.1 +channels==3.0.5 +charset-normalizer==3.3.2 +constantly==15.1.0 +coverage[toml]==7.2.7 +cryptography==42.0.3 +daphne==3.0.2 +django==3.2.24 +django-picklefield==3.1 +django-pylibmc==0.6.1 +django-q==1.3.6 +django-redis==4.5.0 +exceptiongroup==1.2.0 +hyperlink==21.0.0 +hypothesis==6.45.0 +idna==3.6 +importlib-metadata==6.7.0 +incremental==22.10.0 +iniconfig==2.0.0 +mock==5.1.0 +opentracing==2.4.0 +packaging==23.2 +pluggy==1.2.0 +psycopg2-binary==2.9.9 +pyasn1==0.5.1 +pyasn1-modules==0.3.0 +pycparser==2.21 +pylibmc==1.6.3 +pyopenssl==24.0.0 +pytest==7.4.4 +pytest-cov==4.1.0 +pytest-django==3.10.0 +pytest-mock==3.11.1 +pytest-randomly==3.12.0 +python-dateutil==2.8.2 +python-memcached==1.62 +pytz==2024.1 +redis==2.10.6 +requests==2.31.0 +service-identity==21.1.0 +six==1.16.0 +sortedcontainers==2.4.0 +sqlparse==0.4.4 +tomli==2.0.1 +twisted[tls]==23.8.0 +txaio==23.1.1 +typing-extensions==4.7.1 +urllib3==2.0.7 +wcwidth==0.2.13 +zipp==3.15.0 +zope-interface==6.2 + +# The following packages are considered to be unsafe in a requirements file: +# setuptools From 907f018168e0a824d5f4766a989c9db25538b28f Mon Sep 17 00:00:00 2001 From: erikayasuda Date: Fri, 16 Feb 2024 15:37:45 -0500 Subject: [PATCH 12/22] generated missing req files --- .riot/requirements/19126e6.txt | 64 +++++++++++++++++++++++++++++++ .riot/requirements/1bc3637.txt | 67 +++++++++++++++++++++++++++++++++ .riot/requirements/204183a.txt | 68 +++++++++++++++++++++++++++++++++ .riot/requirements/c126367.txt | 68 +++++++++++++++++++++++++++++++++ .riot/requirements/f3e34f7.txt | 69 ++++++++++++++++++++++++++++++++++ 5 files changed, 336 insertions(+) create mode 100644 .riot/requirements/19126e6.txt create mode 100644 .riot/requirements/1bc3637.txt create mode 100644 .riot/requirements/204183a.txt create mode 100644 .riot/requirements/c126367.txt create mode 100644 .riot/requirements/f3e34f7.txt diff --git a/.riot/requirements/19126e6.txt b/.riot/requirements/19126e6.txt new file mode 100644 index 00000000000..dd1588c6f57 --- /dev/null +++ b/.riot/requirements/19126e6.txt @@ -0,0 +1,64 @@ +# +# This file is autogenerated by pip-compile with Python 3.12 +# by the following command: +# +# pip-compile --no-annotate .riot/requirements/19126e6.in +# +arrow==1.3.0 +asgiref==3.7.2 +attrs==23.2.0 +autobahn==23.6.2 +automat==22.10.0 +blessed==1.20.0 +certifi==2024.2.2 +cffi==1.16.0 +channels==4.0.0 +charset-normalizer==3.3.2 +constantly==23.10.4 +coverage[toml]==7.4.1 +cryptography==42.0.3 +daphne==4.1.0 +django==4.2.10 +django-picklefield==3.1 +django-pylibmc==0.6.1 +django-q==1.3.6 +django-redis==4.5.0 +hyperlink==21.0.0 +hypothesis==6.45.0 +idna==3.6 +incremental==22.10.0 +iniconfig==2.0.0 +mock==5.1.0 +opentracing==2.4.0 +packaging==23.2 +pluggy==1.4.0 +psycopg==3.1.18 +psycopg2-binary==2.9.9 +pyasn1==0.5.1 +pyasn1-modules==0.3.0 +pycparser==2.21 +pylibmc==1.6.3 +pyopenssl==24.0.0 +pytest==8.0.0 +pytest-cov==4.1.0 +pytest-django==3.10.0 +pytest-mock==3.12.0 +pytest-randomly==3.15.0 +python-dateutil==2.8.2 +python-memcached==1.62 +redis==2.10.6 +requests==2.31.0 +service-identity==24.1.0 +six==1.16.0 +sortedcontainers==2.4.0 +sqlparse==0.4.4 +twisted[tls]==23.10.0 +txaio==23.1.1 +types-python-dateutil==2.8.19.20240106 +typing-extensions==4.9.0 +urllib3==2.2.0 +wcwidth==0.2.13 +zope-interface==6.2 + +# The following packages are considered to be unsafe in a requirements file: +# setuptools diff --git a/.riot/requirements/1bc3637.txt b/.riot/requirements/1bc3637.txt new file mode 100644 index 00000000000..7e9dbb44bfc --- /dev/null +++ b/.riot/requirements/1bc3637.txt @@ -0,0 +1,67 @@ +# +# This file is autogenerated by pip-compile with Python 3.9 +# by the following command: +# +# pip-compile --no-annotate .riot/requirements/1bc3637.in +# +arrow==1.3.0 +asgiref==3.7.2 +attrs==23.2.0 +autobahn==23.6.2 +automat==22.10.0 +blessed==1.20.0 +certifi==2024.2.2 +cffi==1.16.0 +channels==4.0.0 +charset-normalizer==3.3.2 +constantly==23.10.4 +coverage[toml]==7.4.1 +cryptography==42.0.3 +daphne==4.1.0 +django==4.2.10 +django-picklefield==3.1 +django-pylibmc==0.6.1 +django-q==1.3.6 +django-redis==4.5.0 +exceptiongroup==1.2.0 +hyperlink==21.0.0 +hypothesis==6.45.0 +idna==3.6 +importlib-metadata==7.0.1 +incremental==22.10.0 +iniconfig==2.0.0 +mock==5.1.0 +opentracing==2.4.0 +packaging==23.2 +pluggy==1.4.0 +psycopg2-binary==2.9.9 +pyasn1==0.5.1 +pyasn1-modules==0.3.0 +pycparser==2.21 +pylibmc==1.6.3 +pyopenssl==24.0.0 +pytest==8.0.0 +pytest-cov==4.1.0 +pytest-django==3.10.0 +pytest-mock==3.12.0 +pytest-randomly==3.15.0 +python-dateutil==2.8.2 +python-memcached==1.62 +redis==2.10.6 +requests==2.31.0 +service-identity==24.1.0 +six==1.16.0 +sortedcontainers==2.4.0 +sqlparse==0.4.4 +tomli==2.0.1 +twisted[tls]==23.10.0 +txaio==23.1.1 +types-python-dateutil==2.8.19.20240106 +typing-extensions==4.9.0 +urllib3==2.2.0 +wcwidth==0.2.13 +zipp==3.17.0 +zope-interface==6.2 + +# The following packages are considered to be unsafe in a requirements file: +# setuptools diff --git a/.riot/requirements/204183a.txt b/.riot/requirements/204183a.txt new file mode 100644 index 00000000000..7cd02b31dfa --- /dev/null +++ b/.riot/requirements/204183a.txt @@ -0,0 +1,68 @@ +# +# This file is autogenerated by pip-compile with Python 3.9 +# by the following command: +# +# pip-compile --no-annotate .riot/requirements/204183a.in +# +arrow==1.3.0 +asgiref==3.7.2 +attrs==23.2.0 +autobahn==23.6.2 +automat==22.10.0 +blessed==1.20.0 +certifi==2024.2.2 +cffi==1.16.0 +channels==4.0.0 +charset-normalizer==3.3.2 +constantly==23.10.4 +coverage[toml]==7.4.1 +cryptography==42.0.3 +daphne==4.1.0 +django==4.2.10 +django-picklefield==3.1 +django-pylibmc==0.6.1 +django-q==1.3.6 +django-redis==4.5.0 +exceptiongroup==1.2.0 +hyperlink==21.0.0 +hypothesis==6.45.0 +idna==3.6 +importlib-metadata==7.0.1 +incremental==22.10.0 +iniconfig==2.0.0 +mock==5.1.0 +opentracing==2.4.0 +packaging==23.2 +pluggy==1.4.0 +psycopg==3.1.18 +psycopg2-binary==2.9.9 +pyasn1==0.5.1 +pyasn1-modules==0.3.0 +pycparser==2.21 +pylibmc==1.6.3 +pyopenssl==24.0.0 +pytest==8.0.0 +pytest-cov==4.1.0 +pytest-django==3.10.0 +pytest-mock==3.12.0 +pytest-randomly==3.15.0 +python-dateutil==2.8.2 +python-memcached==1.62 +redis==2.10.6 +requests==2.31.0 +service-identity==24.1.0 +six==1.16.0 +sortedcontainers==2.4.0 +sqlparse==0.4.4 +tomli==2.0.1 +twisted[tls]==23.10.0 +txaio==23.1.1 +types-python-dateutil==2.8.19.20240106 +typing-extensions==4.9.0 +urllib3==2.2.0 +wcwidth==0.2.13 +zipp==3.17.0 +zope-interface==6.2 + +# The following packages are considered to be unsafe in a requirements file: +# setuptools diff --git a/.riot/requirements/c126367.txt b/.riot/requirements/c126367.txt new file mode 100644 index 00000000000..4b8ed876505 --- /dev/null +++ b/.riot/requirements/c126367.txt @@ -0,0 +1,68 @@ +# +# This file is autogenerated by pip-compile with Python 3.8 +# by the following command: +# +# pip-compile --no-annotate .riot/requirements/c126367.in +# +arrow==1.3.0 +asgiref==3.7.2 +attrs==23.2.0 +autobahn==23.1.2 +automat==22.10.0 +backports-zoneinfo==0.2.1 +blessed==1.20.0 +certifi==2024.2.2 +cffi==1.16.0 +channels==4.0.0 +charset-normalizer==3.3.2 +constantly==23.10.4 +coverage[toml]==7.4.1 +cryptography==42.0.3 +daphne==4.1.0 +django==4.2.10 +django-picklefield==3.1 +django-pylibmc==0.6.1 +django-q==1.3.6 +django-redis==4.5.0 +exceptiongroup==1.2.0 +hyperlink==21.0.0 +hypothesis==6.45.0 +idna==3.6 +importlib-metadata==7.0.1 +incremental==22.10.0 +iniconfig==2.0.0 +mock==5.1.0 +opentracing==2.4.0 +packaging==23.2 +pluggy==1.4.0 +psycopg2-binary==2.9.9 +pyasn1==0.5.1 +pyasn1-modules==0.3.0 +pycparser==2.21 +pylibmc==1.6.3 +pyopenssl==24.0.0 +pytest==8.0.0 +pytest-cov==4.1.0 +pytest-django==3.10.0 +pytest-mock==3.12.0 +pytest-randomly==3.15.0 +python-dateutil==2.8.2 +python-memcached==1.62 +redis==2.10.6 +requests==2.31.0 +service-identity==24.1.0 +six==1.16.0 +sortedcontainers==2.4.0 +sqlparse==0.4.4 +tomli==2.0.1 +twisted[tls]==23.10.0 +txaio==23.1.1 +types-python-dateutil==2.8.19.20240106 +typing-extensions==4.9.0 +urllib3==2.2.0 +wcwidth==0.2.13 +zipp==3.17.0 +zope-interface==6.2 + +# The following packages are considered to be unsafe in a requirements file: +# setuptools diff --git a/.riot/requirements/f3e34f7.txt b/.riot/requirements/f3e34f7.txt new file mode 100644 index 00000000000..ca3ec955011 --- /dev/null +++ b/.riot/requirements/f3e34f7.txt @@ -0,0 +1,69 @@ +# +# This file is autogenerated by pip-compile with Python 3.8 +# by the following command: +# +# pip-compile --no-annotate .riot/requirements/f3e34f7.in +# +arrow==1.3.0 +asgiref==3.7.2 +attrs==23.2.0 +autobahn==23.1.2 +automat==22.10.0 +backports-zoneinfo==0.2.1 +blessed==1.20.0 +certifi==2024.2.2 +cffi==1.16.0 +channels==4.0.0 +charset-normalizer==3.3.2 +constantly==23.10.4 +coverage[toml]==7.4.1 +cryptography==42.0.3 +daphne==4.1.0 +django==4.2.10 +django-picklefield==3.1 +django-pylibmc==0.6.1 +django-q==1.3.6 +django-redis==4.5.0 +exceptiongroup==1.2.0 +hyperlink==21.0.0 +hypothesis==6.45.0 +idna==3.6 +importlib-metadata==7.0.1 +incremental==22.10.0 +iniconfig==2.0.0 +mock==5.1.0 +opentracing==2.4.0 +packaging==23.2 +pluggy==1.4.0 +psycopg==3.1.18 +psycopg2-binary==2.9.9 +pyasn1==0.5.1 +pyasn1-modules==0.3.0 +pycparser==2.21 +pylibmc==1.6.3 +pyopenssl==24.0.0 +pytest==8.0.0 +pytest-cov==4.1.0 +pytest-django==3.10.0 +pytest-mock==3.12.0 +pytest-randomly==3.15.0 +python-dateutil==2.8.2 +python-memcached==1.62 +redis==2.10.6 +requests==2.31.0 +service-identity==24.1.0 +six==1.16.0 +sortedcontainers==2.4.0 +sqlparse==0.4.4 +tomli==2.0.1 +twisted[tls]==23.10.0 +txaio==23.1.1 +types-python-dateutil==2.8.19.20240106 +typing-extensions==4.9.0 +urllib3==2.2.0 +wcwidth==0.2.13 +zipp==3.17.0 +zope-interface==6.2 + +# The following packages are considered to be unsafe in a requirements file: +# setuptools From d1846296be8c1481b5e856761163d525b1098988 Mon Sep 17 00:00:00 2001 From: erikayasuda Date: Fri, 16 Feb 2024 15:42:33 -0500 Subject: [PATCH 13/22] compile and prune reqs --- .riot/requirements/12373d8.txt | 57 ----------------- .riot/requirements/17efebb.txt | 61 ------------------ .riot/requirements/1c69ec1.txt | 61 ------------------ .riot/requirements/1ed1e53.txt | 60 ------------------ .riot/requirements/3d0b8c6.txt | 61 ------------------ .riot/requirements/7a7aa61.txt | 61 ------------------ .../requirements/{8213d1a.txt => 8d1d496.txt} | 37 ++++++----- .riot/requirements/e8b06ff.txt | 57 ----------------- .riot/requirements/f969d43.txt | 62 ------------------- 9 files changed, 22 insertions(+), 495 deletions(-) delete mode 100644 .riot/requirements/12373d8.txt delete mode 100644 .riot/requirements/17efebb.txt delete mode 100644 .riot/requirements/1c69ec1.txt delete mode 100644 .riot/requirements/1ed1e53.txt delete mode 100644 .riot/requirements/3d0b8c6.txt delete mode 100644 .riot/requirements/7a7aa61.txt rename .riot/requirements/{8213d1a.txt => 8d1d496.txt} (64%) delete mode 100644 .riot/requirements/e8b06ff.txt delete mode 100644 .riot/requirements/f969d43.txt diff --git a/.riot/requirements/12373d8.txt b/.riot/requirements/12373d8.txt deleted file mode 100644 index cf850fea5b9..00000000000 --- a/.riot/requirements/12373d8.txt +++ /dev/null @@ -1,57 +0,0 @@ -# -# This file is autogenerated by pip-compile with Python 3.12 -# by the following command: -# -# pip-compile --no-annotate .riot/requirements/12373d8.in -# -asgiref==3.7.2 -attrs==23.1.0 -autobahn==23.6.2 -automat==22.10.0 -certifi==2023.11.17 -cffi==1.16.0 -channels==4.0.0 -charset-normalizer==3.3.2 -constantly==23.10.4 -coverage[toml]==7.3.4 -cryptography==41.0.7 -daphne==4.0.0 -django==4.2.8 -django-pylibmc==0.6.1 -django-redis==4.5.0 -hyperlink==21.0.0 -hypothesis==6.45.0 -idna==3.6 -incremental==22.10.0 -iniconfig==2.0.0 -mock==5.1.0 -opentracing==2.4.0 -packaging==23.2 -pluggy==1.3.0 -psycopg==3.1.16 -psycopg2-binary==2.9.9 -pyasn1==0.5.1 -pyasn1-modules==0.3.0 -pycparser==2.21 -pylibmc==1.6.3 -pyopenssl==23.3.0 -pytest==7.4.3 -pytest-cov==4.1.0 -pytest-django==3.10.0 -pytest-mock==3.12.0 -pytest-randomly==3.15.0 -python-memcached==1.59 -redis==2.10.6 -requests==2.31.0 -service-identity==23.1.0 -six==1.16.0 -sortedcontainers==2.4.0 -sqlparse==0.4.4 -twisted[tls]==23.10.0 -txaio==23.1.1 -typing-extensions==4.9.0 -urllib3==2.1.0 -zope-interface==6.1 - -# The following packages are considered to be unsafe in a requirements file: -# setuptools diff --git a/.riot/requirements/17efebb.txt b/.riot/requirements/17efebb.txt deleted file mode 100644 index 1a54ed16544..00000000000 --- a/.riot/requirements/17efebb.txt +++ /dev/null @@ -1,61 +0,0 @@ -# -# This file is autogenerated by pip-compile with Python 3.7 -# by the following command: -# -# pip-compile --config=pyproject.toml --no-annotate --resolver=backtracking .riot/requirements/17efebb.in -# -asgiref==3.7.2 -attrs==23.1.0 -autobahn==23.1.2 -automat==22.10.0 -certifi==2023.11.17 -cffi==1.15.1 -channels==3.0.5 -charset-normalizer==3.3.2 -constantly==15.1.0 -coverage[toml]==7.2.7 -cryptography==41.0.7 -daphne==3.0.2 -django==3.2.23 -django-pylibmc==0.6.1 -django-redis==4.5.0 -exceptiongroup==1.2.0 -hyperlink==21.0.0 -hypothesis==6.45.0 -idna==3.6 -importlib-metadata==6.7.0 -incremental==22.10.0 -iniconfig==2.0.0 -mock==5.1.0 -opentracing==2.4.0 -packaging==23.2 -pluggy==1.2.0 -psycopg2-binary==2.9.9 -pyasn1==0.5.1 -pyasn1-modules==0.3.0 -pycparser==2.21 -pylibmc==1.6.3 -pyopenssl==23.3.0 -pytest==7.4.3 -pytest-cov==4.1.0 -pytest-django==3.10.0 -pytest-mock==3.11.1 -pytest-randomly==3.12.0 -python-memcached==1.59 -pytz==2023.3.post1 -redis==2.10.6 -requests==2.31.0 -service-identity==21.1.0 -six==1.16.0 -sortedcontainers==2.4.0 -sqlparse==0.4.4 -tomli==2.0.1 -twisted[tls]==23.8.0 -txaio==23.1.1 -typing-extensions==4.7.1 -urllib3==2.0.7 -zipp==3.15.0 -zope-interface==6.1 - -# The following packages are considered to be unsafe in a requirements file: -# setuptools diff --git a/.riot/requirements/1c69ec1.txt b/.riot/requirements/1c69ec1.txt deleted file mode 100644 index ee2da5806db..00000000000 --- a/.riot/requirements/1c69ec1.txt +++ /dev/null @@ -1,61 +0,0 @@ -# -# This file is autogenerated by pip-compile with Python 3.8 -# by the following command: -# -# pip-compile --no-annotate .riot/requirements/1c69ec1.in -# -asgiref==3.7.2 -attrs==23.1.0 -autobahn==23.1.2 -automat==22.10.0 -backports-zoneinfo==0.2.1 -certifi==2023.11.17 -cffi==1.16.0 -channels==4.0.0 -charset-normalizer==3.3.2 -constantly==23.10.4 -coverage[toml]==7.3.4 -cryptography==41.0.7 -daphne==4.0.0 -django==4.2.8 -django-pylibmc==0.6.1 -django-redis==4.5.0 -exceptiongroup==1.2.0 -hyperlink==21.0.0 -hypothesis==6.45.0 -idna==3.6 -importlib-metadata==7.0.0 -incremental==22.10.0 -iniconfig==2.0.0 -mock==5.1.0 -opentracing==2.4.0 -packaging==23.2 -pluggy==1.3.0 -psycopg2-binary==2.9.9 -pyasn1==0.5.1 -pyasn1-modules==0.3.0 -pycparser==2.21 -pylibmc==1.6.3 -pyopenssl==23.3.0 -pytest==7.4.3 -pytest-cov==4.1.0 -pytest-django==3.10.0 -pytest-mock==3.12.0 -pytest-randomly==3.15.0 -python-memcached==1.59 -redis==2.10.6 -requests==2.31.0 -service-identity==23.1.0 -six==1.16.0 -sortedcontainers==2.4.0 -sqlparse==0.4.4 -tomli==2.0.1 -twisted[tls]==23.10.0 -txaio==23.1.1 -typing-extensions==4.9.0 -urllib3==2.1.0 -zipp==3.17.0 -zope-interface==6.1 - -# The following packages are considered to be unsafe in a requirements file: -# setuptools diff --git a/.riot/requirements/1ed1e53.txt b/.riot/requirements/1ed1e53.txt deleted file mode 100644 index f31716ad6ab..00000000000 --- a/.riot/requirements/1ed1e53.txt +++ /dev/null @@ -1,60 +0,0 @@ -# -# This file is autogenerated by pip-compile with Python 3.9 -# by the following command: -# -# pip-compile --no-annotate .riot/requirements/1ed1e53.in -# -asgiref==3.7.2 -attrs==23.1.0 -autobahn==23.6.2 -automat==22.10.0 -certifi==2023.11.17 -cffi==1.16.0 -channels==4.0.0 -charset-normalizer==3.3.2 -constantly==23.10.4 -coverage[toml]==7.3.4 -cryptography==41.0.7 -daphne==4.0.0 -django==4.2.8 -django-pylibmc==0.6.1 -django-redis==4.5.0 -exceptiongroup==1.2.0 -hyperlink==21.0.0 -hypothesis==6.45.0 -idna==3.6 -importlib-metadata==7.0.0 -incremental==22.10.0 -iniconfig==2.0.0 -mock==5.1.0 -opentracing==2.4.0 -packaging==23.2 -pluggy==1.3.0 -psycopg2-binary==2.9.9 -pyasn1==0.5.1 -pyasn1-modules==0.3.0 -pycparser==2.21 -pylibmc==1.6.3 -pyopenssl==23.3.0 -pytest==7.4.3 -pytest-cov==4.1.0 -pytest-django==3.10.0 -pytest-mock==3.12.0 -pytest-randomly==3.15.0 -python-memcached==1.59 -redis==2.10.6 -requests==2.31.0 -service-identity==23.1.0 -six==1.16.0 -sortedcontainers==2.4.0 -sqlparse==0.4.4 -tomli==2.0.1 -twisted[tls]==23.10.0 -txaio==23.1.1 -typing-extensions==4.9.0 -urllib3==2.1.0 -zipp==3.17.0 -zope-interface==6.1 - -# The following packages are considered to be unsafe in a requirements file: -# setuptools diff --git a/.riot/requirements/3d0b8c6.txt b/.riot/requirements/3d0b8c6.txt deleted file mode 100644 index a7361de0878..00000000000 --- a/.riot/requirements/3d0b8c6.txt +++ /dev/null @@ -1,61 +0,0 @@ -# -# This file is autogenerated by pip-compile with Python 3.7 -# by the following command: -# -# pip-compile --config=pyproject.toml --no-annotate --resolver=backtracking .riot/requirements/3d0b8c6.in -# -asgiref==3.7.2 -attrs==23.1.0 -autobahn==23.1.2 -automat==22.10.0 -certifi==2023.11.17 -cffi==1.15.1 -channels==4.0.0 -charset-normalizer==3.3.2 -constantly==15.1.0 -coverage[toml]==7.2.7 -cryptography==41.0.7 -daphne==4.0.0 -django==3.2.23 -django-pylibmc==0.6.1 -django-redis==4.5.0 -exceptiongroup==1.2.0 -hyperlink==21.0.0 -hypothesis==6.45.0 -idna==3.6 -importlib-metadata==6.7.0 -incremental==22.10.0 -iniconfig==2.0.0 -mock==5.1.0 -opentracing==2.4.0 -packaging==23.2 -pluggy==1.2.0 -psycopg2-binary==2.9.9 -pyasn1==0.5.1 -pyasn1-modules==0.3.0 -pycparser==2.21 -pylibmc==1.6.3 -pyopenssl==23.3.0 -pytest==7.4.3 -pytest-cov==4.1.0 -pytest-django==3.10.0 -pytest-mock==3.11.1 -pytest-randomly==3.12.0 -python-memcached==1.59 -pytz==2023.3.post1 -redis==2.10.6 -requests==2.31.0 -service-identity==21.1.0 -six==1.16.0 -sortedcontainers==2.4.0 -sqlparse==0.4.4 -tomli==2.0.1 -twisted[tls]==23.8.0 -txaio==23.1.1 -typing-extensions==4.7.1 -urllib3==2.0.7 -zipp==3.15.0 -zope-interface==6.1 - -# The following packages are considered to be unsafe in a requirements file: -# setuptools diff --git a/.riot/requirements/7a7aa61.txt b/.riot/requirements/7a7aa61.txt deleted file mode 100644 index bd70d5ef546..00000000000 --- a/.riot/requirements/7a7aa61.txt +++ /dev/null @@ -1,61 +0,0 @@ -# -# This file is autogenerated by pip-compile with Python 3.9 -# by the following command: -# -# pip-compile --no-annotate .riot/requirements/7a7aa61.in -# -asgiref==3.7.2 -attrs==23.1.0 -autobahn==23.6.2 -automat==22.10.0 -certifi==2023.11.17 -cffi==1.16.0 -channels==4.0.0 -charset-normalizer==3.3.2 -constantly==23.10.4 -coverage[toml]==7.3.4 -cryptography==41.0.7 -daphne==4.0.0 -django==4.2.8 -django-pylibmc==0.6.1 -django-redis==4.5.0 -exceptiongroup==1.2.0 -hyperlink==21.0.0 -hypothesis==6.45.0 -idna==3.6 -importlib-metadata==7.0.0 -incremental==22.10.0 -iniconfig==2.0.0 -mock==5.1.0 -opentracing==2.4.0 -packaging==23.2 -pluggy==1.3.0 -psycopg==3.1.16 -psycopg2-binary==2.9.9 -pyasn1==0.5.1 -pyasn1-modules==0.3.0 -pycparser==2.21 -pylibmc==1.6.3 -pyopenssl==23.3.0 -pytest==7.4.3 -pytest-cov==4.1.0 -pytest-django==3.10.0 -pytest-mock==3.12.0 -pytest-randomly==3.15.0 -python-memcached==1.59 -redis==2.10.6 -requests==2.31.0 -service-identity==23.1.0 -six==1.16.0 -sortedcontainers==2.4.0 -sqlparse==0.4.4 -tomli==2.0.1 -twisted[tls]==23.10.0 -txaio==23.1.1 -typing-extensions==4.9.0 -urllib3==2.1.0 -zipp==3.17.0 -zope-interface==6.1 - -# The following packages are considered to be unsafe in a requirements file: -# setuptools diff --git a/.riot/requirements/8213d1a.txt b/.riot/requirements/8d1d496.txt similarity index 64% rename from .riot/requirements/8213d1a.txt rename to .riot/requirements/8d1d496.txt index cc267eed7c4..c87538ebe03 100644 --- a/.riot/requirements/8213d1a.txt +++ b/.riot/requirements/8d1d496.txt @@ -2,22 +2,26 @@ # This file is autogenerated by pip-compile with Python 3.10 # by the following command: # -# pip-compile --no-annotate .riot/requirements/8213d1a.in +# pip-compile --no-annotate .riot/requirements/8d1d496.in # +arrow==1.3.0 asgiref==3.7.2 -attrs==23.1.0 +attrs==23.2.0 autobahn==23.6.2 automat==22.10.0 -certifi==2023.11.17 +blessed==1.20.0 +certifi==2024.2.2 cffi==1.16.0 channels==4.0.0 charset-normalizer==3.3.2 constantly==23.10.4 -coverage[toml]==7.3.4 -cryptography==41.0.7 -daphne==4.0.0 -django==4.2.8 +coverage[toml]==7.4.1 +cryptography==42.0.3 +daphne==4.1.0 +django==4.2.10 +django-picklefield==3.1 django-pylibmc==0.6.1 +django-q==1.3.6 django-redis==4.5.0 exceptiongroup==1.2.0 hyperlink==21.0.0 @@ -28,32 +32,35 @@ iniconfig==2.0.0 mock==5.1.0 opentracing==2.4.0 packaging==23.2 -pluggy==1.3.0 -psycopg==3.1.16 +pluggy==1.4.0 +psycopg==3.1.18 psycopg2-binary==2.9.9 pyasn1==0.5.1 pyasn1-modules==0.3.0 pycparser==2.21 pylibmc==1.6.3 -pyopenssl==23.3.0 -pytest==7.4.3 +pyopenssl==24.0.0 +pytest==8.0.0 pytest-cov==4.1.0 pytest-django==3.10.0 pytest-mock==3.12.0 pytest-randomly==3.15.0 -python-memcached==1.59 +python-dateutil==2.8.2 +python-memcached==1.62 redis==2.10.6 requests==2.31.0 -service-identity==23.1.0 +service-identity==24.1.0 six==1.16.0 sortedcontainers==2.4.0 sqlparse==0.4.4 tomli==2.0.1 twisted[tls]==23.10.0 txaio==23.1.1 +types-python-dateutil==2.8.19.20240106 typing-extensions==4.9.0 -urllib3==2.1.0 -zope-interface==6.1 +urllib3==2.2.0 +wcwidth==0.2.13 +zope-interface==6.2 # The following packages are considered to be unsafe in a requirements file: # setuptools diff --git a/.riot/requirements/e8b06ff.txt b/.riot/requirements/e8b06ff.txt deleted file mode 100644 index 336cf9acbe0..00000000000 --- a/.riot/requirements/e8b06ff.txt +++ /dev/null @@ -1,57 +0,0 @@ -# -# This file is autogenerated by pip-compile with Python 3.11 -# by the following command: -# -# pip-compile --no-annotate .riot/requirements/e8b06ff.in -# -asgiref==3.7.2 -attrs==23.1.0 -autobahn==23.6.2 -automat==22.10.0 -certifi==2023.11.17 -cffi==1.16.0 -channels==4.0.0 -charset-normalizer==3.3.2 -constantly==23.10.4 -coverage[toml]==7.3.4 -cryptography==41.0.7 -daphne==4.0.0 -django==4.2.8 -django-pylibmc==0.6.1 -django-redis==4.5.0 -hyperlink==21.0.0 -hypothesis==6.45.0 -idna==3.6 -incremental==22.10.0 -iniconfig==2.0.0 -mock==5.1.0 -opentracing==2.4.0 -packaging==23.2 -pluggy==1.3.0 -psycopg==3.1.16 -psycopg2-binary==2.9.9 -pyasn1==0.5.1 -pyasn1-modules==0.3.0 -pycparser==2.21 -pylibmc==1.6.3 -pyopenssl==23.3.0 -pytest==7.4.3 -pytest-cov==4.1.0 -pytest-django==3.10.0 -pytest-mock==3.12.0 -pytest-randomly==3.15.0 -python-memcached==1.59 -redis==2.10.6 -requests==2.31.0 -service-identity==23.1.0 -six==1.16.0 -sortedcontainers==2.4.0 -sqlparse==0.4.4 -twisted[tls]==23.10.0 -txaio==23.1.1 -typing-extensions==4.9.0 -urllib3==2.1.0 -zope-interface==6.1 - -# The following packages are considered to be unsafe in a requirements file: -# setuptools diff --git a/.riot/requirements/f969d43.txt b/.riot/requirements/f969d43.txt deleted file mode 100644 index 206790adfb2..00000000000 --- a/.riot/requirements/f969d43.txt +++ /dev/null @@ -1,62 +0,0 @@ -# -# This file is autogenerated by pip-compile with Python 3.8 -# by the following command: -# -# pip-compile --no-annotate .riot/requirements/f969d43.in -# -asgiref==3.7.2 -attrs==23.1.0 -autobahn==23.1.2 -automat==22.10.0 -backports-zoneinfo==0.2.1 -certifi==2023.11.17 -cffi==1.16.0 -channels==4.0.0 -charset-normalizer==3.3.2 -constantly==23.10.4 -coverage[toml]==7.3.4 -cryptography==41.0.7 -daphne==4.0.0 -django==4.2.8 -django-pylibmc==0.6.1 -django-redis==4.5.0 -exceptiongroup==1.2.0 -hyperlink==21.0.0 -hypothesis==6.45.0 -idna==3.6 -importlib-metadata==7.0.0 -incremental==22.10.0 -iniconfig==2.0.0 -mock==5.1.0 -opentracing==2.4.0 -packaging==23.2 -pluggy==1.3.0 -psycopg==3.1.16 -psycopg2-binary==2.9.9 -pyasn1==0.5.1 -pyasn1-modules==0.3.0 -pycparser==2.21 -pylibmc==1.6.3 -pyopenssl==23.3.0 -pytest==7.4.3 -pytest-cov==4.1.0 -pytest-django==3.10.0 -pytest-mock==3.12.0 -pytest-randomly==3.15.0 -python-memcached==1.59 -redis==2.10.6 -requests==2.31.0 -service-identity==23.1.0 -six==1.16.0 -sortedcontainers==2.4.0 -sqlparse==0.4.4 -tomli==2.0.1 -twisted[tls]==23.10.0 -txaio==23.1.1 -typing-extensions==4.9.0 -urllib3==2.1.0 -zipp==3.17.0 -zope-interface==6.1 - -# The following packages are considered to be unsafe in a requirements file: -# setuptools From f7d5880b1b374bb4a5a2693526fb07ed07a84901 Mon Sep 17 00:00:00 2001 From: erikayasuda Date: Fri, 16 Feb 2024 17:04:44 -0500 Subject: [PATCH 14/22] updated parsing tests --- ddtrace/internal/tracemethods.py | 6 ++- tests/integration/test_tracemethods.py | 64 +++++++++++++++++++------- 2 files changed, 52 insertions(+), 18 deletions(-) diff --git a/ddtrace/internal/tracemethods.py b/ddtrace/internal/tracemethods.py index b6cab548eb9..0239648adf5 100644 --- a/ddtrace/internal/tracemethods.py +++ b/ddtrace/internal/tracemethods.py @@ -16,6 +16,8 @@ def _parse_trace_methods(raw_dd_trace_methods: str) -> List[Tuple[str, str]]: Note that support for wildcard methods ([*]) is not implemented. """ + if not raw_dd_trace_methods: + return [] dd_trace_methods = [] for qualified_methods in raw_dd_trace_methods.split(";"): # Validate that methods are specified @@ -41,7 +43,7 @@ def _parse_trace_methods(raw_dd_trace_methods: str) -> List[Tuple[str, str]]: # Add the methods to the list of methods to trace for method in methods.split(","): - if not str.isidentifier(method): + if not str.isidentifier(method.split(".")[-1]): raise ValueError( "Invalid method name: %r. %s" % ( @@ -59,6 +61,8 @@ def _parse_legacy_trace_methods(raw_dd_trace_methods: str) -> List[str]: """ TODO: This method can be deleted once the legacy syntax is officially deprecated """ + if not raw_dd_trace_methods: + return [] dd_trace_methods = [] for qualified_methods in raw_dd_trace_methods.split(";"): # Validate that methods are specified diff --git a/tests/integration/test_tracemethods.py b/tests/integration/test_tracemethods.py index 70f87bb76e9..0372e5dbc82 100644 --- a/tests/integration/test_tracemethods.py +++ b/tests/integration/test_tracemethods.py @@ -1,5 +1,6 @@ import asyncio import os +from typing import List, Tuple import pytest @@ -8,49 +9,78 @@ pytestmark = pytest.mark.skipif(AGENT_VERSION != "testagent", reason="Tests only compatible with a testagent") - -def test_trace_methods_parse(): +@pytest.mark.parametrize( + "input,expected_output,raises_error", + [ + ("", [], False), + ("module:method1", [("module","method1")], False), + ("module:method1,method2",[("module","method1"), ("module","method2")], False), + ("module:method1,method2;mod2:m1,m2", [("module","method1"), ("module","method2"), ("mod2","m1"), ("mod2", "m2")], False), + ("mod.submod:m1,m2,m3", [("mod.submod", "m1"), ("mod.submod", "m2"), ("mod.submod", "m3")], False), + ("mod.submod.subsubmod:m1,m2", [("mod.submod.subsubmod", "m1"), ("mod.submod.subsubmod", "m2")], False), + ("mod.mod2.mod3:Class.test_method,Class.test_method2", [("mod.mod2.mod3", "Class.test_method"), ("mod.mod2.mod3", "Class.test_method2")], False), + ("module[method1, method2]", None, True), + ("module", None, True), + ("module.", None, True), + ("module.method", None, True), + ("module.method[m1,m2,]", None, True), + ("module.method;module.method", None, True), + ("module.method[m1];module.method[m1,m2,]", None, True), + ("module.method[[m1]", None, True) + ] +) +def test_trace_methods_parse(input: str, expected_output: List[Tuple[str, str]], raises_error: bool): from ddtrace.internal.tracemethods import _parse_trace_methods - assert _parse_trace_methods("") == [] - assert _parse_trace_methods("module[method1]") == ["module.method1"] - assert _parse_trace_methods("module[method1,method2]") == ["module.method1", "module.method2"] - assert _parse_trace_methods("module[method1,method2];mod2[m1,m2]") == [ + if raises_error: + with pytest.raises(ValueError): + _parse_trace_methods(input) + else: + assert _parse_trace_methods(input) == expected_output + + +def test_legacy_trace_methods_parse(): + from ddtrace.internal.tracemethods import _parse_legacy_trace_methods + + assert _parse_legacy_trace_methods("") == [] + assert _parse_legacy_trace_methods("module[method1]") == ["module.method1"] + assert _parse_legacy_trace_methods("module[method1,method2]") == ["module.method1", "module.method2"] + assert _parse_legacy_trace_methods("module[method1,method2];mod2[m1,m2]") == [ "module.method1", "module.method2", "mod2.m1", "mod2.m2", ] - assert _parse_trace_methods("mod.submod[m1,m2,m3]") == ["mod.submod.m1", "mod.submod.m2", "mod.submod.m3"] - assert _parse_trace_methods("mod.submod.subsubmod[m1,m2]") == ["mod.submod.subsubmod.m1", "mod.submod.subsubmod.m2"] - assert _parse_trace_methods("mod.mod2.mod3.Class[test_method,test_method2]") == [ + assert _parse_legacy_trace_methods("mod.submod[m1,m2,m3]") == ["mod.submod.m1", "mod.submod.m2", "mod.submod.m3"] + assert _parse_legacy_trace_methods("mod.submod.subsubmod[m1,m2]") == ["mod.submod.subsubmod.m1", "mod.submod.subsubmod.m2"] + assert _parse_legacy_trace_methods("mod.mod2.mod3.Class[test_method,test_method2]") == [ "mod.mod2.mod3.Class.test_method", "mod.mod2.mod3.Class.test_method2", ] with pytest.raises(ValueError): - _parse_trace_methods("module[method1, method2]") + _parse_legacy_trace_methods("module[method1, method2]") with pytest.raises(ValueError): - _parse_trace_methods("module") + _parse_legacy_trace_methods("module") with pytest.raises(ValueError): - _parse_trace_methods("module.") + _parse_legacy_trace_methods("module.") with pytest.raises(ValueError): - _parse_trace_methods("module.method") + _parse_legacy_trace_methods("module.method") with pytest.raises(ValueError): - _parse_trace_methods("module.method[m1,m2,]") + _parse_legacy_trace_methods("module.method[m1,m2,]") with pytest.raises(ValueError): - _parse_trace_methods("module.method;module.method") + _parse_legacy_trace_methods("module.method;module.method") with pytest.raises(ValueError): - _parse_trace_methods("module.method[m1];module.method[m1,m2,]") + _parse_legacy_trace_methods("module.method[m1];module.method[m1,m2,]") with pytest.raises(ValueError): - _parse_trace_methods("module.method[[m1]") + _parse_legacy_trace_methods("module.method[[m1]") def _test_method(): From ecd02a73b71d435ade689aade143cf706911acf6 Mon Sep 17 00:00:00 2001 From: erikayasuda Date: Fri, 16 Feb 2024 17:05:17 -0500 Subject: [PATCH 15/22] linting --- tests/integration/test_tracemethods.py | 59 ++++++++++++++++---------- 1 file changed, 36 insertions(+), 23 deletions(-) diff --git a/tests/integration/test_tracemethods.py b/tests/integration/test_tracemethods.py index 0372e5dbc82..e4c1d7a1745 100644 --- a/tests/integration/test_tracemethods.py +++ b/tests/integration/test_tracemethods.py @@ -1,6 +1,7 @@ import asyncio import os -from typing import List, Tuple +from typing import List +from typing import Tuple import pytest @@ -9,34 +10,43 @@ pytestmark = pytest.mark.skipif(AGENT_VERSION != "testagent", reason="Tests only compatible with a testagent") + @pytest.mark.parametrize( - "input,expected_output,raises_error", - [ - ("", [], False), - ("module:method1", [("module","method1")], False), - ("module:method1,method2",[("module","method1"), ("module","method2")], False), - ("module:method1,method2;mod2:m1,m2", [("module","method1"), ("module","method2"), ("mod2","m1"), ("mod2", "m2")], False), - ("mod.submod:m1,m2,m3", [("mod.submod", "m1"), ("mod.submod", "m2"), ("mod.submod", "m3")], False), - ("mod.submod.subsubmod:m1,m2", [("mod.submod.subsubmod", "m1"), ("mod.submod.subsubmod", "m2")], False), - ("mod.mod2.mod3:Class.test_method,Class.test_method2", [("mod.mod2.mod3", "Class.test_method"), ("mod.mod2.mod3", "Class.test_method2")], False), - ("module[method1, method2]", None, True), - ("module", None, True), - ("module.", None, True), - ("module.method", None, True), - ("module.method[m1,m2,]", None, True), - ("module.method;module.method", None, True), - ("module.method[m1];module.method[m1,m2,]", None, True), - ("module.method[[m1]", None, True) - ] + "dd_trace_methods,expected_output,raises_error", + [ + ("", [], False), + ("module:method1", [("module", "method1")], False), + ("module:method1,method2", [("module", "method1"), ("module", "method2")], False), + ( + "module:method1,method2;mod2:m1,m2", + [("module", "method1"), ("module", "method2"), ("mod2", "m1"), ("mod2", "m2")], + False, + ), + ("mod.submod:m1,m2,m3", [("mod.submod", "m1"), ("mod.submod", "m2"), ("mod.submod", "m3")], False), + ("mod.submod.subsubmod:m1,m2", [("mod.submod.subsubmod", "m1"), ("mod.submod.subsubmod", "m2")], False), + ( + "mod.mod2.mod3:Class.test_method,Class.test_method2", + [("mod.mod2.mod3", "Class.test_method"), ("mod.mod2.mod3", "Class.test_method2")], + False, + ), + ("module[method1, method2]", None, True), + ("module", None, True), + ("module.", None, True), + ("module.method", None, True), + ("module.method[m1,m2,]", None, True), + ("module.method;module.method", None, True), + ("module.method[m1];module.method[m1,m2,]", None, True), + ("module.method[[m1]", None, True), + ], ) -def test_trace_methods_parse(input: str, expected_output: List[Tuple[str, str]], raises_error: bool): +def test_trace_methods_parse(dd_trace_methods: str, expected_output: List[Tuple[str, str]], raises_error: bool): from ddtrace.internal.tracemethods import _parse_trace_methods if raises_error: with pytest.raises(ValueError): - _parse_trace_methods(input) + _parse_trace_methods(dd_trace_methods) else: - assert _parse_trace_methods(input) == expected_output + assert _parse_trace_methods(dd_trace_methods) == expected_output def test_legacy_trace_methods_parse(): @@ -52,7 +62,10 @@ def test_legacy_trace_methods_parse(): "mod2.m2", ] assert _parse_legacy_trace_methods("mod.submod[m1,m2,m3]") == ["mod.submod.m1", "mod.submod.m2", "mod.submod.m3"] - assert _parse_legacy_trace_methods("mod.submod.subsubmod[m1,m2]") == ["mod.submod.subsubmod.m1", "mod.submod.subsubmod.m2"] + assert _parse_legacy_trace_methods("mod.submod.subsubmod[m1,m2]") == [ + "mod.submod.subsubmod.m1", + "mod.submod.subsubmod.m2", + ] assert _parse_legacy_trace_methods("mod.mod2.mod3.Class[test_method,test_method2]") == [ "mod.mod2.mod3.Class.test_method", "mod.mod2.mod3.Class.test_method2", From 711f065c617226e7ff1432265d46f32adaff99ea Mon Sep 17 00:00:00 2001 From: erikayasuda Date: Tue, 20 Feb 2024 11:29:37 -0500 Subject: [PATCH 16/22] pr feedback --- ddtrace/internal/tracemethods.py | 8 +- tests/contrib/django/test_django.py | 17 - tests/contrib/django/test_django_snapshots.py | 19 +- ...apshots.test_djangoq_dd_trace_methods.json | 488 ++++++++++++++++++ 4 files changed, 511 insertions(+), 21 deletions(-) create mode 100644 tests/snapshots/tests.contrib.django.test_django_snapshots.test_djangoq_dd_trace_methods.json diff --git a/ddtrace/internal/tracemethods.py b/ddtrace/internal/tracemethods.py index 0239648adf5..6c5a8572876 100644 --- a/ddtrace/internal/tracemethods.py +++ b/ddtrace/internal/tracemethods.py @@ -12,7 +12,6 @@ def _parse_trace_methods(raw_dd_trace_methods: str) -> List[Tuple[str, str]]: specification of DD_TRACE_METHODS. DD_TRACE_METHODS is specified to be FullyQualifiedModuleName:comma-separated-methods;... - The square bracket notation will be deprecated in favor of this new syntax Note that support for wildcard methods ([*]) is not implemented. """ @@ -38,7 +37,8 @@ def _parse_trace_methods(raw_dd_trace_methods: str) -> List[Tuple[str, str]]: # __main__ cannot be used since the __main__ that exists now is not the same as the __main__ that the user # application will have. __main__ when sitecustomize module is run is the builtin __main__. raise ValueError( - "Invalid DD_TRACE_METHODS: %s. Methods cannot be traced on the __main__ module." % qualified_methods + "Invalid DD_TRACE_METHODS: %s. Methods cannot be traced on the __main__ module. __main__ when " + "sitecustomize module is run is the builtin __main__." % qualified_methods ) # Add the methods to the list of methods to trace @@ -59,6 +59,10 @@ def _parse_trace_methods(raw_dd_trace_methods: str) -> List[Tuple[str, str]]: def _parse_legacy_trace_methods(raw_dd_trace_methods: str) -> List[str]: """ + Return a list of method names to trace based on the specification of + DD_TRACE_METHODS. + + This square bracket notation will be deprecated in favor of the new ':' notation TODO: This method can be deleted once the legacy syntax is officially deprecated """ if not raw_dd_trace_methods: diff --git a/tests/contrib/django/test_django.py b/tests/contrib/django/test_django.py index 852afcb0461..f44935717f8 100644 --- a/tests/contrib/django/test_django.py +++ b/tests/contrib/django/test_django.py @@ -36,7 +36,6 @@ from ddtrace.propagation.http import HTTP_HEADER_SAMPLING_PRIORITY from ddtrace.propagation.http import HTTP_HEADER_TRACE_ID from ddtrace.vendor import wrapt -from tests.contrib.django.test_django_snapshots import daphne_client from tests.opentracer.utils import init_tracer from tests.utils import assert_dict_issuperset from tests.utils import flaky @@ -2425,19 +2424,3 @@ def test_django_base_handler_failure(client, test_spans): pass # We expect an error root = test_spans.get_root_span() assert root.resource == "GET ^$" - - -@pytest.mark.parametrize( - "dd_trace_methods,error_expected", - [("django_q.tasks[async_task]", True), ("django_q.tasks:async_task", False)], # legacy syntax, updated syntax -) -def test_djangoq_dd_trace_methods(dd_trace_methods, error_expected): - with daphne_client( - "application", - additional_env={"DD_TRACE_METHODS": dd_trace_methods, "_DD_TRACE_WRITER_ADDITIONAL_HEADERS": ""}, - django_settings_module="tests.contrib.django.django_app.settings", - ) as (client, proc): - assert client.get("simple/").status_code == 200 - - _, stderr = proc.communicate(timeout=5) - assert (b"error configuring Datadog tracing" in stderr) == error_expected diff --git a/tests/contrib/django/test_django_snapshots.py b/tests/contrib/django/test_django_snapshots.py index 1b2f6974a91..fd62a80f878 100644 --- a/tests/contrib/django/test_django_snapshots.py +++ b/tests/contrib/django/test_django_snapshots.py @@ -19,7 +19,7 @@ @contextmanager -def daphne_client(django_asgi, additional_env=None, django_settings_module="tests.contrib.django.django_app.settings"): +def daphne_client(django_asgi, additional_env=None): """Runs a django app hosted with a daphne webserver in a subprocess and returns a client which can be used to query it. @@ -34,7 +34,7 @@ def daphne_client(django_asgi, additional_env=None, django_settings_module="test assert "_DD_TRACE_WRITER_ADDITIONAL_HEADERS" in env, "Client fixture needs test token in headers" env.update( { - "DJANGO_SETTINGS_MODULE": django_settings_module, + "DJANGO_SETTINGS_MODULE": "tests.contrib.django.django_app.settings", } ) @@ -316,3 +316,18 @@ def test_django_resource_handler(): with daphne_client("application", additional_env={"DD_DJANGO_USE_HANDLER_RESOURCE_FORMAT": "true"}) as (client, _): # Request a class based view assert client.get("simple/").status_code == 200 + +@pytest.mark.parametrize( + "dd_trace_methods,error_expected", + [("django_q.tasks[async_task]", True), ("django_q.tasks:async_task", False)], # legacy syntax, updated syntax +) +@snapshot(ignores=SNAPSHOT_IGNORES + ["meta.http.useragent"]) +def test_djangoq_dd_trace_methods(dd_trace_methods, error_expected): + with daphne_client( + "application", + additional_env={"DD_TRACE_METHODS": dd_trace_methods} + ) as (client, proc): + assert client.get("simple/").status_code == 200 + + _, stderr = proc.communicate(timeout=5) + assert (b"error configuring Datadog tracing" in stderr) == error_expected \ No newline at end of file diff --git a/tests/snapshots/tests.contrib.django.test_django_snapshots.test_djangoq_dd_trace_methods.json b/tests/snapshots/tests.contrib.django.test_django_snapshots.test_djangoq_dd_trace_methods.json new file mode 100644 index 00000000000..5573087ddff --- /dev/null +++ b/tests/snapshots/tests.contrib.django.test_django_snapshots.test_djangoq_dd_trace_methods.json @@ -0,0 +1,488 @@ +[[ + { + "name": "django.request", + "service": "django", + "resource": "GET ^simple/$", + "trace_id": 0, + "span_id": 1, + "parent_id": 0, + "type": "web", + "error": 0, + "meta": { + "_dd.base_service": "", + "_dd.p.dm": "-0", + "_dd.p.tid": "65d4d02000000000", + "asgi.version": "3.0", + "component": "django", + "django.request.class": "django.core.handlers.asgi.ASGIRequest", + "django.response.class": "django.http.response.HttpResponse", + "django.user.is_authenticated": "False", + "django.view": "tests.contrib.django.views.BasicView", + "http.method": "GET", + "http.route": "^simple/$", + "http.status_code": "200", + "http.url": "http://localhost:8000/simple/", + "http.useragent": "python-requests/2.31.0", + "http.version": "1.1", + "language": "python", + "runtime-id": "6125927e20ea40e18c3b0531ec57d87a", + "span.kind": "server" + }, + "metrics": { + "_dd.measured": 1, + "_dd.top_level": 1, + "_dd.tracer_kr": 1.0, + "_sampling_priority_v1": 1, + "process_id": 47152 + }, + "duration": 3044208, + "start": 1708445728566359177 + }, + { + "name": "django.middleware", + "service": "django", + "resource": "django.contrib.sessions.middleware.SessionMiddleware.__call__", + "trace_id": 0, + "span_id": 2, + "parent_id": 1, + "type": "", + "error": 0, + "meta": { + "_dd.base_service": "", + "component": "django" + }, + "duration": 2079917, + "start": 1708445728566915343 + }, + { + "name": "django.middleware", + "service": "django", + "resource": "django.contrib.sessions.middleware.SessionMiddleware.process_request", + "trace_id": 0, + "span_id": 3, + "parent_id": 2, + "type": "", + "error": 0, + "meta": { + "_dd.base_service": "", + "component": "django" + }, + "duration": 24625, + "start": 1708445728566955343 + }, + { + "name": "django.middleware", + "service": "django", + "resource": "django.middleware.common.CommonMiddleware.__call__", + "trace_id": 0, + "span_id": 4, + "parent_id": 2, + "type": "", + "error": 0, + "meta": { + "_dd.base_service": "", + "component": "django" + }, + "duration": 1929375, + "start": 1708445728567007718 + }, + { + "name": "django.middleware", + "service": "django", + "resource": "django.middleware.common.CommonMiddleware.process_request", + "trace_id": 0, + "span_id": 6, + "parent_id": 4, + "type": "", + "error": 0, + "meta": { + "_dd.base_service": "", + "component": "django" + }, + "duration": 25250, + "start": 1708445728567036260 + }, + { + "name": "django.middleware", + "service": "django", + "resource": "django.middleware.csrf.CsrfViewMiddleware.__call__", + "trace_id": 0, + "span_id": 7, + "parent_id": 4, + "type": "", + "error": 0, + "meta": { + "_dd.base_service": "", + "component": "django" + }, + "duration": 1804584, + "start": 1708445728567087218 + }, + { + "name": "django.middleware", + "service": "django", + "resource": "django.middleware.csrf.CsrfViewMiddleware.process_request", + "trace_id": 0, + "span_id": 9, + "parent_id": 7, + "type": "", + "error": 0, + "meta": { + "_dd.base_service": "", + "component": "django" + }, + "duration": 14583, + "start": 1708445728567114760 + }, + { + "name": "django.middleware", + "service": "django", + "resource": "django.contrib.auth.middleware.AuthenticationMiddleware.__call__", + "trace_id": 0, + "span_id": 10, + "parent_id": 7, + "type": "", + "error": 0, + "meta": { + "_dd.base_service": "", + "component": "django" + }, + "duration": 1697792, + "start": 1708445728567152593 + }, + { + "name": "django.middleware", + "service": "django", + "resource": "django.contrib.auth.middleware.AuthenticationMiddleware.process_request", + "trace_id": 0, + "span_id": 12, + "parent_id": 10, + "type": "", + "error": 0, + "meta": { + "_dd.base_service": "", + "component": "django" + }, + "duration": 14667, + "start": 1708445728567179718 + }, + { + "name": "django.middleware", + "service": "django", + "resource": "django.contrib.messages.middleware.MessageMiddleware.__call__", + "trace_id": 0, + "span_id": 13, + "parent_id": 10, + "type": "", + "error": 0, + "meta": { + "_dd.base_service": "", + "component": "django" + }, + "duration": 1626792, + "start": 1708445728567216843 + }, + { + "name": "django.middleware", + "service": "django", + "resource": "django.contrib.messages.middleware.MessageMiddleware.process_request", + "trace_id": 0, + "span_id": 14, + "parent_id": 13, + "type": "", + "error": 0, + "meta": { + "_dd.base_service": "", + "component": "django" + }, + "duration": 32833, + "start": 1708445728567246135 + }, + { + "name": "django.middleware", + "service": "django", + "resource": "django.middleware.clickjacking.XFrameOptionsMiddleware.__call__", + "trace_id": 0, + "span_id": 15, + "parent_id": 13, + "type": "", + "error": 0, + "meta": { + "_dd.base_service": "", + "component": "django" + }, + "duration": 1495291, + "start": 1708445728567303052 + }, + { + "name": "django.middleware", + "service": "django", + "resource": "django.middleware.security.SecurityMiddleware.__call__", + "trace_id": 0, + "span_id": 17, + "parent_id": 15, + "type": "", + "error": 0, + "meta": { + "_dd.base_service": "", + "component": "django" + }, + "duration": 1418083, + "start": 1708445728567331052 + }, + { + "name": "django.middleware", + "service": "django", + "resource": "django.middleware.security.SecurityMiddleware.process_request", + "trace_id": 0, + "span_id": 19, + "parent_id": 17, + "type": "", + "error": 0, + "meta": { + "_dd.base_service": "", + "component": "django" + }, + "duration": 12208, + "start": 1708445728567359135 + }, + { + "name": "django.middleware", + "service": "django", + "resource": "tests.contrib.django.middleware.ClsMiddleware.__call__", + "trace_id": 0, + "span_id": 20, + "parent_id": 17, + "type": "", + "error": 0, + "meta": { + "_dd.base_service": "", + "component": "django" + }, + "duration": 1290417, + "start": 1708445728567394635 + }, + { + "name": "django.middleware", + "service": "django", + "resource": "tests.contrib.django.middleware.fn_middleware", + "trace_id": 0, + "span_id": 22, + "parent_id": 20, + "type": "", + "error": 0, + "meta": { + "_dd.base_service": "", + "component": "django" + }, + "duration": 1254209, + "start": 1708445728567423718 + }, + { + "name": "django.middleware", + "service": "django", + "resource": "tests.contrib.django.middleware.EverythingMiddleware.__call__", + "trace_id": 0, + "span_id": 23, + "parent_id": 22, + "type": "", + "error": 0, + "meta": { + "_dd.base_service": "", + "component": "django" + }, + "duration": 1211291, + "start": 1708445728567450802 + }, + { + "name": "django.middleware", + "service": "django", + "resource": "django.middleware.csrf.CsrfViewMiddleware.process_view", + "trace_id": 0, + "span_id": 24, + "parent_id": 23, + "type": "", + "error": 0, + "meta": { + "_dd.base_service": "", + "component": "django" + }, + "duration": 25584, + "start": 1708445728567888093 + }, + { + "name": "django.middleware", + "service": "django", + "resource": "tests.contrib.django.middleware.EverythingMiddleware.process_view", + "trace_id": 0, + "span_id": 25, + "parent_id": 23, + "type": "", + "error": 0, + "meta": { + "_dd.base_service": "", + "component": "django" + }, + "duration": 21625, + "start": 1708445728568068010 + }, + { + "name": "django.view", + "service": "django", + "resource": "tests.contrib.django.views.BasicView", + "trace_id": 0, + "span_id": 26, + "parent_id": 23, + "type": "", + "error": 0, + "meta": { + "_dd.base_service": "", + "component": "django" + }, + "duration": 167208, + "start": 1708445728568255302 + }, + { + "name": "django.view.setup", + "service": "django", + "resource": "django.views.generic.base.View.setup", + "trace_id": 0, + "span_id": 27, + "parent_id": 26, + "type": "", + "error": 0, + "meta": { + "_dd.base_service": "", + "component": "django" + }, + "duration": 18083, + "start": 1708445728568294177 + }, + { + "name": "django.view.dispatch", + "service": "django", + "resource": "django.views.generic.base.View.dispatch", + "trace_id": 0, + "span_id": 28, + "parent_id": 26, + "type": "", + "error": 0, + "meta": { + "_dd.base_service": "", + "component": "django" + }, + "duration": 76709, + "start": 1708445728568339093 + }, + { + "name": "django.view.get", + "service": "django", + "resource": "tests.contrib.django.views.BasicView.get", + "trace_id": 0, + "span_id": 29, + "parent_id": 28, + "type": "", + "error": 0, + "meta": { + "_dd.base_service": "", + "component": "django" + }, + "duration": 34166, + "start": 1708445728568372302 + }, + { + "name": "django.middleware", + "service": "django", + "resource": "django.middleware.security.SecurityMiddleware.process_response", + "trace_id": 0, + "span_id": 21, + "parent_id": 17, + "type": "", + "error": 0, + "meta": { + "_dd.base_service": "", + "component": "django" + }, + "duration": 27042, + "start": 1708445728568714385 + }, + { + "name": "django.middleware", + "service": "django", + "resource": "django.middleware.clickjacking.XFrameOptionsMiddleware.process_response", + "trace_id": 0, + "span_id": 18, + "parent_id": 15, + "type": "", + "error": 0, + "meta": { + "_dd.base_service": "", + "component": "django" + }, + "duration": 18084, + "start": 1708445728568772343 + }, + { + "name": "django.middleware", + "service": "django", + "resource": "django.contrib.messages.middleware.MessageMiddleware.process_response", + "trace_id": 0, + "span_id": 16, + "parent_id": 13, + "type": "", + "error": 0, + "meta": { + "_dd.base_service": "", + "component": "django" + }, + "duration": 14708, + "start": 1708445728568821635 + }, + { + "name": "django.middleware", + "service": "django", + "resource": "django.middleware.csrf.CsrfViewMiddleware.process_response", + "trace_id": 0, + "span_id": 11, + "parent_id": 7, + "type": "", + "error": 0, + "meta": { + "_dd.base_service": "", + "component": "django" + }, + "duration": 12334, + "start": 1708445728568872468 + }, + { + "name": "django.middleware", + "service": "django", + "resource": "django.middleware.common.CommonMiddleware.process_response", + "trace_id": 0, + "span_id": 8, + "parent_id": 4, + "type": "", + "error": 0, + "meta": { + "_dd.base_service": "", + "component": "django" + }, + "duration": 16834, + "start": 1708445728568912718 + }, + { + "name": "django.middleware", + "service": "django", + "resource": "django.contrib.sessions.middleware.SessionMiddleware.process_response", + "trace_id": 0, + "span_id": 5, + "parent_id": 2, + "type": "", + "error": 0, + "meta": { + "_dd.base_service": "", + "component": "django" + }, + "duration": 29750, + "start": 1708445728568958302 + }]] From 324f0e72c1a013fed276ab9c74ffa42bffd0ec2c Mon Sep 17 00:00:00 2001 From: erikayasuda Date: Tue, 20 Feb 2024 11:30:37 -0500 Subject: [PATCH 17/22] linting --- tests/contrib/django/test_django_snapshots.py | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/tests/contrib/django/test_django_snapshots.py b/tests/contrib/django/test_django_snapshots.py index fd62a80f878..3475cacd191 100644 --- a/tests/contrib/django/test_django_snapshots.py +++ b/tests/contrib/django/test_django_snapshots.py @@ -317,17 +317,15 @@ def test_django_resource_handler(): # Request a class based view assert client.get("simple/").status_code == 200 + @pytest.mark.parametrize( "dd_trace_methods,error_expected", [("django_q.tasks[async_task]", True), ("django_q.tasks:async_task", False)], # legacy syntax, updated syntax ) @snapshot(ignores=SNAPSHOT_IGNORES + ["meta.http.useragent"]) def test_djangoq_dd_trace_methods(dd_trace_methods, error_expected): - with daphne_client( - "application", - additional_env={"DD_TRACE_METHODS": dd_trace_methods} - ) as (client, proc): + with daphne_client("application", additional_env={"DD_TRACE_METHODS": dd_trace_methods}) as (client, proc): assert client.get("simple/").status_code == 200 _, stderr = proc.communicate(timeout=5) - assert (b"error configuring Datadog tracing" in stderr) == error_expected \ No newline at end of file + assert (b"error configuring Datadog tracing" in stderr) == error_expected From e1f1cde5ea72ece9aa0dd22b32d3be1e3feeca86 Mon Sep 17 00:00:00 2001 From: erikayasuda <153395705+erikayasuda@users.noreply.github.com> Date: Tue, 20 Feb 2024 11:31:35 -0500 Subject: [PATCH 18/22] Update releasenotes/notes/fix-dd-trace-methods-2c1b4af30a7bf3ef.yaml Co-authored-by: Emmett Butler <723615+emmettbutler@users.noreply.github.com> --- releasenotes/notes/fix-dd-trace-methods-2c1b4af30a7bf3ef.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/releasenotes/notes/fix-dd-trace-methods-2c1b4af30a7bf3ef.yaml b/releasenotes/notes/fix-dd-trace-methods-2c1b4af30a7bf3ef.yaml index 3ad73e52de9..f8979fc363e 100644 --- a/releasenotes/notes/fix-dd-trace-methods-2c1b4af30a7bf3ef.yaml +++ b/releasenotes/notes/fix-dd-trace-methods-2c1b4af30a7bf3ef.yaml @@ -1,5 +1,5 @@ --- deprecations: - | - tracing: Using [] for DD_TRACE_METHODS ("mymod.mysubmod.myclass[myfunc,otherfunc];...") is deprecated and will be removed in 3.0.0. - You can use the new notation with : instead ("mymod.mysubmod:myclass.myfunc,myclass.otherfunc;...") \ No newline at end of file + tracing: Using ``[]`` for DD_TRACE_METHODS (``mymod.mysubmod.myclass[myfunc,otherfunc];...``) is deprecated and will be removed in 3.0.0. + You can use the new notation with ``:`` instead (``mymod.mysubmod:myclass.myfunc,myclass.otherfunc;...``) \ No newline at end of file From dcb774562f5832e1f341fee7f2f8a6b1fdc1ca7a Mon Sep 17 00:00:00 2001 From: erikayasuda Date: Tue, 20 Feb 2024 16:44:12 -0500 Subject: [PATCH 19/22] adding temporary flag for no_ddtrace to get around pytest issues blocking changes --- .circleci/config.templ.yml | 6 +++++- scripts/run-test-suite | 2 ++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/.circleci/config.templ.yml b/.circleci/config.templ.yml index 8fdfbc32bb4..8a47e56ec0e 100644 --- a/.circleci/config.templ.yml +++ b/.circleci/config.templ.yml @@ -126,6 +126,9 @@ commands: run_agent_checks: type: boolean default: true + no_ddtrace: + type: boolean + default: false steps: - checkout - attach_workspace: @@ -146,7 +149,7 @@ commands: DD_TRACE_AGENT_URL: << parameters.trace_agent_url >> RIOT_RUN_RECOMPILE_REQS: "<< pipeline.parameters.riot_run_latest >>" command: | - ./scripts/run-test-suite '<>' <> 1 + ./scripts/run-test-suite '<>' <> 1 <> - unless: condition: << parameters.snapshot >> @@ -821,6 +824,7 @@ jobs: pattern: 'django($|_celery)' snapshot: true docker_services: "memcached redis postgres" + no_ddtrace: true django_hosts: <<: *machine_executor diff --git a/scripts/run-test-suite b/scripts/run-test-suite index dc6e54677af..b61f2b0d317 100755 --- a/scripts/run-test-suite +++ b/scripts/run-test-suite @@ -5,6 +5,8 @@ RIOT_PATTERN=${1} DDTRACE_FLAG=$([ -v _CI_DD_API_KEY ] && echo '--ddtrace') COVERAGE_FLAG=$([[ "${2:-false}" == false ]] && echo '--no-cov') DDTEST_CMD=$([[ ${3} == "1" ]] && echo "./scripts/ddtest") +# temporary workaround for pytest issues in CI jobs +DDTRACE_FLAG=$([[ "${4:-false}" == true ]] && echo '--no-ddtrace') RIOT_HASHES=( $(riot list --hash-only $RIOT_PATTERN | sort) ) echo "Found ${#RIOT_HASHES[@]} riot hashes: ${RIOT_HASHES[@]}" From 6e538faba983b6ffc63b0173d5758ece0304580c Mon Sep 17 00:00:00 2001 From: erikayasuda Date: Wed, 21 Feb 2024 14:13:21 -0500 Subject: [PATCH 20/22] remove pytest workaround --- .circleci/config.templ.yml | 6 +----- .../notes/fix-dd-trace-methods-2c1b4af30a7bf3ef.yaml | 5 ++++- scripts/run-test-suite | 2 -- 3 files changed, 5 insertions(+), 8 deletions(-) diff --git a/.circleci/config.templ.yml b/.circleci/config.templ.yml index 8a47e56ec0e..8fdfbc32bb4 100644 --- a/.circleci/config.templ.yml +++ b/.circleci/config.templ.yml @@ -126,9 +126,6 @@ commands: run_agent_checks: type: boolean default: true - no_ddtrace: - type: boolean - default: false steps: - checkout - attach_workspace: @@ -149,7 +146,7 @@ commands: DD_TRACE_AGENT_URL: << parameters.trace_agent_url >> RIOT_RUN_RECOMPILE_REQS: "<< pipeline.parameters.riot_run_latest >>" command: | - ./scripts/run-test-suite '<>' <> 1 <> + ./scripts/run-test-suite '<>' <> 1 - unless: condition: << parameters.snapshot >> @@ -824,7 +821,6 @@ jobs: pattern: 'django($|_celery)' snapshot: true docker_services: "memcached redis postgres" - no_ddtrace: true django_hosts: <<: *machine_executor diff --git a/releasenotes/notes/fix-dd-trace-methods-2c1b4af30a7bf3ef.yaml b/releasenotes/notes/fix-dd-trace-methods-2c1b4af30a7bf3ef.yaml index f8979fc363e..3d13410555e 100644 --- a/releasenotes/notes/fix-dd-trace-methods-2c1b4af30a7bf3ef.yaml +++ b/releasenotes/notes/fix-dd-trace-methods-2c1b4af30a7bf3ef.yaml @@ -2,4 +2,7 @@ deprecations: - | tracing: Using ``[]`` for DD_TRACE_METHODS (``mymod.mysubmod.myclass[myfunc,otherfunc];...``) is deprecated and will be removed in 3.0.0. - You can use the new notation with ``:`` instead (``mymod.mysubmod:myclass.myfunc,myclass.otherfunc;...``) \ No newline at end of file + You can use the new notation with ``:`` instead (``mymod.mysubmod:myclass.myfunc,myclass.otherfunc;...``) +feature: + - | + tracing: \ No newline at end of file diff --git a/scripts/run-test-suite b/scripts/run-test-suite index b61f2b0d317..dc6e54677af 100755 --- a/scripts/run-test-suite +++ b/scripts/run-test-suite @@ -5,8 +5,6 @@ RIOT_PATTERN=${1} DDTRACE_FLAG=$([ -v _CI_DD_API_KEY ] && echo '--ddtrace') COVERAGE_FLAG=$([[ "${2:-false}" == false ]] && echo '--no-cov') DDTEST_CMD=$([[ ${3} == "1" ]] && echo "./scripts/ddtest") -# temporary workaround for pytest issues in CI jobs -DDTRACE_FLAG=$([[ "${4:-false}" == true ]] && echo '--no-ddtrace') RIOT_HASHES=( $(riot list --hash-only $RIOT_PATTERN | sort) ) echo "Found ${#RIOT_HASHES[@]} riot hashes: ${RIOT_HASHES[@]}" From 2897adaef8953836549d144ab6d27ec068607e21 Mon Sep 17 00:00:00 2001 From: erikayasuda Date: Wed, 21 Feb 2024 14:20:42 -0500 Subject: [PATCH 21/22] comment updates --- ddtrace/internal/tracemethods.py | 4 +++- releasenotes/notes/fix-dd-trace-methods-2c1b4af30a7bf3ef.yaml | 4 ++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/ddtrace/internal/tracemethods.py b/ddtrace/internal/tracemethods.py index 6c5a8572876..028fb6b2fba 100644 --- a/ddtrace/internal/tracemethods.py +++ b/ddtrace/internal/tracemethods.py @@ -13,7 +13,7 @@ def _parse_trace_methods(raw_dd_trace_methods: str) -> List[Tuple[str, str]]: DD_TRACE_METHODS is specified to be FullyQualifiedModuleName:comma-separated-methods;... - Note that support for wildcard methods ([*]) is not implemented. + Note that support for wildcard methods with * is not implemented. """ if not raw_dd_trace_methods: return [] @@ -62,6 +62,8 @@ def _parse_legacy_trace_methods(raw_dd_trace_methods: str) -> List[str]: Return a list of method names to trace based on the specification of DD_TRACE_METHODS. + Note that support for wildcard methods with [*] is not implemented. + This square bracket notation will be deprecated in favor of the new ':' notation TODO: This method can be deleted once the legacy syntax is officially deprecated """ diff --git a/releasenotes/notes/fix-dd-trace-methods-2c1b4af30a7bf3ef.yaml b/releasenotes/notes/fix-dd-trace-methods-2c1b4af30a7bf3ef.yaml index 3d13410555e..eff6961fe67 100644 --- a/releasenotes/notes/fix-dd-trace-methods-2c1b4af30a7bf3ef.yaml +++ b/releasenotes/notes/fix-dd-trace-methods-2c1b4af30a7bf3ef.yaml @@ -2,7 +2,7 @@ deprecations: - | tracing: Using ``[]`` for DD_TRACE_METHODS (``mymod.mysubmod.myclass[myfunc,otherfunc];...``) is deprecated and will be removed in 3.0.0. - You can use the new notation with ``:`` instead (``mymod.mysubmod:myclass.myfunc,myclass.otherfunc;...``) feature: - | - tracing: \ No newline at end of file + tracing: Updates DD_TRACE_METHODS to use a new notation with ``:`` to differentiate between the base module and the method name + (``mymod.mysubmod:myclass.myfunc,myclass.otherfunc;...``) \ No newline at end of file From a6850c206ee20acedc75d20879e19dfaf9871334 Mon Sep 17 00:00:00 2001 From: erikayasuda Date: Wed, 21 Feb 2024 14:42:50 -0500 Subject: [PATCH 22/22] fix release note syntax --- releasenotes/notes/fix-dd-trace-methods-2c1b4af30a7bf3ef.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/releasenotes/notes/fix-dd-trace-methods-2c1b4af30a7bf3ef.yaml b/releasenotes/notes/fix-dd-trace-methods-2c1b4af30a7bf3ef.yaml index eff6961fe67..65bb6b3e628 100644 --- a/releasenotes/notes/fix-dd-trace-methods-2c1b4af30a7bf3ef.yaml +++ b/releasenotes/notes/fix-dd-trace-methods-2c1b4af30a7bf3ef.yaml @@ -2,7 +2,7 @@ deprecations: - | tracing: Using ``[]`` for DD_TRACE_METHODS (``mymod.mysubmod.myclass[myfunc,otherfunc];...``) is deprecated and will be removed in 3.0.0. -feature: +features: - | tracing: Updates DD_TRACE_METHODS to use a new notation with ``:`` to differentiate between the base module and the method name (``mymod.mysubmod:myclass.myfunc,myclass.otherfunc;...``) \ No newline at end of file