78 Commits

Author SHA1 Message Date
22c0d2e301 feat(metrics): 优化指标数据处理和清理机制
- 在指标收集器中新增定期清理任务,自动清理无效的统计数据
- 修改 MetricsHandler 中的延迟分布处理,移除冗余日志输出
- 优化 MetricsStorage 的数据加载逻辑,限制加载的统计数据数量
- 新增延迟分布单独持久化存储,减少主指标文件的复杂性
- 改进数据加载和恢复的日志记录,提供更清晰的操作反馈
2025-03-09 13:21:35 +08:00
d2e5020d22 feat(metrics): 优化延迟分布数据处理逻辑
- 增加对延迟分布数据的类型兼容性处理
- 新增直接使用 map[string]int64 类型的处理分支
- 优化日志输出,提供更详细的类型转换信息
- 在处理结束后打印最终的延迟分布数据
- 改进错误处理和类型转换的健壮性
2025-03-09 11:49:37 +08:00
f2e1b8cbf5 feat(metrics): 统一延迟分布桶命名并优化日志记录
- 将延迟分布桶键名从 "<10ms" 和 ">1s" 改为 "lt10ms" 和 "gt1s"
- 在指标处理和收集过程中添加详细日志,帮助诊断数据处理流程
- 前端页面适配新的桶键名,并提供友好的显示转换
- 增强延迟分布数据处理的健壮性和可读性
2025-03-09 11:43:26 +08:00
2cb88a4f5e fix(metrics): 优化延迟统计和分布数据处理
- 修复延迟统计分布数据获取逻辑,增加更健壮的类型转换
- 确保延迟分布桶始终存在,即使没有数据
- 在处理器中为空分布数据添加默认初始化
- 优化指标收集器中的延迟桶初始化和数据获取方法
2025-03-09 11:33:47 +08:00
b6b77b03ed feat(metrics): 增强指标展示和统计功能
- 在指标结构中新增延迟统计、错误统计和引用来源统计字段
- 更新前端仪表盘,添加延迟、带宽、错误和引用来源统计卡片
- 优化指标收集器,支持引用来源和错误类型统计
- 在工具函数中新增字符串转整数解析方法
- 简化引用来源URL处理,提取域名信息
2025-03-09 11:24:46 +08:00
3810153f8e refactor(auth): Update OAuth URLs and button text for CZL Connect integration 2025-03-03 23:08:27 +08:00
4af1592021 删除固定路径代理配置, 因为普通代理好像已经支持了 2025-03-03 06:47:52 +08:00
f614692f33 refactor(auth): Remove user allowlist filtering
- Delete `isAllowedUser` function for user authorization
- Remove environment variable `OAUTH_ALLOWED_USERS` from docker-compose
- Eliminate user whitelist check in OAuth callback handler
2025-02-20 02:50:43 +08:00
929d13157d refactor(proxy): Optimize hop-by-hop header handling and routing logic
- Simplify hop-by-hop headers initialization using map literal
- Create a local copy of hop headers to improve header filtering
- Enhance routing logic with context-based timeout for alternative target checks
- Improve error handling and logging in file size and routing detection
- Reduce unnecessary goroutine complexity in target URL selection
2025-02-18 13:34:50 +08:00
ed63121a00 refactor(metrics): Introduce JSON-friendly metrics serialization
- Create PathMetricsJSON struct for clean JSON serialization
- Add ToJSON method to convert PathMetrics to JSON-compatible representation
- Update metrics handlers and collectors to use new JSON-friendly type
- Simplify type conversion in SafePathMetrics utility function
- Improve metrics data transfer and serialization consistency
2025-02-17 08:01:29 +08:00
92910a608f feat(metrics): Add interval-based metrics tracking and reporting
- Implement time-interval statistics for requests, errors, and bytes
- Add per-second metrics calculation for requests and bandwidth
- Enhance GetStats method to return interval-specific performance data
- Track and reset interval status codes dynamically
- Improve metrics granularity with more detailed performance insights
2025-02-17 06:13:24 +08:00
a4437b9a39 feat(auth): Implement OAuth-based authentication with Q58 platform
- Replace password-based login with OAuth authentication
- Add OAuth login and callback handlers
- Support user whitelist via environment variables
- Update login page to use OAuth flow
- Remove legacy metrics-related authentication configuration
- Enhance token management with username tracking
2025-02-17 05:43:23 +08:00
41f5b82661 feat(metrics): Enhance uptime formatting with more precise time display
- Update FormatUptime to include seconds in time representation
- Modify metrics handler to use new uptime formatting method
- Improve readability of uptime display with more granular time details
2025-02-16 20:24:31 +08:00
4e3a17ecd4 refactor(logging): Standardize logging format across components
- Update logging in cache, auth, proxy, metrics, and fixed path middleware
- Add consistent log message structure with method, path, status, and source
- Improve error logging with more descriptive and uniform messages
- Enhance log readability by using concise and informative log formats
2025-02-16 14:34:49 +08:00
a4c4688412 feat(cache): Add dynamic cache configuration management
- Implement GetConfig and UpdateConfig methods in CacheManager
- Add cache configuration endpoints in CacheAdminHandler
- Create frontend UI for dynamically updating cache settings
- Support configurable max age, cleanup interval, and cache size
- Add input validation for cache configuration updates
2025-02-16 13:57:12 +08:00
35ea14a91f feat(cache): Add Content-Encoding support in cache management
- Update CacheItem struct to include ContentEncoding field
- Modify Put and Commit methods to store Content-Encoding header
- Enhance cache retrieval to set Content-Encoding header for cached responses
- Implement Content-Encoding preservation across proxy and mirror handlers
2025-02-15 18:16:04 +08:00
2267a27b37 feat(cache): Implement streaming cache with TeeReader for efficient response handling
- Replace full response body reading with streaming cache mechanism
- Add CreateTemp and Commit methods to CacheManager for incremental caching
- Use io.TeeReader to simultaneously write response to client and cache file
- Remove buffer pool and full body reading in proxy and mirror handlers
- Improve memory efficiency and reduce latency for large responses
- Update error handling and logging for cache-related operations
2025-02-15 17:48:13 +08:00
ffc64bb73a feat(cache): Add fixed path cache support to admin dashboard and API
- Integrate fixed path cache into cache admin handler and API endpoints
- Update cache admin dashboard to display fixed path cache statistics
- Modify cache management functions to support fixed path cache operations
- Add new cache type to frontend cache management UI
2025-02-15 17:32:27 +08:00
c4cd99a827 feat(cache): Implement comprehensive caching system for proxy requests
- Add CacheManager to handle caching for proxy and mirror handlers
- Introduce cache-related API endpoints for stats, enabling, and clearing
- Modify proxy and mirror handlers to support caching GET requests
- Remove rate limiting and simplify request handling
- Update go.mod dependencies and remove unused imports
- Add cache hit/miss headers to responses
- Enhance metrics collection for cached requests
2025-02-15 17:00:16 +08:00
3e5950e3f6 feat(metrics,web): Enhance dashboard with advanced metrics visualization
- Integrate Recharts library for interactive data visualization
- Add detailed latency distribution charts and error type analysis
- Implement bandwidth and performance metrics graphs
- Update metrics collection to support more granular statistical tracking
- Modify frontend API routes to remove /admin prefix
- Improve metrics display with responsive and informative charts
2025-02-15 16:23:20 +08:00
33d6a51416 refactor(web): Migrate to modern web frontend and simplify admin routes
- Remove legacy static files, templates, and JavaScript
- Update main.go to serve SPA-style web application
- Modify admin route handling to support client-side routing
- Simplify configuration and metrics API endpoints
- Remove server-side template rendering in favor of static file serving
- Update Dockerfile and GitHub Actions to build web frontend
2025-02-15 11:44:09 +08:00
0446eb1c53 feat(proxy): Optimize HTTP transport and timeout configurations
- Increase connection pool and idle connection limits
- Extend timeout durations for more robust network handling
- Configure HTTP/2 transport with enhanced performance settings
- Add HTTP/2-specific optimizations and security constraints
2025-02-15 08:59:20 +08:00
6c7bc2bfb8 refactor(proxy): Improve error handling and response writing in proxy handler
- Modify error response writing to use explicit WriteHeader and Write methods
- Remove redundant WriteHeader call in ServeHTTP method
- Add WriteHeader before writing response for both small and large responses
- Enhance code readability and error handling consistency
2025-02-15 08:34:14 +08:00
e89ef02205 特性(代理):通过端口和身份验证更新来增强服务器配置和安全性。
- 更新 docker-compose.yml 文件,使用端口 3336
- 修改 Dockerfile 以暴露端口 3336
- 重构 main.go 以支持新的路由和管理端点
- 在 auth.go 中实现健壮的身份验证中间件
- 通过加强错误检查来改进指标处理。
- 添加用于安全类型转换的实用函数
- 引入请求ID生成功能,以便更好地进行追踪。
2025-02-15 08:07:28 +08:00
f76649d0e7 refactor(proxy): streamline target URL selection logic by removing deprecated path handling 2025-01-12 18:24:19 +08:00
9aedaf75c5 refactor(metrics): simplify auto-refresh logic in metrics template 2024-12-05 11:27:47 +08:00
ea4e7cc70b 状态码统计布局问题 2024-12-05 11:21:30 +08:00
1f2f78dc64 refactor(metrics): remove historical data handling and streamline collector logic
- Eliminated the historical data storage and related functions from the metrics collector to simplify the codebase.
- Removed the historical data display section from the metrics template, enhancing clarity and focus on current metrics.
- Updated the CheckDataConsistency method to implement a simpler validation check for total errors against total requests.

