{"id":26678188,"url":"https://github.com/telexintegrations/nodejs_latency_monitor","last_synced_at":"2025-03-26T05:15:10.839Z","repository":{"id":278869338,"uuid":"936135619","full_name":"telexintegrations/nodejs_latency_monitor","owner":"telexintegrations","description":null,"archived":false,"fork":false,"pushed_at":"2025-02-23T21:07:54.000Z","size":882,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-02-23T21:26:49.886Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/telexintegrations.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2025-02-20T15:31:04.000Z","updated_at":"2025-02-23T21:07:58.000Z","dependencies_parsed_at":"2025-02-23T21:26:51.993Z","dependency_job_id":null,"html_url":"https://github.com/telexintegrations/nodejs_latency_monitor","commit_stats":null,"previous_names":["telexintegrations/nodejs_latency_monitor","telexintegrations/express_latency_monitor"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/telexintegrations%2Fnodejs_latency_monitor","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/telexintegrations%2Fnodejs_latency_monitor/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/telexintegrations%2Fnodejs_latency_monitor/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/telexintegrations%2Fnodejs_latency_monitor/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/telexintegrations","download_url":"https://codeload.github.com/telexintegrations/nodejs_latency_monitor/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245591533,"owners_count":20640692,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-03-26T05:15:09.686Z","updated_at":"2025-03-26T05:15:10.823Z","avatar_url":"https://github.com/telexintegrations.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# NodeJS Express Latency Monitor\n\n\n\n**Nodejs Express Latency Monitor** is a middleware for monitoring and alerting high latency in Express applications using TypeScript. It tracks request-response times, total requests, error counts, and latency distribution. When latency exceeds a threshold, it sends real-time alerts to **Telex** for quick incident response.\n\n---\n\n## **Features**\n- **Latency Monitoring:** Tracks request-response times for all API endpoints.\n- **High Latency Alerts:** Sends alerts to Telex when latency exceeds 3000 ms.\n- **Real-Time Notifications:** Integrates with Telex for instant latency alerts.\n\n---\n\n## **Technology Stack**\n- **Express.js:** Web framework for building REST APIs.\n- **TypeScript:** Static typing for better maintainability and scalability.\n- **Prom-Client:** Collects and exposes metrics for Prometheus.\n- **Axios:** HTTP client for sending notifications to Telex.\n- **Telex:** Notification platform for real-time alerts.\n\n---\n\n## **Usage**\n\n1.\n## **Telex Integration**\n\n### **How It Works:**\n- The middleware tracks the response time of each request.\n- If the latency exceeds **3000 ms**, it triggers an alert.\n- The alert is processed in a worker thread (`AlertWorker`) to avoid blocking the main thread.\n- `NotificationService` sends the alert to the **Telex webhook URL**.\n- Telex receives the alert and displays it as a warning notification in the dashboard.\n\n### **Alert Message Format:**\n```\n🚨 High Latency Alert: [HTTP Method] [URL] took [Response Time] ms\n```\n\n### **Example Alert on Telex:**\n```\n🚨 High Latency Alert: GET /api/example took 4500 ms\n```\n\n---\n\n## **Testing with Telex**\n\n### **Step 1: Verify Setup**\nEnsure the app is running with the Telex webhook URL correctly configured in `.env`.\n\n### **Step 2: Trigger High Latency:**\nSimulate high latency by delaying a response in one of the routes:\n```\n```\n\n### **Step 3: Send Request:**\nOpen a browser or use `curl` to hit the endpoint:\n```bash\ncurl https://nodejs-latency-monitor.onrender.com/api/test-latency\n```\n\n### **Step 4: Check Telex Dashboard:**\n1. Log in to your **Telex Dashboard**.\n2. Navigate to **Channel where the webhook is taken**.\n3. Confirm the alert is displayed with the following details:\n   - Event Title: **High Latency Detected**\n   - Method: `GET`\n   - URL: `/api/test-latency`\n   - Response Time: **8000 ms**\n\n### **Step 5: Verify Alert Details:**\nEnsure the alert contains:\n- Request Method and URL\n- Response Time\n- HTTP Status Code\n\n---\n\n## **Acknowledgements**\n\n- **Express.js** for the web framework.\n- **Prom-Client** for metrics collection.\n- **Telex** for real-time alert notifications.\n- **TypeScript** for static typing and maintainability","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftelexintegrations%2Fnodejs_latency_monitor","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftelexintegrations%2Fnodejs_latency_monitor","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftelexintegrations%2Fnodejs_latency_monitor/lists"}