Gauge是仪表值。顾名思义,Gauge用来记录可以瞬息万变的一个数值,例如CPU利用率、内存利用率等。

示例:

//example 1:
List<String> list = registry.gauge("listGauge", Collections.emptyList(), new ArrayList<>(), List::size);
List<String> list2 = registry.gaugeCollectionSize("listSize2", Tags.empty(), new ArrayList<>());
Map<String, Integer> map = registry.gaugeMapSize("mapGauge", Tags.empty(), new HashMap<>());

//example 2:
AtomicInteger n = registry.gauge("numberGauge", new AtomicInteger(0));
n.set(1);
n.set(2);

//example 3:
Gauge gauge = Gauge
    .builder("gauge", myObj, myObj::gaugeValue)
    .description("a description of what this gauge does") // optional
    .tags("region", "test") // optional
    .register(registry);
作者:Jeebiz  创建时间:2023-04-27 14:31
最后编辑:Jeebiz  更新时间:2024-02-26 11:18