These changes improve the maintainability of the metrics system by removing outdated features and ensuring a more straightforward data validation process.
2024-12-05 11:16:58 +08:00
1440eec7ed refactor(metrics): remove deprecated metrics history endpoint and clean up related code
- Removed the MetricsHistoryHandler and associated historical data export functionality to streamline the metrics handling process.
- Updated the metrics template to improve label translations and ensure default values are used for optional data fields.
- Enhanced the JavaScript code for metrics display by adding checks for undefined data arrays, improving robustness.
- Cleaned up unused variables and functions to maintain code clarity and reduce complexity.

These changes simplify the metrics system by eliminating outdated features and improving the overall reliability of data presentation.
2024-12-05 11:09:44 +08:00
b82096227c feat(metrics): improve metrics handling with safe type conversions and default values
- Introduced safe type conversion functions to handle nil values gracefully, ensuring metrics integrity.
- Updated the MetricsHandler to return default values for metrics when stats retrieval fails, enhancing reliability.
- Streamlined the metrics initialization process by ensuring all necessary fields are populated, even in error scenarios.
- Improved memory usage reporting and response time metrics for better performance insights.

These changes enhance the robustness of the metrics system, ensuring accurate data handling and improved monitoring capabilities.
2024-12-05 10:59:55 +08:00
058244cc70 feat(metrics): enhance configuration and performance monitoring
- Added new performance monitoring settings in the configuration, including maximum requests per minute and data transfer limits.
- Introduced validation parameters for metrics, ensuring data integrity and consistency checks during collection.
- Refactored the metrics collector to streamline initialization and improve error handling.
- Removed deprecated database-related code and optimized metrics saving processes.
- Enhanced historical data management with regular clean-up routines to maintain performance.

