[英]How to configure an OpenTracing Tracer to push data to Prometheus/Grafana in Java
I have a Spring Boot app using OpenTracing and I would like to push its data to Prometheus, so I can query all metrics via Grafana (like in this tutorial https://www.hawkular.org/blog/2017/06/26/opentracing-appmetrics.html ).我有一个使用 OpenTracing 的 Spring Boot 应用程序,我想将其数据推送到 Prometheus,因此我可以通过 Grafana 查询所有指标(如本教程中所示https://www.hawkular.org/blog/2017/06/26/ opentracing-appmetrics.html )。
The problem is, I haven't found any consistent solution to do this, all the examples that I have found so far are outdated, deprecated or lacks documentation.问题是,我还没有找到任何一致的解决方案来做到这一点,到目前为止我发现的所有示例都已过时、已弃用或缺乏文档。
Ideally, I am looking for some solution which returns an instance of io.opentracing.Tracer, similar to what Jaeger does:理想情况下,我正在寻找一些返回 io.opentracing.Tracer 实例的解决方案,类似于 Jaeger 所做的:
Tracer tracer = new JaegerTracer.Builder("couchbase")
.withReporter(new RemoteReporter.Builder()
.withSender(new UdpSender(AGENT_HOST, 6831, 0))
.build())
.withSampler(new ConstSampler(true))
.withScopeManager(new AutoFinishScopeManager())
.withMetricsFactory(metricsFactory)
.build();
Best最好的事物
Note that tracing data (spans) are not the same as "metrics", although there could be some overlap in some cases.请注意,跟踪数据(跨度)与“指标”不同,尽管在某些情况下可能会有一些重叠。 I recommend the following blog post on what is the purpose of each, including logging:
我推荐以下博客文章,了解每个的目的,包括日志记录:
https://peter.bourgon.org/blog/2017/02/21/metrics-tracing-and-logging.html https://peter.bourgon.org/blog/2017/02/21/metrics-tracing-and-logging.html
That said, there is the OpenTracing library mentioned in the blog post you linked, called opentracing-contrib/java-metrics .也就是说,您链接的博客文章中提到了 OpenTracing 库,名为opentracing-contrib/java-metrics 。 It allows you to pick specific spans and record them as data points (metrics).
它允许您选择特定的跨度并将它们记录为数据点(指标)。 It works as a decorator of a concrete tracer, so, your spans would reach a concrete backend like Jaeger and, additionally, create data points based on the configured spans.
它用作具体跟踪器的装饰器,因此,您的跨度将到达像 Jaeger 这样的具体后端,此外,还会根据配置的跨度创建数据点。 The data points are then reported via Micrometer , which can be configured to expose this data in Prometheus format.
然后通过Micrometer报告数据点,它可以配置为以 Prometheus 格式公开这些数据。
The problem is, I haven't found any consistent solution to do this, all the examples that I have found so far are outdated, deprecated or lacks documentation.
问题是,我还没有找到任何一致的解决方案来做到这一点,到目前为止我发现的所有示例都已过时、已弃用或缺乏文档。
Please, open an issue on the java-metrics
repository with the problems you are facing.请在
java-metrics
存储库上打开一个问题,说明您面临的问题。
Did you find a way to push the metrics from jaeger to prometheus/grafana? 您是否找到了将指标从jaeger提升到prometheus / grafana的方法? Thanks!
谢谢!
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.