Skip to content

Commit 2d7ed23

Browse files
theletterfchalin
andauthored
[Python] Edit propagation doc (#4803)
Co-authored-by: Patrice Chalin <[email protected]>
1 parent 175d63f commit 2d7ed23

File tree

1 file changed

+28
-6
lines changed

1 file changed

+28
-6
lines changed

content/en/docs/languages/python/propagation.md

+28-6
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,29 @@ Although not limited to tracing, it is what allows traces to build causal
99
information about a system across services that are arbitrarily distributed
1010
across process and network boundaries.
1111

12-
## Manual W3C Trace Context Propagation
12+
OpenTelemetry provides a text-based approach to propagate context to remote
13+
services using the [W3C Trace Context](https://www.w3.org/TR/trace-context/)
14+
HTTP headers.
1315

14-
The following generic example demonstrates how you can propagate trace context
16+
## Automatic context propagation
17+
18+
Instrumentation libraries for popular Python frameworks and libraries, such as
19+
Jinja2, Flask, Django, and Celery.propagate context across services for you.
20+
21+
{{% alert title="Note" %}}
22+
23+
Use instrumentation libraries to propagate context. Although it is possible to
24+
propagate context manually, the Python auto-instrumentation and instrumentation
25+
libraries are well-tested and easier to use.
26+
27+
{{% /alert %}}
28+
29+
## Manual context propagation
30+
31+
The following generic example shows how you can propagate trace context
1532
manually.
1633

17-
First, on the sending service, you'll need to inject the current `context`:
34+
First, on the sending service, inject the current `context`:
1835

1936
```python
2037
from flask import Flask
@@ -49,8 +66,8 @@ if __name__ == '__main__':
4966
app.run(port=5002)
5067
```
5168

52-
On the receiving service, you'll need to extract `context` (for example, from
53-
parsed HTTP headers) and then set them as the current trace context.
69+
On the receiving service, extract `context`, for example, from parsed HTTP
70+
headers, and then set them as the current trace context.
5471

5572
```python
5673
from flask import Flask, request
@@ -91,4 +108,9 @@ if __name__ == '__main__':
91108
```
92109

93110
From there, when you have a deserialized active context, you can create spans
94-
that will be a part of the same trace from the other service.
111+
that are part of the same trace from the other service.
112+
113+
## Next steps
114+
115+
To learn more about propagation, see
116+
[Propagators API](/docs/specs/otel/context/api-propagators/).

0 commit comments

Comments
 (0)