@@ -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
+ Auto-instrumentation exists for some popular Python frameworks.
19
+
20
+ {{% alert title="Note" %}}
21
+
22
+ Use auto-instrumentation or instrumentation libraries to propagate context.
23
+ Although it is possible to propagate context manually, the Python
24
+ auto-instrumentation and instrumentation libraries are well-tested and easier
25
+ 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
70
+ parsed HTTP 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, read the
116
+ [ Propagators API specification] ( /docs/specs/otel/context/api-propagators/ ) .
0 commit comments