fix(alerting): @Autowired on AlertingMetrics production constructor
Task 29's refactor added a package-private test-friendly constructor alongside the public production one. Without @Autowired Spring cannot pick which constructor to use for the @Component, and falls back to searching for a no-arg default — crashing startup with 'No default constructor found'. Detected when launching the server via the new docker-compose stack; unit tests still pass because they invoke the package-private test constructor directly.
This commit is contained in:
@@ -9,6 +9,7 @@ import io.micrometer.core.instrument.MeterRegistry;
|
|||||||
import io.micrometer.core.instrument.Timer;
|
import io.micrometer.core.instrument.Timer;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.jdbc.core.JdbcTemplate;
|
import org.springframework.jdbc.core.JdbcTemplate;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
@@ -74,6 +75,7 @@ public class AlertingMetrics {
|
|||||||
* Production constructor: wraps the Postgres-backed gauge suppliers in a
|
* Production constructor: wraps the Postgres-backed gauge suppliers in a
|
||||||
* 30-second TTL cache so Prometheus scrapes don't cause per-scrape DB queries.
|
* 30-second TTL cache so Prometheus scrapes don't cause per-scrape DB queries.
|
||||||
*/
|
*/
|
||||||
|
@Autowired
|
||||||
public AlertingMetrics(MeterRegistry registry, JdbcTemplate jdbc) {
|
public AlertingMetrics(MeterRegistry registry, JdbcTemplate jdbc) {
|
||||||
this(registry,
|
this(registry,
|
||||||
() -> countRules(jdbc, true),
|
() -> countRules(jdbc, true),
|
||||||
|
|||||||
Reference in New Issue
Block a user