Server latency tool - #41
Merged
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
Adds a new “Website Latency Check” tool to the CTRL_Node CLI to measure and display end-to-end website connection/request latency broken down by phase (DNS, TCP, TLS, TTFB, download), and rates responsiveness using a TTFB-based score.
Changes:
- Introduces
LatencyCheckmodule, integrates it into the main interactive menu, and adds unit tests for the new behavior. - Adds
rate_ttfb()helper and associated tests for the TTFB rating thresholds. - Updates README feature list, adds isort config alignment, and bumps package version to
0.0.3.
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| tests/common/modules/test_module_utils.py | Adds unit tests for the new rate_ttfb() helper. |
| tests/common/modules/test_latency.py | Adds unit tests covering LatencyCheck initialization, measurement, and output formatting. |
| README.md | Documents the new Website Latency Check feature. |
| pyproject.toml | Bumps version to 0.0.3 and adds [tool.isort] profile configuration. |
| ctrl_node/ctrl_node.py | Adds a new menu option to run the Website Latency Check tool. |
| ctrl_node/common/modules/module_utils.py | Adds rate_ttfb() helper used by the latency tool. |
| ctrl_node/common/modules/latency.py | Implements LatencyCheck with phased timing, request execution, and result display. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+43
to
+46
| address_info = self.time_phase( | ||
| "DNS lookup", lambda: socket.getaddrinfo(self.host, self.port) | ||
| ) | ||
| self.ip_address = address_info[0][4][0] |
Comment on lines
+55
to
+63
| if self.use_tls: | ||
| context = ssl.create_default_context() | ||
| sock = self.time_phase( | ||
| "TLS handshake", | ||
| lambda: context.wrap_socket(sock, server_hostname=self.host), | ||
| ) | ||
|
|
||
| self.request_content(sock) | ||
| sock.close() |
Comment on lines
+93
to
+98
| request = ( | ||
| f"GET {self.path} HTTP/1.1\r\n" | ||
| f"Host: {self.host}\r\n" | ||
| "Connection: close\r\n" | ||
| "\r\n" | ||
| ).encode() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Changes