@@ -9,12 +9,29 @@ Although not limited to tracing, it is what allows traces to build causal
9
9
information about a system across services that are arbitrarily distributed
10
10
across process and network boundaries.
11
11
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.
13
15
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
15
32
manually.
16
33
17
- First, on the sending service, you'll need to inject the current ` context ` :
34
+ First, on the sending service, inject the current ` context ` :
18
35
19
36
``` python
20
37
from flask import Flask
@@ -49,8 +66,8 @@ if __name__ == '__main__':
49
66
app.run(port = 5002 )
50
67
```
51
68
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.
54
71
55
72
``` python
56
73
from flask import Flask, request
@@ -91,4 +108,9 @@ if __name__ == '__main__':
91
108
```
92
109
93
110
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