Class SlaCalculationService

java.lang.Object
com.nmontytskyi.monitoring.server.sla.SlaCalculationService

@Service public class SlaCalculationService extends Object
Computes SLA compliance reports for registered microservices.

Only reads data — alert logic remains in AlertEvaluationService. For each call it:

  1. resolves the requested time window (e.g. last 24 hours),
  2. queries aggregate counters and percentiles from metric_records,
  3. builds a SlaReport with actual values and compliance flags.

When no SlaDefinitionEntity has been created for the service, SlaDefinition.defaults() is used (99.9% uptime, 1 000 ms, 5% errors).

  • Constructor Details

    • SlaCalculationService

      public SlaCalculationService()
  • Method Details

    • calculate

      @Transactional(readOnly=true) public SlaReport calculate(Long serviceId, SlaWindow window)
      Calculates an SLA report for the given service over the specified window.
      Parameters:
      serviceId - identifier of the registered service
      window - time window over which to aggregate metrics
      Returns:
      a fully populated SlaReport
      Throws:
      ServiceNotFoundException - if no service exists with serviceId