本文整理汇总了Java中io.micrometer.core.instrument.MeterRegistry.gauge方法的典型用法代码示例。如果您正苦于以下问题:Java MeterRegistry.gauge方法的具体用法?Java MeterRegistry.gauge怎么用?Java MeterRegistry.gauge使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类io.micrometer.core.instrument.MeterRegistry
的用法示例。
在下文中一共展示了MeterRegistry.gauge方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: bindTo
import io.micrometer.core.instrument.MeterRegistry; //导入方法依赖的package包/类
@Override
public void bindTo(MeterRegistry registry) {
registry.gauge(name, Tags.concat(tags,"table", tableName), dataSource, ds -> {
try (Connection conn = ds.getConnection();
PreparedStatement ps = conn.prepareStatement(query);
ResultSet rs = ps.executeQuery()) {
rs.next();
return rs.getInt(1);
} catch(SQLException ignored) {
return 0;
}
});
}
示例2: objectGauge
import io.micrometer.core.instrument.MeterRegistry; //导入方法依赖的package包/类
@Test
@DisplayName("gauges attached to an object are updated when their values are observed")
default void objectGauge(MeterRegistry registry) {
List<String> list = registry.gauge("my.gauge", emptyList(), new ArrayList<>(), List::size);
list.addAll(Arrays.asList("a", "b"));
Gauge g = registry.mustFind("my.gauge").gauge();
assertThat(g.value()).isEqualTo(2);
}
示例3: numericGauge
import io.micrometer.core.instrument.MeterRegistry; //导入方法依赖的package包/类
@Test
@DisplayName("gauges attached to a number are updated when their values are observed")
default void numericGauge(MeterRegistry registry) {
AtomicInteger n = registry.gauge("my.gauge", new AtomicInteger(0));
n.set(1);
Gauge g = registry.mustFind("my.gauge").gauge();
assertThat(g.value()).isEqualTo(1);
n.set(2);
assertThat(g.value()).isEqualTo(2);
}
示例4: bindTo
import io.micrometer.core.instrument.MeterRegistry; //导入方法依赖的package包/类
@Override
public void bindTo(MeterRegistry registry) {
if (poolMetadata != null) {
registry.gauge(name + ".active.connections", tags, dataSource, dataSource -> poolMetadata.getActive() != null ? poolMetadata.getActive() : 0);
registry.gauge(name + ".max.connections", tags, dataSource, dataSource -> poolMetadata.getMax());
registry.gauge(name + ".min.connections", tags, dataSource, dataSource -> poolMetadata.getMin());
}
}
示例5: garbageCollectedSourceObject
import io.micrometer.core.instrument.MeterRegistry; //导入方法依赖的package包/类
@Test
@DisplayName("gauges that reference an object that is garbage collected report NaN")
default void garbageCollectedSourceObject(MeterRegistry registry) {
registry.gauge("my.gauge", emptyList(), (Map) null, Map::size);
assertThat(registry.mustFind("my.gauge").gauge().value()).matches(val -> Double.isNaN(val) || val == 0.0);
}
示例6: bindTo
import io.micrometer.core.instrument.MeterRegistry; //导入方法依赖的package包/类
@Override
public void bindTo(MeterRegistry registry) {
registry.gauge(name + ".size", Tags.concat(tags, "name", cache.getName()), cache, c -> c.getNativeCache().size());
}
示例7: myBinder
import io.micrometer.core.instrument.MeterRegistry; //导入方法依赖的package包/类
@Bean
public MyThing myBinder(MeterRegistry registry) {
registry.gauge("my.thing", 0);
return new MyThing();
}