|
| 1 | +# Telemetry Unification Summary |
| 2 | + |
| 3 | +## Overview |
| 4 | + |
| 5 | +The telemetry system has been unified to use a single `--use_telemetry` flag across all platforms, with platform-specific implementations: |
| 6 | +- **Windows**: ETW (Event Tracing for Windows) |
| 7 | +- **POSIX (macOS, Linux, iOS, Android)**: 1DS SDK via `cpp_client_telemetry` |
| 8 | + |
| 9 | +## Key Changes Made |
| 10 | + |
| 11 | +### 1. Unified Flag Naming |
| 12 | +- **Single Flag**: `--use_telemetry` now works consistently across all platforms |
| 13 | +- **Removed**: `--use_1ds_telemetry` (no longer needed) |
| 14 | +- **CMake Variable**: `onnxruntime_USE_TELEMETRY` is set for all platforms |
| 15 | +- Platform-specific telemetry backend is automatically selected based on the build platform |
| 16 | + |
| 17 | +### 2. Build Scripts Updated |
| 18 | + |
| 19 | +#### `build.sh` (POSIX platforms) |
| 20 | +- **Default Behavior**: Telemetry is enabled by default for all POSIX platforms |
| 21 | +- **Implementation**: Automatically passes `--use_telemetry` flag |
| 22 | +- **Comment**: Added clarifying comment about 1DS usage |
| 23 | + |
| 24 | +#### `build.bat` (Windows) |
| 25 | +- **Default Behavior**: Telemetry is enabled by default |
| 26 | +- **Implementation**: Uses ETW telemetry |
| 27 | +- **No Changes**: Windows behavior remains unchanged |
| 28 | + |
| 29 | +### 3. Build Arguments (`build_args.py`) |
| 30 | +- **Moved**: `--use_telemetry` from Windows-specific to general feature args |
| 31 | +- **Help Text**: Updated to clarify platform-specific behavior |
| 32 | + - "Enable telemetry (ETW on Windows, 1DS SDK on other platforms)" |
| 33 | +- **Location**: `add_other_feature_args()` function |
| 34 | + |
| 35 | +### 4. Build Script (`build.py`) |
| 36 | +- **Unified CMake Argument**: Single `-Donnxruntime_USE_TELEMETRY` flag before platform-specific logic |
| 37 | +- **Platform Detection**: Automatically chooses ETW (Windows) or 1DS (POSIX) based on `is_windows()` |
| 38 | + |
| 39 | +### 5. CMake Integration (`onnxruntime_1ds_telemetry.cmake`) |
| 40 | +- **Condition**: `if(onnxruntime_USE_TELEMETRY AND NOT WIN32)` |
| 41 | +- **Implementation**: Automatically includes cpp_client_telemetry for non-Windows builds |
| 42 | +- **Defines**: Sets `USE_1DS_TELEMETRY` compile definition for POSIX platforms |
| 43 | + |
| 44 | +### 6. cpp_client_telemetry Submodule |
| 45 | +- **Location**: `cmake/external/cpp_client_telemetry` |
| 46 | +- **Status**: Already present in `.gitmodules` |
| 47 | +- **URL**: https://github.com/microsoft/cpp_client_telemetry.git |
| 48 | +- **Initialization**: Automatically handled by `git submodule update --init --recursive` |
| 49 | + |
| 50 | +### 7. Documentation Updated |
| 51 | + |
| 52 | +#### `README_TELEMETRY.md` |
| 53 | +- **Title**: Updated to reflect unified telemetry system |
| 54 | +- **Build Instructions**: Clarified `--use_telemetry` flag usage for all platforms |
| 55 | +- **Platform Behavior**: Documented ETW vs 1DS selection |
| 56 | +- **Testing**: Updated with unified flag examples |
| 57 | +- **Privacy**: Updated to reflect opt-in (telemetry disabled by default, except when using build.sh/build.bat) |
| 58 | + |
| 59 | +## Current Status |
| 60 | + |
| 61 | +### ? Completed |
| 62 | +1. Flag unification across platforms |
| 63 | +2. Build scripts updated (build.sh, build.bat, build.py, build_args.py) |
| 64 | +3. CMake integration working (onnxruntime_1ds_telemetry.cmake) |
| 65 | +4. Documentation updated |
| 66 | +5. cpp_client_telemetry submodule present |
| 67 | + |
| 68 | +### ?? To Be Implemented |
| 69 | +The 1DS telemetry event logging methods in `telemetry_1ds.cc` need implementation: |
| 70 | +- `LogProcessInfo()` |
| 71 | +- `LogSessionCreation()` |
| 72 | +- `LogSessionCreationStart()` |
| 73 | +- `LogEvaluationStart()` |
| 74 | +- `LogEvaluationStop()` |
| 75 | +- `LogRuntimeError()` |
| 76 | +- `LogRuntimePerf()` |
| 77 | +- `LogCompileModelStart()` |
| 78 | +- `LogCompileModelComplete()` |
| 79 | +- `LogAutoEpSelection()` |
| 80 | +- `LogProviderOptions()` |
| 81 | + |
| 82 | +Each method currently has a `// TODO: Implement using 1DS SDK` comment. |
| 83 | + |
| 84 | +## Usage Examples |
| 85 | + |
| 86 | +### Enable Telemetry (All Platforms) |
| 87 | + |
| 88 | +**macOS/Linux:** |
| 89 | +```bash |
| 90 | +# Default (telemetry enabled via build.sh) |
| 91 | +./build.sh --config Release |
| 92 | + |
| 93 | +# Or explicitly via build.py |
| 94 | +python tools/ci_build/build.py --build_dir build/Linux --use_telemetry --config Release |
| 95 | +``` |
| 96 | + |
| 97 | +**Windows:** |
| 98 | +```cmd |
| 99 | +REM Default (telemetry enabled via build.bat) |
| 100 | +build.bat --config Release |
| 101 | +
|
| 102 | +REM Or explicitly via build.py |
| 103 | +python tools\ci_build\build.py --build_dir build\Windows --use_telemetry --config Release |
| 104 | +``` |
| 105 | + |
| 106 | +### Disable Telemetry |
| 107 | + |
| 108 | +**All Platforms:** |
| 109 | +```bash |
| 110 | +# Call build.py directly without --use_telemetry |
| 111 | +python tools/ci_build/build.py --build_dir build/Linux --config Release |
| 112 | + |
| 113 | +# Or via CMake |
| 114 | +cmake -Donnxruntime_USE_TELEMETRY=OFF ... |
| 115 | +``` |
| 116 | + |
| 117 | +## Architecture |
| 118 | + |
| 119 | +``` |
| 120 | +??????????????????????????????????????????????????????????? |
| 121 | +? User Invokes build.sh / build.bat ? |
| 122 | +? (--use_telemetry added automatically) ? |
| 123 | +??????????????????????????????????????????????????????????? |
| 124 | + ? |
| 125 | + ? |
| 126 | +??????????????????????????????????????????????????????????? |
| 127 | +? build.py (tools/ci_build/) ? |
| 128 | +? Sets: -Donnxruntime_USE_TELEMETRY=ON ? |
| 129 | +??????????????????????????????????????????????????????????? |
| 130 | + ? |
| 131 | + ??????????????????????????? |
| 132 | + ? ? |
| 133 | + ? ? |
| 134 | +???????????????????????? ???????????????????????? |
| 135 | +? Windows Build ? ? POSIX Build ? |
| 136 | +? Uses ETW ? ? Uses 1DS SDK ? |
| 137 | +? (no extra setup) ? ? (cpp_client_tel.) ? |
| 138 | +???????????????????????? ???????????????????????? |
| 139 | + ? ? |
| 140 | + ? ? |
| 141 | + ? ???????????????????????? |
| 142 | + ? ? CMake includes ? |
| 143 | + ? ? onnxruntime_1ds_ ? |
| 144 | + ? ? telemetry.cmake ? |
| 145 | + ? ???????????????????????? |
| 146 | + ? ? |
| 147 | + ??????????????????????????? |
| 148 | + ? |
| 149 | + ? |
| 150 | + ?????????????????????????????? |
| 151 | + ? Runtime Telemetry Active ? |
| 152 | + ? - Windows: ETW events ? |
| 153 | + ? - POSIX: 1DS events ? |
| 154 | + ?????????????????????????????? |
| 155 | +``` |
| 156 | + |
| 157 | +## Testing Instructions |
| 158 | + |
| 159 | +### 1. Initialize Submodules |
| 160 | +```bash |
| 161 | +git submodule update --init --recursive |
| 162 | +``` |
| 163 | + |
| 164 | +### 2. Build with Telemetry |
| 165 | + |
| 166 | +**macOS/Linux:** |
| 167 | +```bash |
| 168 | +./build.sh --config Release |
| 169 | +``` |
| 170 | + |
| 171 | +**Windows:** |
| 172 | +```cmd |
| 173 | +build.bat --config Release |
| 174 | +``` |
| 175 | + |
| 176 | +### 3. Verify Telemetry Initialization |
| 177 | + |
| 178 | +Check build logs for: |
| 179 | +- **POSIX**: "1DS telemetry initialized for [platform]" |
| 180 | +- **Windows**: ETW registration success messages |
| 181 | + |
| 182 | +### 4. Run Tests |
| 183 | +```bash |
| 184 | +cd build/[Platform]/Release |
| 185 | +./onnxruntime_test_all |
| 186 | +``` |
| 187 | + |
| 188 | +## Backwards Compatibility |
| 189 | + |
| 190 | +### Breaking Changes |
| 191 | +- `--use_1ds_telemetry` flag is no longer recognized |
| 192 | +- Users must use `--use_telemetry` instead |
| 193 | + |
| 194 | +### Migration Guide |
| 195 | +**Old command:** |
| 196 | +```bash |
| 197 | +python tools/ci_build/build.py --use_1ds_telemetry ... |
| 198 | +``` |
| 199 | + |
| 200 | +**New command:** |
| 201 | +```bash |
| 202 | +python tools/ci_build/build.py --use_telemetry ... |
| 203 | +``` |
| 204 | + |
| 205 | +Or simply use the build scripts which enable telemetry by default: |
| 206 | +```bash |
| 207 | +./build.sh # POSIX |
| 208 | +build.bat # Windows |
| 209 | +``` |
| 210 | + |
| 211 | +## Configuration Files |
| 212 | + |
| 213 | +### Telemetry Token Configuration |
| 214 | + |
| 215 | +**For POSIX (1DS):** |
| 216 | +1. **Environment Variable** (testing): |
| 217 | + ```bash |
| 218 | + export ORT_TELEMETRY_TOKEN="your-guid-here" |
| 219 | + ``` |
| 220 | + |
| 221 | +2. **Config File** (production): |
| 222 | + ```json |
| 223 | + // onnxruntime/core/platform/posix/telemetry_config.json |
| 224 | + { |
| 225 | + "telemetry": { |
| 226 | + "tenant_token": "your-guid-here", |
| 227 | + "enabled": true, |
| 228 | + ... |
| 229 | + } |
| 230 | + } |
| 231 | + ``` |
| 232 | + |
| 233 | +**For Windows (ETW):** |
| 234 | +- Uses `TELEMETRYGUID` environment variable set by CI scripts |
| 235 | +- See `tools/ci_build/github/windows/set_telemetry_var.ps1` |
| 236 | + |
| 237 | +## Next Steps |
| 238 | + |
| 239 | +1. **Implement 1DS Event Logging**: Complete the TODO items in `telemetry_1ds.cc` |
| 240 | +2. **Add Unit Tests**: Test telemetry initialization and event logging |
| 241 | +3. **Performance Testing**: Verify overhead of telemetry collection |
| 242 | +4. **Token Management**: Implement secure token storage and rotation |
| 243 | +5. **Event Schema Documentation**: Document the structure of each telemetry event |
| 244 | + |
| 245 | +## References |
| 246 | + |
| 247 | +- **1DS SDK**: https://github.com/microsoft/cpp_client_telemetry |
| 248 | +- **ETW Documentation**: https://learn.microsoft.com/en-us/windows/win32/etw/about-event-tracing |
| 249 | +- **ONNX Runtime Docs**: docs/Telemetry.md |
| 250 | + |
| 251 | +## Contact |
| 252 | + |
| 253 | +For questions about the telemetry unification: |
| 254 | +- Create a GitHub issue with the `telemetry` label |
| 255 | +- Contact the ONNX Runtime team |
0 commit comments