Countercounter= Counter .builder("http.request") .baseUnit("num") .description("a description of what this counter does") .tags("uri", "/order/create") .register(registry); counter.increment();
FunctionTimer.builder("cache.gets.latency", cache, c -> c.getLocalMapStats().getGetOperationCount(), c -> c.getLocalMapStats().getTotalGetLatency(), TimeUnit.NANOSECONDS) .tags("name", cache.getName()) .description("Cache gets") .register(registry);
registry.more().timer("cache.gets.latency", cache, c -> c.getLocalMapStats().getGetOperationCount(), c -> c.getLocalMapStats().getTotalGetLatency(), TimeUnit.NANOSECONDS);
Long Task Timer
Long Task Timer同样也是Timer的特殊类型,但是其功能与Timer大相径庭。Long Task Timer统计的是当前有多少正在执行的任务,以及这些这任务已经耗费了多少时间,适用于监控长时间执行的方法,统计类似当前负载量的相关指标。Long Task Timer在事件开始时记录,在事件结束后将事件移除。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
LongTaskTimerlongTaskTimer= LongTaskTimer .builder("long.task.timer") .description("a description of what this timer does") .tags("region", "test") .register(registry);
Gaugegauge= Gauge .builder("gauge", myObj, myObj::gaugeValue) .description("a description of what this gauge does") .tags("region", "test") .register(registry);
Distribution Summary翻译为分布摘要,主要用于跟踪事件的分布,它的记录形式与Timer十分相似,但是记录的内容不依赖于时间单位,可以是任意数值,比如在监测范围内各个Http请求的响应内容大小时就可以使用Distribution Summary。为了更加明确地表明记录的内容,通常创建Distribution Summary时应该设置baseUnit属性。
1 2 3 4 5 6 7 8 9 10 11
DistributionSummarysummary= DistributionSummary .builder("response.size") .description("a description of what this summary does") .baseUnit("bytes") .tags("region", "test") .scale(100) .register(registry);
Countercounter= Counter .builder("http.request") .baseUnit("num") .description("a description of what this counter does") .tags("uri", "/order/create") .register(registry); counter.increment();
FunctionTimer.builder("cache.gets.latency", cache, c -> c.getLocalMapStats().getGetOperationCount(), c -> c.getLocalMapStats().getTotalGetLatency(), TimeUnit.NANOSECONDS) .tags("name", cache.getName()) .description("Cache gets") .register(registry);
registry.more().timer("cache.gets.latency", cache, c -> c.getLocalMapStats().getGetOperationCount(), c -> c.getLocalMapStats().getTotalGetLatency(), TimeUnit.NANOSECONDS);
Long Task Timer
Long Task Timer同样也是Timer的特殊类型,但是其功能与Timer大相径庭。Long Task Timer统计的是当前有多少正在执行的任务,以及这些这任务已经耗费了多少时间,适用于监控长时间执行的方法,统计类似当前负载量的相关指标。Long Task Timer在事件开始时记录,在事件结束后将事件移除。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
LongTaskTimerlongTaskTimer= LongTaskTimer .builder("long.task.timer") .description("a description of what this timer does") .tags("region", "test") .register(registry);
Gaugegauge= Gauge .builder("gauge", myObj, myObj::gaugeValue) .description("a description of what this gauge does") .tags("region", "test") .register(registry);
Distribution Summary翻译为分布摘要,主要用于跟踪事件的分布,它的记录形式与Timer十分相似,但是记录的内容不依赖于时间单位,可以是任意数值,比如在监测范围内各个Http请求的响应内容大小时就可以使用Distribution Summary。为了更加明确地表明记录的内容,通常创建Distribution Summary时应该设置baseUnit属性。
1 2 3 4 5 6 7 8 9 10 11
DistributionSummarysummary= DistributionSummary .builder("response.size") .description("a description of what this summary does") .baseUnit("bytes") .tags("region", "test") .scale(100) .register(registry);