-
Notifications
You must be signed in to change notification settings - Fork 1.1k
feat: add connection delay metric for soniox #1949
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
PR Review: Add Connection Delay Metric for SonioxSummaryThis PR adds connection delay metrics tracking to the Soniox ASR extension, measuring the time between connection initiation and establishment. The implementation is well-structured with comprehensive tests. Code Quality & Best Practices ✅Strengths:
Style & Convention:
Potential Issues & Suggestions1. Default Parameter Value (Minor)Location: websocket.py:199, conftest.py:199 Using 0 as a default value could lead to misleading metrics if the parameter is accidentally omitted. This would result in an extremely large connection delay (current time minus epoch). Suggestion: Consider making the parameter required (no default) or handle 0 explicitly with a warning. 2. Clock Skew Considerations (Minor)Location: extension.py:347-349 The calculation uses time.time() at both points, which is reliable for a single process. However, for defensive programming, consider adding a check for negative delays. 3. Test Boundary Validation (Very Minor)Location: test_connection_delay_metrics.py:223 The assertion >= 400 is slightly tight given the 500ms simulated delay. Test flakiness could occur under heavy load. Consider using a slightly more forgiving threshold. Performance Considerations ✅
Security Concerns ✅
Test Coverage ✅Excellent test coverage:
Minor Enhancement: Consider adding a test case for immediate/near-instant connections (delay ≈ 0ms) to validate edge cases. Architecture & Design ✅Well-designed implementation:
Files Changed Analysisextension.py (9 additions, 2 deletions) ✅
websocket.py (8 additions, 2 deletions) ✅
manifest.json (1 addition, 1 deletion) ✅
conftest.py (10 additions, 3 deletions) ✅
test_connection_delay_metrics.py (228 additions, 0 deletions) ✅
Final Verdict: ✅ APPROVE with minor suggestionsThis is a solid implementation that adds valuable observability to the Soniox ASR extension. The code quality is high, tests are comprehensive, and the changes are minimal and focused. Recommendations before merge:
None of these are blocking issues. The PR is ready to merge as-is if you choose. Great work on the implementation and especially on the thorough test coverage! 🎉 |
Pull Request Review: Add Connection Delay Metric for SonioxOverviewThis PR adds connection delay metrics tracking to the Soniox ASR extension, measuring the time between initiating a WebSocket connection and receiving the open event. The implementation includes comprehensive test coverage. Code Quality & Best Practices✅ Strengths
🔴 CRITICAL ISSUE: Missing Method DefinitionThe send_connect_delay_metrics method is called but never defined! Location: extension.py:356 Required Action: Implement this method following patterns from other extensions. You likely need something like: async def send_connect_delay_metrics(self, connection_delay_ms: int) -> None:
from ten_ai_base.message import ModuleMetrics, ModuleType
await self._send_asr_metrics(
ModuleMetrics(
module=ModuleType.ASR,
vendor=self.vendor(),
metrics={"connect_delay": connection_delay_ms},
metadata={}
)
)Potential Bugs & Issues1. Timestamp Variable Initialization (websocket.py:110)The _connection_attempt_start_time is initialized to 0 which could cause issues if _handle_open is triggered unexpectedly. Recommendation: Initialize to None with validation, or add a check before use. 2. Error Handling Missing (extension.py:346-356)No try-except around metrics sending. If it fails, it could prevent connection initialization from completing. Recommendation: Add error handling with appropriate logging. 3. Test Flakiness Potential (test_connection_delay_metrics.py:223)Assertion expects >= 400ms for 0.5s delay could be flaky on slow CI systems. Recommendation: Use more lenient threshold or add tolerance comment. Performance & Security✅ Performance: No concerns - timestamp capture is efficient, measurement overhead negligible Test Coverage✅ Excellent coverage with new 228-line test file covering:
Suggestions:
Documentation
SummaryAction Required:
Nice to Have:
Overall Assessment: Solid implementation and well-tested, but cannot be merged until the missing method is implemented. Once addressed, this will be a valuable addition to metrics observability. Files Changed: 5 files (+256, -8 lines) |
No description provided.