如何配置 OpenTracing Tracer 以将数据推送到 Java 中的 Prometheus/Grafana

How to configure an OpenTracing Tracer to push data to Prometheus/Grafana in Java

我有一个使用 OpenTracing 的 Spring 引导应用程序,我想将其数据推送到 Prometheus,这样我就可以通过 Grafana 查询所有指标(就像本教程中的 https://www.hawkular.org/blog/2017/06/26/opentracing-appmetrics.html)。

问题是,我还没有找到任何一致的解决方案,到目前为止我找到的所有示例都已过时、弃用或缺少文档。

理想情况下,我正在寻找一些 returns 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();

最佳

请注意,跟踪数据(跨度)与 "metrics" 不同,尽管在某些情况下可能会有一些重叠。我推荐以下博客 post,了解每个博客的用途,包括日志记录:

https://peter.bourgon.org/blog/2017/02/21/metrics-tracing-and-logging.html

就是说,您链接的博客 post 中提到了名为 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. The data points are then reported via Micrometer 的 OpenTracing 库,可以将其配置为以 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.

请在 java-metrics 存储库中针对您面临的问题提出一个问题。