These changes improve the configurability and reliability of the metrics system, ensuring accurate data handling and enhanced monitoring capabilities.
2024-12-05 10:56:27 +08:00
8df86387ac refactor(metrics): enhance dashboard styles and optimize SQL queries
- Updated CSS styles for the metrics dashboard, improving layout with flex properties and enhanced item presentation.
- Modified the status code display to use a more organized structure, allowing for better alignment and spacing.
- Changed the data type for avgLatency in SaveMetrics to int64 for consistency.
- Implemented a context with timeout for database queries in GetRecentMetrics, improving performance and reliability.
- Optimized SQL queries to limit result sets and enhance data retrieval efficiency.

These changes improve the user experience and data presentation in the metrics dashboard, providing clearer insights into performance metrics.
2024-12-05 09:22:33 +08:00
7cca4bab95 fix css bug 2024-12-05 08:58:42 +08:00
1140062afb 修改metrics状态码样式 2024-12-05 08:52:25 +08:00
d69d34bb5d fix(metrics): update metrics dashboard styles and improve status code display 2024-12-05 08:48:00 +08:00
3270bb5f36 fix(metrics): update metrics dashboard styles and optimize SQL queries
- Changed text color in the metrics dashboard from white to black for better visibility.
- Modified the layout of status codes to display in a row with improved alignment and spacing.
- Enhanced CSS styles for the metrics dashboard, including adjustments to flex properties and background settings.
- Updated SQL query in GetRecentMetrics to sort status codes, ensuring a more organized display of metrics.

