diff --git a/ddtrace/contrib/_valkey.py b/ddtrace/contrib/_valkey.py deleted file mode 100644 index 59a87e5a677..00000000000 --- a/ddtrace/contrib/_valkey.py +++ /dev/null @@ -1,68 +0,0 @@ -""" -The valkey integration traces valkey requests. - - -Enabling -~~~~~~~~ - -The valkey integration is enabled automatically when using -:ref:`ddtrace-run` or :ref:`import ddtrace.auto`. - -Or use :func:`patch()` to manually enable the integration:: - - from ddtrace import patch - patch(valkey=True) - - -Global Configuration -~~~~~~~~~~~~~~~~~~~~ - -.. py:data:: ddtrace.config.valkey["service"] - - The service name reported by default for valkey traces. - - This option can also be set with the ``DD_VALKEY_SERVICE`` environment - variable. - - Default: ``"valkey"`` - - -.. py:data:: ddtrace.config.valkey["cmd_max_length"] - - Max allowable size for the valkey command span tag. - Anything beyond the max length will be replaced with ``"..."``. - - This option can also be set with the ``DD_VALKEY_CMD_MAX_LENGTH`` environment - variable. - - Default: ``1000`` - - -.. py:data:: ddtrace.config.valkey["resource_only_command"] - - The span resource will only include the command executed. To include all - arguments in the span resource, set this value to ``False``. - - This option can also be set with the ``DD_VALKEY_RESOURCE_ONLY_COMMAND`` environment - variable. - - Default: ``True`` - - -Instance Configuration -~~~~~~~~~~~~~~~~~~~~~~ - -To configure particular valkey instances use the :class:`Pin ` API:: - - import valkey - from ddtrace.trace import Pin - - client = valkey.StrictValkey(host="localhost", port=6379) - - # Override service name for this instance - Pin.override(client, service="my-custom-queue") - - # Traces reported for this client will now have "my-custom-queue" - # as the service name. - client.get("my-key") -""" \ No newline at end of file diff --git a/docs/integrations.rst b/docs/integrations.rst index cb107ea6105..d14c03bcfb7 100644 --- a/docs/integrations.rst +++ b/docs/integrations.rst @@ -489,7 +489,7 @@ urllib3 valkey ^^^^^^ -.. automodule:: ddtrace.contrib._valkey +.. automodule:: ddtrace.contrib.valkey .. _vertexai: diff --git a/tests/internal/test_module.py b/tests/internal/test_module.py index d93c361ac3f..5df30dc9761 100644 --- a/tests/internal/test_module.py +++ b/tests/internal/test_module.py @@ -529,24 +529,23 @@ def test_module_import_side_effect(): def test_public_modules_in_ddtrace_contrib(): - # Ensures that public modules are not accidentally added to the integration API + # Ensures that public modules are not accidentally added to ddtrace.contrib contrib_dir = Path(DDTRACE_PATH) / "ddtrace" / "contrib" public_modules = set() for directory, _, file_names in os.walk(contrib_dir): relative_dir = Path(directory).relative_to(contrib_dir) - if "internal" in relative_dir.parts or any([x.startswith("_") for x in relative_dir.parts]): + if "internal" in relative_dir.parts: + # ignore modules in ddtrace/contrib/internal continue - # Open files in ddtrace/contrib/ and check if the content matches the template for file_name in file_names: - # Skip internal and __init__ modules, as they are not supposed to have the deprecation template - if file_name.endswith(".py") and not (file_name.startswith("_") or file_name == "__init__.py"): - # Get the relative path of the file from ddtrace/contrib to the deprecated file (ex: pymongo/patch) - relative_dir_with_file = relative_dir / file_name[:-3] # Remove the .py extension - # Convert the relative path to python module format (ex: [pymongo, patch] -> pymongo.patch) - sub_modules = ".".join(relative_dir_with_file.parts) - public_modules.add(f"ddtrace.contrib.{sub_modules}") + # Ignore private modules (python files prefixed with "_") + if file_name.endswith(".py") and not file_name.startswith("_"): + # Covert filename to a module name (ex: dd-trace-py/ddtrace/contrib/flask.py -> ddtrace.contrib.flask) + relative_dir_with_file = relative_dir / file_name[:-3] + module_name = "ddtrace.contrib." + ".".join(relative_dir_with_file.parts) + public_modules.add(module_name) # The following modules contain attributes that are exposed to ddtrace users. All other modules in ddtrace.contrib # are internal.