Netflix Servo 用 Java 语言,提供暴露、发布应用运行指标的简单接口,主要满足的需求包括:使用JMX、简单、灵活发布。
示例代码:
public class Server { @MonitorId private final String id; @Monitor(, type=INFORMATIONAL) private AtomicReferencestatus = new AtomicReference ("UP"); @Monitor(, type=GAUGE) private AtomicInteger currentConnections = new AtomicInteger(0); @Monitor(, type=COUNTER) private AtomicInteger totalConnections = new AtomicInteger(0); @Monitor(, type=COUNTER) private AtomicLong bytesIn = new AtomicLong(0L); @Monitor(, type=COUNTER) private AtomicLong bytesOut = new AtomicLong(0L); public Server(String id) { this.id = id; } // ... } Server s1 = new Server("s1"); DefaultMonitorRegistry.getInstance().registerObject(s1);