Skip to content

Commit

Permalink
docs(tracing): remove patch_all from basic usage docs [3.0] (DataDog#…
Browse files Browse the repository at this point in the history
…11868)

Resolves: DataDog#11865

- Removes documentation for `ddtrace.patch_all(...)` from basic usage.
We should encourage the use of `ddtrace.auto` instead.
- For fine grained control over enabling/disabling integrations
`DD_PATCH_MODULES` and `DD_TRACE_<Integration>_ENABLED` should be used.

## Checklist
- [ ] PR author has checked that all the criteria below are met
- The PR description includes an overview of the change
- The PR description articulates the motivation for the change
- The change includes tests OR the PR description describes a testing
strategy
- The PR description notes risks associated with the change, if any
- Newly-added code is easy to change
- The change follows the [library release note
guidelines](https://ddtrace.readthedocs.io/en/stable/releasenotes.html)
- The change includes or references documentation updates if necessary
- Backport labels are set (if
[applicable](https://ddtrace.readthedocs.io/en/latest/contributing.html#backporting))

## Reviewer Checklist
- [x] Reviewer has checked that all the criteria below are met 
- Title is accurate
- All changes are related to the pull request's stated goal
- Avoids breaking
[API](https://ddtrace.readthedocs.io/en/stable/versioning.html#interfaces)
changes
- Testing strategy adequately addresses listed risks
- Newly-added code is easy to change
- Release note makes sense to a user of the library
- If necessary, author has acknowledged and discussed the performance
implications of this PR as reported in the benchmarks PR comment
- Backport labels are set in a manner that is consistent with the
[release branch maintenance
policy](https://ddtrace.readthedocs.io/en/latest/contributing.html#backporting)

---------

Co-authored-by: Gabriele N. Tornetta <[email protected]>
Co-authored-by: Emmett Butler <[email protected]>
  • Loading branch information
3 people authored Jan 12, 2025
1 parent a58f139 commit d0b151a
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 46 deletions.
2 changes: 1 addition & 1 deletion ddtrace/_monkey.py
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ def on_import(hook):

def patch_all(**patch_modules):
# type: (bool) -> None
"""Automatically patches all available modules.
"""Enables ddtrace library instrumentation.
In addition to ``patch_modules``, an override can be specified via an
environment variable, ``DD_TRACE_<module>_ENABLED`` for each module.
Expand Down
32 changes: 6 additions & 26 deletions docs/basic_usage.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,39 +3,19 @@
Basic Usage
===========

Tracing
~~~~~~~
Automatic Instrumentation
~~~~~~~~~~~~~~~~~~~~~~~~~

``ddtrace.auto``
----------------

To set up instrumentation within your application, call :ref:`import ddtrace.auto<ddtraceauto>` as early as possible
To enable full ddtrace support (library instrumentation, profiling, application security monitoring, dynamic instrumentation, etc.) call :ref:`import ddtrace.auto<ddtraceauto>` as the very first thing
in your application. This will only work if your application is not running under ``ddtrace-run``.

``patch_all``
-------------

For fine-grained control over instrumentation setup, use ``patch_all`` as early as possible
in the application::

from ddtrace import patch_all
patch_all()

To toggle instrumentation for a particular module::

from ddtrace import patch_all
patch_all(redis=False, cassandra=False)

By default all supported libraries will be instrumented when ``patch_all`` is
used.

**Note:** To ensure that the supported libraries are instrumented properly in
the application, they must be patched *prior* to being imported. So make sure
to call ``patch_all`` *before* importing libraries that are to be instrumented.

More information about ``patch_all`` is available in the :py:func:`patch_all<ddtrace.patch_all>` API
documentation.
Note: Some Datadog products and instrumentation are disabled by default. Products and instrumentation can be enabled/disable via environment variables, see :ref:`configurations <Configuration>` page for more details.

Tracing
~~~~~~~

Manual Instrumentation
----------------------
Expand Down
2 changes: 1 addition & 1 deletion docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ contacting support.

.. [1] Libraries that are automatically instrumented when the
:ref:`ddtrace-run<ddtracerun>` command is used or the ``import ddtrace.auto`` import
is used. Always use ``patch()``, ``patch_all()``, and ``import ddtrace.auto`` as soon
is used. Always use ``import ddtrace.auto`` as soon
as possible in your Python entrypoint.
.. [2] only the synchronous client
Expand Down
18 changes: 0 additions & 18 deletions docs/installation_quickstart.rst
Original file line number Diff line number Diff line change
Expand Up @@ -59,24 +59,6 @@ When ``ddtrace-run`` cannot be used, a similar start-up behavior can be achieved
with the import of ``ddtrace.auto``. This should normally be imported as the
first thing during the application start-up.

If neither ``ddtrace-run`` nor ``import ddtrace.auto`` are suitable for your application, then
:py:func:`ddtrace.patch_all` can be used to configure the tracer::

from ddtrace import config, patch_all

config.env = "dev" # the environment the application is in
config.service = "app" # name of your application
config.version = "0.1" # version of your application
patch_all()


.. note::
We recommend the use of ``ddtrace-run`` when possible. If you are importing
``ddtrace.auto`` as a programmatic replacement for ``ddtrace``, then note
that integrations will take their configuration from the environment
variables. A call to :py:func:`ddtrace.patch_all` cannot be used to disable
an integration at this point.


Service names also need to be configured for libraries that query other
services (``requests``, ``grpc``, database libraries, etc). Check out the
Expand Down

0 comments on commit d0b151a

Please sign in to comment.