-
Notifications
You must be signed in to change notification settings - Fork 0
@MetricInterface
Usable way to define, describe and document component's metric interface is simple java interface that contains public String fields which defines names of metrics produced by a component
public interface SimpleFailoverProcessorMetrics {
/**
* Counter of errors on processor's simple failover line, usually high values ( > 100 per hour ) of this
* metric will signal about service/host communication problems.
*/
String PROCESS_ERROR = "processor.simple-failover.event.error";
}
This interface may be [static ]imported and used as part of component class definition
import foo.bar.SimpleFailoverProcessorMetrics
public class SimpleFailoverProcess implements FailoverProcess {
@Override
@ErrorCountable(name= SimpleFailoverProcessorMetrics.PROCESS_ERROR)
public void performMain(....) {
....
}
}
To bring additional semantic and involve possible further processing and usage for this kind of interfaces I will suggest to introduce marker annotation @MetricInterface.
@MetricInterface
public interface SimpleFailoverProcessorMetrics { ... }
At the moment this metric should not have any special effect in the runtime or compile time, it is proposed as marker to help track and find metric interfaces.
One variant of further processing, for example, may be implemented as code pre-processing to generate component/module metrics interface. Another one variant is metric dashboards generation and more.
This technique may be extended to provide links between component class and its metric interface, for example
@MetricInterface(ofComponent=SimpleFailoverProcess.class)
public interface SimpleFailoverProcessorMetrics { ... }
Back links from component also may be provided using same annotation
@MetricInterface(definedBy=SimpleFailoverProcessorMetrics.class)
public class SimpleFailoverProcess implements FailoverProcess { ... }