These changes improve the user experience and data presentation in the metrics dashboard, providing clearer insights into performance metrics.
2024-12-05 08:37:51 +08:00
864ebcc610 test 2024-12-05 08:23:38 +08:00
96a792abf2 fix(metrics): update metrics dashboard styles and SQL query
- Enhanced CSS styles for the metrics dashboard, improving layout and visual presentation with new flex properties and background adjustments.
- Modified the SQL query in GetRecentMetrics to include an additional interval parameter, ensuring more accurate data retrieval for recent metrics.
- These changes improve the user experience and data accuracy in the metrics dashboard, providing a more robust framework for performance monitoring.
2024-12-05 08:03:03 +08:00
e286fa9eaf feat(metrics): enhance metrics retention and improve data handling
- Introduced new constants for data retention periods, specifying retention for metrics, status codes, paths, and referers to improve data management.
- Updated the MetricsHistoryHandler to accept floating-point hours for more precise time queries, enhancing the flexibility of historical data retrieval.
- Enhanced the metrics dashboard layout with additional CSS styles for better visual presentation and user experience.
- Improved error handling in the response writing process to ensure robust logging of connection issues.
- Implemented a new function to check for connection closure errors, improving the reliability of the proxy handler.

These changes significantly enhance the metrics collection, retention, and user interface, providing a more robust framework for performance monitoring and data analysis.
2024-12-05 07:57:02 +08:00
26c945a3f9 feat(metrics): enhance metrics dashboard and data handling
- Improved the metrics dashboard layout with new styles for better visual presentation, including enhanced chart and control elements.
- Added functionality for auto-refreshing metrics and exporting data to CSV, improving user interaction and data accessibility.
- Implemented persistent statistics tracking in the collector, allowing for historical data retrieval and better performance monitoring.
- Enhanced database operations with optimizations for saving metrics and cleaning up old data, ensuring efficient data management.
- Introduced performance metrics tracking, providing insights into average response times and throughput.

These changes significantly enhance the usability and functionality of the metrics dashboard, providing a more robust framework for performance monitoring and data analysis.
2024-12-05 07:08:08 +08:00
c35d95f2cc fix(metrics): enhance metrics dashboard layout and optimize database queries
- Increased the bottom margin of charts in the metrics dashboard for improved visual spacing.
- Added titles to the charts for better context and understanding of displayed data.
- Introduced composite indexes in the database to optimize aggregation queries and improve performance.
- Modified the SQL query in GetRecentMetrics to calculate incremental changes in metrics, enhancing data accuracy and usability.

These changes improve the user experience by providing clearer visualizations and more efficient data retrieval in the metrics dashboard.
2024-12-05 01:46:25 +08:00
68a0ea234b fix(metrics): refine chart handling and data validation in metrics dashboard
- Updated chart management logic to ensure proper destruction of existing charts before creating new ones, preventing memory leaks.
- Enhanced data validation by adding a check for the data format returned from the API, ensuring it is an array before processing.
- Consolidated chart options into a common configuration for improved consistency across different charts.
- Improved the updateChart function to handle canvas element existence checks and streamline chart creation.

