Commit 7a93c25
authored
Refactor OpenTelemetry environment variable handling to use ray_constants (#57910)
1. **Remove direct environment variable access patterns**
- Replace all instances of `os.getenv("RAY_enable_open_telemetry") ==
"1"`
- Standardize to use `ray_constants.RAY_ENABLE_OPEN_TELEMETRY`
consistently throughout the codebase
2. **Unify default value format for RAY_enable_open_telemetry**
- Standardize the default value to `"true"` | `"false"`
- Previously, the codebase had mixed usage of `"1"` and `"true"`, which
is now unified
3. **Backward compatibility maintained**
- Carefully verified that the existing `RAY_ENABLE_OPEN_TELEMETRY`
constant properly handles both `"1"` and `"true"` values
- This change will not introduce any breaking behavior
- The `env_bool` helper function already supports both formats:
```python
RAY_ENABLE_OPEN_TELEMETRY = env_bool("RAY_enable_open_telemetry", False)
def env_bool(key, default):
if key in os.environ:
return (
True
if os.environ[key].lower() == "true" or os.environ[key] == "1"
else False
)
return default
```
---
Most of the current code uses: `RAY_enable_open_telemetry: "1"`
A smaller portion (not zero) uses: `RAY_enable_open_telemetry: "true"`
https://github.com/ray-project/ray/blob/fe7ad00f9720a722fde5fecba5bb681234bcdb63/python/ray/tests/test_metrics_agent.py#L497
My personal preference is "true"—it’s concise and unambiguous. If it’s
"1", I have to think/guess whether it means "true" or "false".
---------
Signed-off-by: justwph <[email protected]>1 parent 33ba50e commit 7a93c25
File tree
6 files changed
+16
-12
lines changed- python/ray
- dashboard/modules/reporter/tests
- tests
- util
- src/ray/stats/tests
6 files changed
+16
-12
lines changedLines changed: 2 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
204 | 204 | | |
205 | 205 | | |
206 | 206 | | |
207 | | - | |
| 207 | + | |
208 | 208 | | |
209 | | - | |
| 209 | + | |
210 | 210 | | |
211 | 211 | | |
212 | 212 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
85 | 85 | | |
86 | 86 | | |
87 | 87 | | |
88 | | - | |
| 88 | + | |
89 | 89 | | |
90 | 90 | | |
91 | 91 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
18 | 18 | | |
19 | 19 | | |
20 | 20 | | |
| 21 | + | |
21 | 22 | | |
22 | 23 | | |
23 | 24 | | |
| |||
41 | 42 | | |
42 | 43 | | |
43 | 44 | | |
44 | | - | |
| 45 | + | |
45 | 46 | | |
46 | 47 | | |
47 | 48 | | |
| |||
151 | 152 | | |
152 | 153 | | |
153 | 154 | | |
154 | | - | |
| 155 | + | |
155 | 156 | | |
156 | 157 | | |
157 | 158 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
22 | 22 | | |
23 | 23 | | |
24 | 24 | | |
25 | | - | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
26 | 29 | | |
27 | 30 | | |
28 | 31 | | |
| |||
204 | 207 | | |
205 | 208 | | |
206 | 209 | | |
207 | | - | |
| 210 | + | |
208 | 211 | | |
209 | 212 | | |
210 | 213 | | |
| |||
320 | 323 | | |
321 | 324 | | |
322 | 325 | | |
323 | | - | |
| 326 | + | |
324 | 327 | | |
325 | 328 | | |
326 | 329 | | |
| |||
744 | 747 | | |
745 | 748 | | |
746 | 749 | | |
747 | | - | |
| 750 | + | |
748 | 751 | | |
749 | 752 | | |
750 | 753 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | | - | |
3 | 2 | | |
4 | 3 | | |
5 | 4 | | |
6 | 5 | | |
| 6 | + | |
7 | 7 | | |
8 | 8 | | |
9 | 9 | | |
| |||
198 | 198 | | |
199 | 199 | | |
200 | 200 | | |
201 | | - | |
| 201 | + | |
202 | 202 | | |
203 | 203 | | |
204 | 204 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
5 | 5 | | |
6 | 6 | | |
7 | 7 | | |
8 | | - | |
| 8 | + | |
9 | 9 | | |
10 | 10 | | |
11 | 11 | | |
| |||
0 commit comments