1.自定义EndPoint
@Component@Endpoint(id = "xyEndPoint")public class DubboEndPoint {@ReadOperationpublic Map<String, Object> read() {return Collections.singletonMap("age", "30");}@WriteOperationpublic void write() {}}
@ReadOperation:自定义读数据
@WriteOperation:自定义写数据
通常定义一个共享变量,用于读写。
2.自定义health
@Componentpublic class DubboThreadPoolHealthIndicator extends AbstractHealthIndicator {@Overrideprotected void doHealthCheck(Builder builder) throws Exception {builder.status(Status.UP);}}
自定义的health组件,一定要以HealthIndicator结尾,且以component的方式添加到容器中
3.自定义info
@Componentpublic class DubboInfo implements InfoContributor {@Overridepublic void contribute(Builder builder) {Map<String, Object> details = new HashMap<>();details.put("application", "xy-rbac");details.put("suthor", "jack.li");details.put("order total", 100203);builder.withDetails(details);}}
4.自定义Metrics
�
Metrics.counter("dubbo.counter", "poolSize", port).increment();Timer timer = Metrics.timer("dubbo.request");timer.record(() -> {System.out.println("this is Metrics timer");});Metrics.gauge("dubbo.poolSize", tp.getPoolSize());Metrics.gauge("dubbo.taskCount", tp.getTaskCount());
5.springboot健康检查
6.k8s 健康检查
1.添加k8s监控配置项
#k8s 环境健康检查探针management.endpoint.health.probes.enabled=true
2.访问url检查应用是否健康
http://localhost:8080/actuator/health/liveness http://localhost:8080/actuator/health/readiness
