Interface MetricsCollector
public interface MetricsCollector
Contract for a component that collects metrics from a microservice.
Implemented in monitoring-server by ActuatorMetricsCollector,
which performs HTTP requests to the target service's /actuator/health
and /actuator/metrics endpoints and converts the response into a
MetricSnapshot.
Separating the interface from the implementation allows:
- easy substitution in tests;
- adding alternative collection mechanisms (e.g. JMX or gRPC) without modifying consumer code.
-
Method Summary
Modifier and TypeMethodDescriptioncollect(ServiceInfo service) Collects the current metrics from the specified service.
-
Method Details
-
collect
Collects the current metrics from the specified service.If the service is unavailable, the method does not throw an exception. Instead it returns a
MetricSnapshotwith statusHealthStatus.DOWNand a populatederrorMessage.- Parameters:
service- description of the service to collect metrics from- Returns:
- a snapshot of the current service state
-