【问题标题】:Example of embedded Jetty and using Micrometer for stats (without Spring)嵌入式 Jetty 示例并使用 Micrometer 进行统计(无 Spring)
【发布时间】:2021-08-20 20:49:53
【问题描述】:

我是使用 Micrometer 作为指标/统计数据生成器的新手,我很难使用我的 Jersey/Embedded Jetty 服务器正确配置它。我想添加 Jetty 统计信息。

我已经有 servlet 以 Prometheus 格式为 JVM 生成统计信息。

有人知道如何配置它的好工作示例吗?

我没有使用 SpringBoot。

【问题讨论】:

    标签: jetty micrometer


    【解决方案1】:

    最好的方法是查看 Spring Boot 代码。比如binds the jetty connections

    JettyConnectionMetrics.addToAllConnectors(server, this.meterRegistry, this.tags);
    

    它使用ApplicationStartedEventfind the server reference

    private Server findServer(ApplicationContext applicationContext) {
        if (applicationContext instanceof WebServerApplicationContext) {
            WebServer webServer = ((WebServerApplicationContext) applicationContext).getWebServer();
            if (webServer instanceof JettyWebServer) {
                return ((JettyWebServer) webServer).getServer();
            }
        }
        return null;
    }
    

    还有其他类记录线程使用情况和 SSL 握手指标。

    【讨论】:

      猜你喜欢
      • 2016-02-22
      • 2013-04-15
      • 2017-09-20
      • 2012-11-17
      • 2011-08-20
      • 2012-12-20
      • 1970-01-01
      • 2011-03-10
      • 1970-01-01
      相关资源
      最近更新 更多