Hu-Fi / Mr.Market-V2

This is the V2 version of Mr.Market
GNU Affero General Public License v3.0
1 stars 0 forks source link

[TSE] Implement Health Service #21

Open MWBlocky opened 3 weeks ago

MWBlocky commented 3 weeks ago

Description

This Pull Request introduces the implementation of a Health Check Service for the TSE (Trading Strategy Execution) instances. This service is designed to provide the necessary data to assess the health and operational status of TSE instances, ensuring that all instances are functioning correctly and supplying vital information for monitoring and maintenance.

Summary of changes

Related issues

Fixes #16

posix4e commented 5 days ago

So it's important that health checks are run passively, automatically and routinely. Not on demand.

So when a user hits a /health endpoint, it should just retreive counters

For instance

so /health is retrieving this information not causing them to be updated.

MWBlocky commented 3 days ago

@posix4e, I'm evaluating some solutions for monitoring database operations in our project. Here are the options:

  1. NestJS Subscribers (NestJS Documentation):

    • You can react to INSERT, UPDATE, and DELETE operations by storing relevant data, which could be saved to Redis.
    • There is no built-in support for subscribing to SELECT operations. This can be addressed by adding an interceptor and applying it to methods such as find.
  2. pg_stat_statements (PostgreSQL Documentation):

    • PostgreSQL does not store historical statistics by default. This can be achieved using the pg_stat_statements extension, but it requires additional configuration in postgresql.conf, which can be challenging during deployment.
  3. Custom Logging:

    • You could also add a custom logger to each operation, which would not only log to the console but also store data that could be returned by a health check endpoint.

Do any of these solutions look suitable for our implementation? Or do you have other recommendations?

posix4e commented 3 days ago

You can just track it in memory no reason to hit the database , just record the time in memory or redis when last read database