Skip to content

Commit e811f7d

Browse files
author
Emanuele Palazzetti
authored
Merge pull request #301 from palazzem/docs
[docs] update documentation after latest changes
2 parents eac54e1 + 30680d9 commit e811f7d

File tree

6 files changed

+47
-37
lines changed

6 files changed

+47
-37
lines changed

ddtrace/contrib/aiobotocore/__init__.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
"""
2-
The aiobotocore integration will trace all AWS calls made with the `aiobotocore`
3-
library.
2+
The aiobotocore integration will trace all AWS calls made with the ``aiobotocore``
3+
library. This integration isn't enabled when applying the default patching.
4+
To enable it, you must run ``patch_all(botocore=True)``
45
5-
This integration ignores autopatching, it can be enabled via
6-
`patch_all(botocore=True)`
76
::
87
98
import aiobotocore.session
@@ -15,7 +14,8 @@
1514
# This will report spans with the default instrumentation
1615
aiobotocore.session.get_session()
1716
lambda_client = session.create_client('lambda', region_name='us-east-1')
18-
# Example of instrumented query
17+
18+
# This query generates a trace
1919
lambda_client.list_functions()
2020
"""
2121
from ..util import require_modules

ddtrace/contrib/aiohttp/__init__.py

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -17,27 +17,28 @@
1717
trace_app(app, tracer, service='async-api')
1818
web.run_app(app, port=8000)
1919
20-
Tracer settings are available under the `datadog_trace` namespace:
21-
22-
* `tracer` (default: `ddtrace.tracer`): set the default tracer instance that is used to
23-
trace `aiohttp` internals. By default the `ddtrace` tracer is used.
24-
* `service` (default: `aiohttp-web`): set the service name used by the tracer. Usually
25-
this configuration must be updated with a meaningful name.
26-
* `distributed_tracing_enabled` (default: `False): enable distributed tracing during
27-
the middleware execution, so that a new span is created with the given `trace_id` and
28-
`parent_id` passed via request headers.
29-
30-
To update your settings, just:
20+
Integration settings are attached to your application under the ``datadog_trace``
21+
namespace. You can read or update them as follows::
3122
3223
# activates distributed tracing for all received requests
3324
app['datadog_trace']['distributed_tracing_enabled'] = True
3425
26+
Available settings are:
27+
28+
* ``tracer`` (default: ``ddtrace.tracer``): set the default tracer instance that is used to
29+
trace `aiohttp` internals. By default the `ddtrace` tracer is used.
30+
* ``service`` (default: ``aiohttp-web``): set the service name used by the tracer. Usually
31+
this configuration must be updated with a meaningful name.
32+
* ``distributed_tracing_enabled`` (default: ``False``): enable distributed tracing during
33+
the middleware execution, so that a new span is created with the given ``trace_id`` and
34+
``parent_id`` injected via request headers.
35+
3536
Third-party modules that are currently supported by the ``patch()`` method are:
3637
3738
* ``aiohttp_jinja2``
3839
39-
When a request span is automatically created, the ``Context`` for this logical execution
40-
is attached to the ``request`` object, so that it can be used in the application code::
40+
When a request span is created, a new ``Context`` for this logical execution is attached
41+
to the ``request`` object, so that it can be used in the application code::
4142
4243
async def home_handler(request):
4344
ctx = request['datadog_context']

ddtrace/contrib/aiopg/__init__.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
1-
"""Instrument aiopg to report Postgres queries.
2-
3-
``patch`` will automatically patch your aiopg connection to make it work.
4-
::
1+
"""
2+
Instrument `aiopg` to report a span for each executed Postgres queries::
53
64
from ddtrace import Pin, patch
75
import aiopg
@@ -12,13 +10,14 @@
1210
# This will report a span with the default settings
1311
async with aiopg.connect(DSN) as db:
1412
with (await db.cursor()) as cursor:
15-
await cursor.execute("select * from users where id = 1")
13+
await cursor.execute("SELECT * FROM users WHERE id = 1")
1614
1715
# Use a pin to specify metadata related to this connection
1816
Pin.override(db, service='postgres-users')
1917
"""
2018
from ..util import require_modules
2119

20+
2221
required_modules = ['aiopg']
2322

2423
with require_modules(required_modules) as missing_modules:

ddtrace/contrib/asyncio/__init__.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,12 @@ async def some_work():
3131
``loop.run_in_executor`` that attaches the current context to the
3232
new thread so that the trace can be resumed regardless when
3333
it's executed
34+
* ``create_task(coro)``: creates a new asyncio ``Task`` that inherits
35+
the current active ``Context`` so that generated traces in the new task
36+
are attached to the main trace
37+
38+
A ``patch(asyncio=True)`` is available if you want to automatically use above
39+
wrappers without changing your code.
3440
"""
3541
from ..util import require_modules
3642

ddtrace/contrib/asyncio/helpers.py

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44
Context and Spans in instrumented ``asyncio`` code.
55
"""
66
import asyncio
7-
from asyncio.base_events import BaseEventLoop
87
import ddtrace
8+
from asyncio.base_events import BaseEventLoop
99

1010
from .provider import CONTEXT_ATTR
1111
from ...context import Context
@@ -87,15 +87,18 @@ def create_task(*args, **kwargs):
8787

8888

8989
def _wrapped_create_task(wrapped, instance, args, kwargs):
90-
# Note: we can't just link the task contexts due to the following scenario:
91-
# begin task A
92-
# task A starts task B1..B10
93-
# finish task B1-B9 (B10 still on trace stack)
94-
# task A starts task C
95-
#
96-
# now task C gets parented to task B10 since it's still on the stack, however
97-
# was not actually triggered by B10
98-
90+
"""Wrapper for ``create_task(coro)`` that propagates the current active
91+
``Context`` to the new ``Task``. This function is useful to connect traces
92+
of detached executions.
93+
94+
Note: we can't just link the task contexts due to the following scenario:
95+
* begin task A
96+
* task A starts task B1..B10
97+
* finish task B1-B9 (B10 still on trace stack)
98+
* task A starts task C
99+
* now task C gets parented to task B10 since it's still on the stack,
100+
however was not actually triggered by B10
101+
"""
99102
new_task = wrapped(*args, **kwargs)
100103
current_task = asyncio.Task.current_task()
101104

ddtrace/contrib/django/__init__.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@
1212
'ddtrace.contrib.django',
1313
]
1414
15-
# It might be MIDDLEWARE instead of MIDDLEWARE_CLASSES for Django 1.10+
16-
MIDDLEWARE_CLASSES = (
15+
# or MIDDLEWARE_CLASSES for Django pre 1.10
16+
MIDDLEWARE = (
1717
# the tracer must be the first middleware
1818
'ddtrace.contrib.django.TraceMiddleware',
1919
@@ -39,8 +39,10 @@
3939
4040
The available settings are:
4141
42-
* ``DEFAULT_SERVICE`` (default: ``django``): set the service name used by the
42+
* ``DEFAULT_SERVICE`` (default: ``'django'``): set the service name used by the
4343
tracer. Usually this configuration must be updated with a meaningful name.
44+
* ``DEFAULT_DATABASE_PREFIX`` (default: ``''``): set a prefix value to database services,
45+
so that your service is listed such as `prefix-defaultdb`.
4446
* ``TAGS`` (default: ``{}``): set global tags that should be applied to all
4547
spans.
4648
* ``TRACER`` (default: ``ddtrace.tracer``): set the default tracer
@@ -58,7 +60,6 @@
5860
disabled even if present.
5961
* ``AGENT_HOSTNAME`` (default: ``localhost``): define the hostname of the trace agent.
6062
* ``AGENT_PORT`` (default: ``8126``): define the port of the trace agent.
61-
* ``DEFAULT_DATABASE_PREFIX`` (default: ``''``): set a prefix value to database services.
6263
"""
6364
from ..util import require_modules
6465

0 commit comments

Comments
 (0)