Commit 1324488
authored
Reload propagators for distro config + Reorder propagators (#421)
## Issue
The [`OTEL_PROPAGATORS` configured in the
ADOT](https://github.com/aws-observability/aws-otel-python-instrumentation/blob/af71c4a100f0ae9c8d378db8487988344485b0c3/aws-opentelemetry-distro/src/amazon/opentelemetry/distro/aws_opentelemetry_distro.py#L73)
do not actually take effect. The configured propagators are still
`tracecontext` and `baggage` which are the default ones configured by
OTel SDK. This causes ADOT to ignore the `x-amzn-trace-id` trace header
causing broken traces if there is only XRay format trace being
propagated.
## Root Cause
- The [`opentelemetry.propagate`
module](https://github.com/open-telemetry/opentelemetry-python/blob/main/opentelemetry-api/src/opentelemetry/propagate/__init__.py)
has [the logic to load the
propagators](https://github.com/open-telemetry/opentelemetry-python/blob/0a2df97a72561552fb72e41c6fd092578a5f43e9/opentelemetry-api/src/opentelemetry/propagate/__init__.py#L124-L163)
configured via the `OTEL_PROPAGATORS` env variable. If the env variable
is not set, then it sets up the default propagators.
- This module is loaded and run very early in the OTel startup logic
even before the ADOT distro code is run which sets the
`OTEL_PROPAGATORS` env variable. This point is too late to modify the
OTEL_PROPAGATORS env variable.
## Solution
Set the `OTEL_PROPAGATORS` env variable in ADOT distro **and** reload
the `opentelemetry.propagate` module (using
[importlib.reload](https://docs.python.org/3/library/importlib.html#importlib.reload))
which will force it to reinitialize the intended propagators.
## Related Note
With this fix, the ADOT configured propagators will take effect, which
currently does not include `baggage` and will break some existing
functionality that depends on baggage. So I'm also also updating the
propagators set by the ADOT to:
- include `baggage`
- drop the B3 propagators as [ADOT JS
did](aws-observability/aws-otel-js-instrumentation@82e563c#diff-02388c43665de519f206132ad186755c563709c77f6de9f919a4e70fc51abc25)
- reorder to `baggage, xray, tracecontext`. This will be the order we
follow for other ADOT SDKs too ([JS already in
progress](aws-observability/aws-otel-js-instrumentation#210)).
By submitting this pull request, I confirm that you can use, modify,
copy, and redistribute this contribution, under the terms of your
choice.1 parent af71c4a commit 1324488
File tree
3 files changed
+70
-6
lines changed- aws-opentelemetry-distro
- src/amazon/opentelemetry/distro
- tests/amazon/opentelemetry/distro
3 files changed
+70
-6
lines changedLines changed: 12 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
| 3 | + | |
3 | 4 | | |
4 | 5 | | |
5 | 6 | | |
| |||
18 | 19 | | |
19 | 20 | | |
20 | 21 | | |
| 22 | + | |
21 | 23 | | |
22 | 24 | | |
23 | 25 | | |
| |||
70 | 72 | | |
71 | 73 | | |
72 | 74 | | |
73 | | - | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
74 | 85 | | |
75 | 86 | | |
76 | 87 | | |
| |||
aws-opentelemetry-distro/tests/amazon/opentelemetry/distro/test_aws_opentelementry_configurator.py
Lines changed: 1 addition & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1262 | 1262 | | |
1263 | 1263 | | |
1264 | 1264 | | |
1265 | | - | |
| 1265 | + | |
1266 | 1266 | | |
1267 | 1267 | | |
1268 | 1268 | | |
| |||
Lines changed: 57 additions & 4 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
| 3 | + | |
3 | 4 | | |
| 5 | + | |
4 | 6 | | |
5 | 7 | | |
6 | 8 | | |
7 | 9 | | |
8 | 10 | | |
| 11 | + | |
| 12 | + | |
9 | 13 | | |
10 | 14 | | |
11 | 15 | | |
| |||
40 | 44 | | |
41 | 45 | | |
42 | 46 | | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
43 | 50 | | |
44 | 51 | | |
45 | 52 | | |
| |||
50 | 57 | | |
51 | 58 | | |
52 | 59 | | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
53 | 63 | | |
54 | 64 | | |
55 | 65 | | |
| |||
65 | 75 | | |
66 | 76 | | |
67 | 77 | | |
68 | | - | |
| 78 | + | |
69 | 79 | | |
70 | 80 | | |
71 | 81 | | |
| |||
188 | 198 | | |
189 | 199 | | |
190 | 200 | | |
191 | | - | |
192 | | - | |
| 201 | + | |
193 | 202 | | |
194 | 203 | | |
195 | 204 | | |
196 | 205 | | |
197 | 206 | | |
198 | 207 | | |
199 | 208 | | |
200 | | - | |
| 209 | + | |
201 | 210 | | |
202 | 211 | | |
203 | 212 | | |
| |||
224 | 233 | | |
225 | 234 | | |
226 | 235 | | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
0 commit comments