These changes enhance the performance and reliability of the metrics dashboard, providing clearer visualizations and better data handling.
2024-12-05 01:28:17 +08:00
b5a3cfeee4 fix(metrics): improve chart management in metrics dashboard
- Added logic to destroy existing charts before creating new ones, preventing memory leaks and ensuring proper chart updates.
- Updated the currentCharts object to maintain references to the newly created charts, enhancing the management of chart instances.
- These changes improve the performance and reliability of the metrics dashboard by ensuring that charts are correctly handled during updates.
2024-12-05 01:22:58 +08:00
660e60576d fix(metrics): enhance metrics chart rendering and data handling
- Updated the metrics chart rendering logic to reverse the data order for a more intuitive time progression from left to right.
- Introduced chart options to ensure the x-axis is not reversed, improving the clarity of time-based data visualization.
- Modified the updateChart function to accept additional options, allowing for more flexible chart configurations.
- Added a safeguard in GetRecentMetrics to return a default empty record instead of null when no metrics are available, enhancing data reliability.

These changes improve the user experience by providing clearer visualizations and ensuring consistent data handling in the metrics dashboard.
2024-12-05 01:13:11 +08:00
a009dd04a8 refactor(metrics): remove historical data section from metrics dashboard template
- Eliminated the historical data section from the metrics dashboard, including time range buttons and associated chart containers.
- Streamlined the metrics template for improved clarity and focus on current metrics display.
- This change enhances the user experience by simplifying the dashboard layout.
2024-12-03 18:27:04 +08:00
b69a78eae0 feat(metrics): enhance metrics dashboard with time range buttons and chart updates
- Replaced the time range dropdown with a set of buttons for selecting different time ranges (1 hour, 6 hours, 12 hours, 24 hours, 3 days, 5 days, 7 days, 15 days, 30 days).
- Improved the styling of the time range buttons for better user experience.
- Refactored chart loading logic to update existing charts instead of recreating them, enhancing performance and user experience.
- Added functionality to dynamically load historical data based on the selected time range, improving data visualization capabilities.
2024-12-03 18:23:37 +08:00
91d4686713 feat(metrics): add safe type conversion functions and enhance metrics data retrieval
- Introduced safe type conversion functions for memory usage, status code stats, top paths, and recent requests to prevent panics when accessing metrics data.
- Updated MetricsHandler to utilize these safe functions, improving the robustness of metrics handling.
- Refactored GetStats method in Collector to ensure all fields are initialized and to streamline the retrieval of metrics data.
- Enhanced the overall structure of metrics data for better clarity and reliability in reporting.
2024-12-03 18:17:25 +08:00
9602034f9d feat(metrics): improve metrics handling with safe type conversions and enhanced request statistics
- Introduced safe type conversion functions to prevent panics when accessing metrics data.
- Updated MetricsHandler to utilize these functions for retrieving active requests, total requests, total errors, and average response time.
- Enhanced error rate calculation to avoid division by zero.
- Refactored buffer pool management in ProxyHandler for better memory handling.
- Improved target URL determination logic based on file extensions for more flexible proxy behavior.
2024-12-03 18:11:29 +08:00
3962799980 feat(config): update alert configurations and error rate thresholds
- Increased ErrorRate threshold from 0.5 to 0.8 for stricter alerting.
- Added AlertInterval setting to config for customizable notification intervals.
- Updated latency thresholds for small, medium, and large files to improve performance monitoring.
- Enhanced metrics handling to incorporate new alert configurations in the system.
2024-12-03 17:54:45 +08:00
68c27b544b feat(metrics): enhance metrics functionality and configuration
- Added new dependency on github.com/mattn/go-sqlite3 for improved metrics storage.
- Updated main.go to initialize metrics collector with a new database path and configuration settings.
- Enhanced config.json to include additional metrics settings such as alert configurations and latency thresholds.
- Refactored internal metrics handling to support new metrics structures and improve data retrieval.
- Introduced a new metrics history endpoint for retrieving historical data, enhancing monitoring capabilities.
- Improved UI for metrics dashboard to include historical data visualization options.
2024-12-03 17:48:11 +08:00