-
Notifications
You must be signed in to change notification settings - Fork 1
Add Redis TS helper and integrate chart data retrieval #576
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
base: master
Are you sure you want to change the base?
Conversation
- Replace days parameter with startDate/endDate/groupBy (minutes) - Add RedisHelper class for TimeSeries operations - Support minutely/hourly/daily aggregations based on groupBy value - Add search parameter support in events queries (title/backtrace/context/addons) - Update GraphQL schema and resolvers for new chart parameters - Fallback to MongoDB when Redis data unavailable
neSpecc
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
now when Redis is down, API is down as well. API should continue responding event without Redis.
- Event.chartData: uses 'days' parameter, fetches data only from MongoDB - Project.chartData: uses 'startDate', 'endDate', 'groupBy' parameters, fetches from Redis with MongoDB fallback - Add getChartDataFromMongo method for Event-specific chart data - Fix redisHelper comment to reflect TS.INCRBY usage - Remove unused 'projectId' parameter from getChartDataFromMongo
- Implement singleton pattern for Redis client to use single connection - Add exponential backoff reconnection strategy (1s to 30s max) - Handle connection lifecycle events (ready, reconnecting, error, end) - Initialize Redis on app startup alongside MongoDB and RabbitMQ - Graceful degradation to MongoDB when Redis is unavailable - Add comprehensive documentation in REDIS_RECONNECT.md This fixes the issue where API lost Redis connection after pod restart and required manual API pod restart to restore functionality.
Changes based on @neSpecc review: 1. TypeDefs improvements: - Use DateTime! instead of String! for date parameters in Project.chartData 2. Method renaming for clarity: - eventsFactory: getChartData → getProjectChartData - eventsFactory: getChartDataFromMongo → getEventDailyChart - Improved parameter order (main identifier first) 3. Code quality: - Remove duplication in try-catch blocks - Extract Redis key composition to utility functions 4. Architecture improvements: - Create ChartDataService to separate business logic from Redis client - Simplify RedisHelper to only low-level Redis operations - Add tsRange() method for TS.RANGE commands - Move chart data logic from redisHelper to dedicated service 5. New utilities: - src/utils/redisKeys.ts with composeTimeSeriesKey(), composeEventTimeSeriesKey() - Type-safe key composition with required parameters Benefits: - Clear separation of concerns (Data Access vs Business Logic vs Service) - RedisHelper stays focused and doesn't grow - Easier to test and maintain - Better type safety and documentation
Changes based on @neSpecc review: 1. TypeDefs improvements: - Use DateTime! instead of String! for date parameters in Project.chartData 2. Method renaming for clarity: - eventsFactory: getChartData → getProjectChartData - eventsFactory: getChartDataFromMongo → getEventDailyChart - Improved parameter order (main identifier first) 3. Code quality: - Remove duplication in try-catch blocks - Extract Redis key composition to utility functions 4. Architecture improvements: - Create ChartDataService to separate business logic from Redis client - Simplify RedisHelper to only low-level Redis operations - Add tsRange() method for TS.RANGE commands - Move chart data logic from redisHelper to dedicated service 5. New utilities: - src/utils/redisKeys.ts with composeTimeSeriesKey(), composeEventTimeSeriesKey() - Type-safe key composition with required parameters Benefits: - Clear separation of concerns (Data Access vs Business Logic vs Service) - RedisHelper stays focused and doesn't grow - Easier to test and maintain - Better type safety and documentation
…codex-team/hawk.api.nodejs into feature/redis-timeseries-helper # Conflicts: # src/models/eventsFactory.js
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #576 +/- ##
==========================================
- Coverage 66.66% 58.30% -8.37%
==========================================
Files 11 19 +8
Lines 174 518 +344
Branches 24 95 +71
==========================================
+ Hits 116 302 +186
- Misses 54 216 +162
+ Partials 4 0 -4 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Better name that reflects the purpose - composing keys for chart data storage, not just Redis-specific utilities.
Clearer naming that explicitly indicates: - This is for project-level metrics (not event-level) - Parameter renamed: suffix -> granularity (more descriptive) Addresses PR review comment about unclear naming.
This PR introduces a new Redis helper module designed to handle time-series (TS) operations and provides chart data aggregation for hourly and daily views.