当前位置: 首页 > 知识库问答 >
问题:

spring-boot度量与spring-cloud度量

蔺昊穹
2023-03-14
@RestController
public class HelloController {

    @Autowired
    private CounterService counterService;

    @RequestMapping("/hello")
    public String sayHello(@RequestParam("name") String name) {
        counterService.increment("counter.calls.hello");
        return "Hello, " + name;
    }
}
...
gauge.response.hello: 5,
gauge.response.metrics: 69,
gauge.response.star-star.favicon.ico: 2,
counter.status.200.star-star.favicon.ico: 4,
counter.status.200.metrics: 1,
counter.calls.hello: 5,
counter.status.200.hello: 5

如spring-boot文档所述。我的自定义计数器(counter.calls.hello)像预期的那样起到计数器的作用。

现在,如果我将spring-cloud-starter-eureka(Brixton.rc1)添加到pom中,并且不更改任何其他内容,那么metricsendpoint将具有

...
gauge.servo.counter.calls.hello: 1,
normalized.servo.rest.totaltime: 0,
normalized.servo.rest.count: 0,
gauge.servo.rest.min: 0,
gauge.servo.rest.max: 0,
gauge.servo.response.hello: 7,
gauge.servo.response.star-star.favicon.ico: 2,

正常的MVC度量标准已经消失了。响应代码信息呢?我的自定义计数器被报告为gauge.servo.counter.calls.hello,但它不再作为计数器工作,即使我对HelloController进行了5次调用,它似乎也只显示值1。经过一些调试和搜索,我将计数器指标名称更改为meter.calls.hello,这将导致指标响应中的counter.servo.calls.hello,并恢复计数器功能。

...
counter.calls.hello(): 3,
response.hello(): 7,
response.metrics(): 9,
response.star-star.favicon.ico(): 2,

Spring-cloud关于度量的文档似乎表明,无论使用servo还是Spectator,我都应该使用ServoRegistry。观众指标部分的术语是不同的。柜台的工作方式并不像我所期望的那样。当我使用文档中描述的ServoRegistry发布一个简单的命中计数器时,我会在metricsendpoint中返回某种速率。

与Spring-Boot提供的相比,伺服和/或旁观者是否有一些附加价值?Spring-cloud文档表明有更多的信息被记录到默认的控制器度量中,但它们没有显示在/metrics中。我应该排除ServoMetricsAutoConfiguration而使用spring-boot实现吗?

共有1个答案

游乐池
2023-03-14

根据Spring Cloud Brixton文档,Servo/Spectator度量标准的优点是它们被标记(也称为维度),而常规的Spring Boot度量标准是分层的。

Spring靴

"counter.status.200.root": 20
"counter.status.400.root": 3

网飞

"root(method=GET,status=200,statistic=count)": 20
"root(method=GET,status=400,statistic=count)": 3
spring.metrics.servo.enabled=false
 类似资料:
  • 我们正在使用Spring靴2与执行器和普罗米修斯显示一个格拉法纳仪表板。我想添加Apache Http Client PoolingHttpClientConnectionManager指标来报告连接池的统计数据。我看到这是添加到Micrometer-Core:1.3.0(https://github.com/micrometer-metrics/micrometer/pull/1223)中的。然

  • 可以用与Spring-Boot1.5类似的方式获取hystrix度量信息? 在1.5度量endpoint中,我有如下内容: 但现在有了使用千分尺的执行器/度量endpoint,我找不到任何对术语“Hystrix”、“Netflix”等的引用。 有什么方法可以不像我以前那样使用hystrix.streamendpoint来获取这些信息?或者这应该是有效的,我做错了什么吗?

  • 为此,我使用spring-boot-starter-web-services(2.0.8.release)。我需要为来自遗留服务的SOAP响应添加度量标准(状态代码为200、非200等的请求数) 我的项目依赖于spring-boot-actuator,但不幸的是,我在actuator/千分尺文档中没有发现如何做到这一点。 是否可以为WebServiceTemplate启用度量标准,它实际上用于从远

  • 是否可以在restendpoint中公开所有的Spring度量? 我使用的是spring Boot2.2.2并添加了这个依赖项 application.yml

  • 我在sprint Boot2执行器中找不到缓存度量。我应该如何查询它们或激活或调试? org.springframework.boot:spring-boot-starter-acture:2.2.5.释放 http://localhost:8080/acturet/metrics/cache.calendar.size http://localhost:8080/acturet/metrics/

  • 我有一个Spring云配置服务器,运行在Dalston发布列车下。它已经生产了几年,为一些旧的Spring Boot应用程序提供配置。今天,我正在尝试构建一个新的Spring Boot 2.3.0应用程序。当我的应用程序启动并尝试从配置服务器获取其配置时,配置服务器只会返回406 Not Acceptable。我可以成功地浏览到我的应用程序试图获取的配置URL,并在我的浏览器中查看配置,所以我想知