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