从 Jetty 11 移植到 Jetty 12。缺少StatisticsHandler 方法

问题描述 投票:0回答:1

我正在将我的应用程序从 Jetty 11 移植到 Jetty 12。

我注意到

StatisticsHandler
中的以下方法丢失了:

- getDispatched
- getDispatchedActive
- getDispatchedActiveMax
- getDispatchedTimeMax
- getDispatchedTimeTotal
- getAsyncRequests
- getAsyncRequestsWaiting
- getAsyncRequestsWaitingMax
- getAsyncDispatches
- getExpires
- getStatsOnMs
- getResponsesBytesTotal

我检查了 Jetty 仓库,发现 在StatisticsHandler #10555 中重新引入了一套更完整的统计数据

在 Jetty 10/11 中,StatisticsHandler 用于公开比 Jetty 12 目前更多的内部结构。以下是 10 月 11 日可用但 12 日不存在的此类统计数据的列表:

getStatsOnMs()
getDispatchedActive()
getDispatched()
getDispatchedActiveMax()
getDispatchedTimeTotal()
getDispatchedTimeMax()
getDispatchedTimeMean()
getDispatchedTimeStdDev()
getExpires()
getAsyncDispatches()
getAsyncRequestsWaiting()

如果 10/11 和 12 之间的变化需要统计数据略有不同,则应按原样重新实施或最终重新审视这些内容。

问题已解决,但上面列表中的大多数方法未添加。

我的问题:

  • 为什么删除
    getDispatched*
    getAsync*()
    方法(如果它们在 Jetty 12 中没有意义,那么原因是什么)
  • 有替代品吗?

了解更多背景信息: 我正在使用

JettyStatisticsCollector
中的
io.prometheus:simpleclient_jetty:0.16.0
:

@Override
public List<MetricFamilySamples> collect() {
  return Arrays.asList(
          buildCounter("jetty_requests_total", "Number of requests", statisticsHandler.getRequests()),
          buildGauge("jetty_requests_active", "Number of requests currently active", statisticsHandler.getRequestsActive()),
          buildGauge("jetty_requests_active_max", "Maximum number of requests that have been active at once", statisticsHandler.getRequestsActiveMax()),
          buildGauge("jetty_request_time_max_seconds", "Maximum time spent handling requests", statisticsHandler.getRequestTimeMax() / 1000.0),
          buildCounter("jetty_request_time_seconds_total", "Total time spent in all request handling", statisticsHandler.getRequestTimeTotal() / 1000.0),
          buildCounter("jetty_dispatched_total", "Number of dispatches", statisticsHandler.getDispatched()),
          buildGauge("jetty_dispatched_active", "Number of dispatches currently active", statisticsHandler.getDispatchedActive()),
          buildGauge("jetty_dispatched_active_max", "Maximum number of active dispatches being handled", statisticsHandler.getDispatchedActiveMax()),
          buildGauge("jetty_dispatched_time_max", "Maximum time spent in dispatch handling", statisticsHandler.getDispatchedTimeMax()),
          buildCounter("jetty_dispatched_time_seconds_total", "Total time spent in dispatch handling", statisticsHandler.getDispatchedTimeTotal() / 1000.0),
          buildCounter("jetty_async_requests_total", "Total number of async requests", statisticsHandler.getAsyncRequests()),
          buildGauge("jetty_async_requests_waiting", "Currently waiting async requests", statisticsHandler.getAsyncRequestsWaiting()),
          buildGauge("jetty_async_requests_waiting_max", "Maximum number of waiting async requests", statisticsHandler.getAsyncRequestsWaitingMax()),
          buildCounter("jetty_async_dispatches_total", "Number of requested that have been asynchronously dispatched", statisticsHandler.getAsyncDispatches()),
          buildCounter("jetty_expires_total", "Number of async requests requests that have expired", statisticsHandler.getExpires()),
          buildStatusCounter(),
          buildGauge("jetty_stats_seconds", "Time in seconds stats have been collected for", statisticsHandler.getStatsOnMs() / 1000.0),
          buildCounter("jetty_responses_bytes_total", "Total number of bytes across all responses", statisticsHandler.getResponsesBytesTotal())
  );
}

我可能可以覆盖这个列表,但我想要 Jetty 公开的全套统计数据。

请注意

io.prometheus:simpleclient_jetty:0.16.0
是行尾,替换为
io.prometheus:client_java
它尚未迁移 JettyStatisticsCollector :

这不是功能性源代码。我们只是保留这些文件,这样一旦我们将它们复制到新的 1.0.x 模块,就不会丢失 Github 历史记录。

jetty prometheus
1个回答
0
投票
  • 为什么删除
    getDispatched*
    getAsync*()
    方法(如果它们在 Jetty 12 中没有意义,那么原因是什么)
  • 有替代品吗?

两者都在跟踪 Servlet 特定行为(

DispatcherType
AsyncContext
用于特定行为)。

Jetty 12 核心类不再依赖 servlet,这就是那些特定方法/指标被删除的原因。

Jetty Core 或

StatisticsHandler
级别没有替代品。

早在 Jetty 11 及更早版本中,Jetty 的核心(以及诸如

StatisticsHandler
之类的东西)就与特定版本的 Servlet 相关联。 (对于 Jetty 11 来说是 Servlet 5.0)

现在在 Jetty 12 中,servlet 类仅存在于各个环境中,您可以选择要运行的环境(例如:servlet 版本)。

© www.soinside.com 2019 - 2024. All rights reserved.