启用弹簧千分尺端点的指标

发布于 2025-01-27 08:09:35 字数 792 浏览 3 评论 0原文

我将Java Spring项目从Java 8迁移到Java 11。因此,我需要用千分尺替换Dropwizard指标。达到某些端点时,Dropwizard指标正在记录状态和响应。 例如:端点localhost:8080/my_service/v1/api/some/endpoint - >>并记录了指标 Metrics.prefix.counter.status.200.v1.api.some.endpoint Metrics.prefix.gauge.response.v1.api.some.endpoint

有没有办法在微米中使用相同的方法?我知道有@counted注释,但由于某种原因,它行不通。 (我将其放在端点方法上)。

我的适当文件文件(仅与指标相关的值):

management.metrics.export.statsd.enabled=true
management.metrics.export.statsd.host=****
management.metrics.export.statsd.port=8125
management.metrics.export.statsd.flavor=etsy
management.metrics.export.statsd.prefix=metrics.prefix
management.metrics.export.statsd.polling-frequency=10s
management.metrics.web.server.auto-time-requests=:true

I'm migrating Java Spring project from java 8 to java 11. So I need to replace dropwizard metrics with micrometer. Dropwizard metrics were recording statuses and responses when hitting certain endpoint.
E.g: endpoint localhost:8080/my_service/v1/api/some/endpoint -->> and metrics recorded
metrics.prefix.counter.status.200.v1.api.some.endpoint
metrics.prefix.gauge.response.v1.api.some.endpoint

Is there a way to anable the same in Micrometer? I'm aware there is @Counted annotation, but for some reason it doesn't work. (I'm putting it on endpoint method).

My propertries file (metrics-related values only):

management.metrics.export.statsd.enabled=true
management.metrics.export.statsd.host=****
management.metrics.export.statsd.port=8125
management.metrics.export.statsd.flavor=etsy
management.metrics.export.statsd.prefix=metrics.prefix
management.metrics.export.statsd.polling-frequency=10s
management.metrics.web.server.auto-time-requests=:true

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

暖风昔人 2025-02-03 08:09:35

如果您使用Spring创建端点(MVC或WebFlux),则无需执行任何操作即可查看这些指标。

您应该看到http.server.requests,其中包含上面名称(URI,状态)等的所有详细信息(作为标签)。

为了制作@Counted(和/或@timed工作),您需要创建countedaspect(和/或timeDaspect /code>)@bean,但是正如我所说,如果您仅在受控中使用它,则不需要它们。

You don't need to do anything to see those metrics if you are using Spring to create your endpoint (mvc or webflux).

You should see http.server.requests which has all the details (as tags) that you have in the name above (uri, status) and more.

In order to make @Counted (and/or @Timed work) you need to create a CountedAspect (and/or TimedAspect) @Bean but as I said, if you only use it on the controlled, they are not needed.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文