公开有关与Spring当前Websocket连接的指标 [英] Exposing metrics about current Websocket connections with Spring

查看:111
本文介绍了公开有关与Spring当前Websocket连接的指标的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

对于仪表板应用程序,我想使用内部Spring指标监视基于Spring Boot的应用程序.因此,我正在使用spring-boot-actuator依赖关系,该依赖关系公开了许多内部指标.有很多基于HTTP的指标和Tomcat指标,例如当前会话,状态X的HTTP调用数量等等.我找不到有关Websocket连接的任何信息.

For my dashboarding application I want to monitor my Spring Boot based application with internal Spring metrics. Therefor I am using the spring-boot-actuator dependency which is exposing a lot of internal metrics. There are a lot of HTTP based metrics and Tomcat metrics like current sessions, amount of HTTP calls of status X and so on. I coulnd't find any information regarding my Websocket connections.

Spring是否为当前Websockets提供了任何内置的度量公开工具,还是必须创建自己的度量(例如,使用Prometheus在Grafana中显示数据)并必须手动注册(例如我收到SessionConnectEventSessionConnectEvent时更新的计数器?

Is there any build-in out of the box metrics exposing tool for the current Websockets with Spring or do I have to create my own metrics (e.g. for showing the data in Grafana with Prometheus) and have to manually register for example a counter which is updated when I receive a SessionConnectEvent or SessionConnectEvent?

提前谢谢!

推荐答案

如果您通过WebSocket使用STOMP,则Spring会汇总WebSocketMessageBrokerStats中安装程序的关键基础结构组件的有关内部状态和计数器的信息,默认情况下会记录该信息每30秒.它是作为Spring bean创建的,可以很容易地自动接线.这是您将获得的信息的示例:

If you are using STOMP over WebSocket, Spring aggregates information about internal state and counters from key infrastructure components of the setup in WebSocketMessageBrokerStats, by default this is logged every 30 seconds. It is created as a Spring bean and can be easily autowired. This is an example of the information you'll get:

当前没有执行器端点,但是我已经将它们创建为我的 Spring WebSocket的一部分聊天示例:

There are no actuator endpoints currently, but I've created them as part of my Spring WebSocket Chat sample:

  • Trace Endpoint: exposes WebSocket traces
  • Mappings Endpoint: exposes WebSocket message mappings
  • Stats Endpoint: exposes WebSocketMessageBrokerStats

这篇关于公开有关与Spring当前Websocket连接的指标的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