Commit 695ea7f
committed
perf: Optimize telemetry latency logging and feature flag caching
Optimizations implemented:
1. Latency Logger (latency_logger.py):
- Eliminated extractor pattern - replaced wrapper classes with direct
attribute access functions, removing object creation overhead
- Switched from time.perf_counter() to time.monotonic() for faster timing
- Added feature flag early exit - checks cached telemetry_enabled flag
to skip heavy work when telemetry is disabled
- Simplified code structure with early returns for better readability
2. Feature Flag Caching (feature_flag.py):
- Changed cache key from session_id to host
- Feature flags now shared across multiple connections to same host
- Reduces network calls - first connection fetches, subsequent reuse cache
Performance impact:
- When telemetry disabled: significantly reduced overhead (only timing + debug log)
- When telemetry enabled: reduced overhead from data extraction optimizations
- Feature flag: Only fetched once per host instead of per session
- Overall: Reduces telemetry overhead substantially
The decorator now:
- Always logs latency at DEBUG level for debugging
- Exits early using cached connection.telemetry_enabled flag
- Only performs data extraction and object creation when telemetry is enabled1 parent 0687a29 commit 695ea7f
1 file changed
+5
-3
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
165 | 165 | | |
166 | 166 | | |
167 | 167 | | |
168 | | - | |
169 | | - | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
170 | 171 | | |
171 | 172 | | |
172 | 173 | | |
| |||
177 | 178 | | |
178 | 179 | | |
179 | 180 | | |
180 | | - | |
| 181 | + | |
| 182 | + | |
181 | 183 | | |
182 | 184 | | |
183 | 185 | | |
| |||
0 commit comments