当前位置: 首页>>代码示例>>Java>>正文


Java MeterRegistry.gauge方法代码示例

本文整理汇总了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;
        }
    });
}
 
开发者ID:micrometer-metrics,项目名称:micrometer,代码行数:14,代码来源:DatabaseTableMetrics.java

示例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);
}
 
开发者ID:micrometer-metrics,项目名称:micrometer,代码行数:10,代码来源:GaugeTest.java

示例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);
}
 
开发者ID:micrometer-metrics,项目名称:micrometer,代码行数:13,代码来源:GaugeTest.java

示例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());
    }
}
 
开发者ID:micrometer-metrics,项目名称:micrometer,代码行数:9,代码来源:DataSourceMetrics.java

示例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);
}
 
开发者ID:micrometer-metrics,项目名称:micrometer,代码行数:7,代码来源:GaugeTest.java

示例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());
}
 
开发者ID:micrometer-metrics,项目名称:micrometer,代码行数:5,代码来源:ConcurrentMapCacheMetrics.java

示例7: myBinder

import io.micrometer.core.instrument.MeterRegistry; //导入方法依赖的package包/类
@Bean
public MyThing myBinder(MeterRegistry registry) {
    registry.gauge("my.thing", 0);
    return new MyThing();
}
 
开发者ID:micrometer-metrics,项目名称:micrometer,代码行数:6,代码来源:MetricsAutoConfigurationTest.java


注:本文中的io.micrometer.core.instrument.MeterRegistry.gauge方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。