use DTRACE_ENV_VAR as the trace logs directory of set (#146412)

```
(/home/bobren/local/a/pytorch-env) [7:47] devgpu035:/home/bobren/local/a/pytorch TORCH_DTRACE=/tmp/bb python r1.py
```
Pull Request resolved: https://github.com/pytorch/pytorch/pull/146412
Approved by: https://github.com/angelayi
ghstack dependencies: #145848
This commit is contained in:
bobrenjc93
2025-02-04 07:57:12 -08:00
committed by PyTorch MergeBot
parent 7f65a20884
commit d23e4f8109

View File

@ -1001,8 +1001,9 @@ def _init_logs(log_file_name=None):
# configuration
trace_dir_name = os.environ.get(TRACE_ENV_VAR, None)
if os.environ.get(DTRACE_ENV_VAR, None):
if dtrace_dir_name := os.environ.get(DTRACE_ENV_VAR, None):
GET_DTRACE_STRUCTURED = True
trace_dir_name = dtrace_dir_name
# This handler may remove itself if trace_dir_name is None and we are not
# actually in an FB environment. This allows us to defer actually