Netflix Servo应用运行指标监控

联合创作 · 2023-09-27 06:48

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);

 

浏览 45
点赞
评论
收藏
分享

手机扫一扫分享

编辑 分享
举报
评论
图片
表情
推荐
点赞
评论
收藏
分享

手机扫一扫分享

编辑 分享
举报