-
Notifications
You must be signed in to change notification settings - Fork 38.7k
Closed
Labels
in: webIssues in web modules (web, webmvc, webflux, websocket)Issues in web modules (web, webmvc, webflux, websocket)type: enhancementA general enhancementA general enhancement
Milestone
Description
Currently WebSocketMessageBrokerStats hides the actual metrics behind nested toString()s. This makes it difficult to expose these metrics (for example with micrometer) without resorting to brittle access to private fields.
Line 197 in 3a0f309
public String toString() { |
ie:
@PostConstruct
public void init() {
webSocketMessageBrokerStats.setLoggingPeriod(statsIntervalMs);
// https://github.com/spring-projects/spring-framework/issues/22807
Object handler = new DirectFieldAccessor(webSocketMessageBrokerStats).getPropertyValue("webSocketHandler");
Object stats = new DirectFieldAccessor(handler).getPropertyValue("stats");
DirectFieldAccessor statsAccessor = new DirectFieldAccessor(stats);
Gauge.builder("sockjs.connection", () ->
((AtomicInteger)statsAccessor.getPropertyValue("webSocket")).get()).tags("protocol", "WS")
.register(meterRegistry);
Gauge.builder("sockjs.connection", () ->
((AtomicInteger)statsAccessor.getPropertyValue("httpStreaming")).get()).tags("protocol", "HttpStream")
.register(meterRegistry);
Gauge.builder("sockjs.connection", () ->
((AtomicInteger)statsAccessor.getPropertyValue("httpPolling")).get()).tags("protocol", "HttpPoll")
.register(meterRegistry);
}```
Metadata
Metadata
Assignees
Labels
in: webIssues in web modules (web, webmvc, webflux, websocket)Issues in web modules (web, webmvc, webflux, websocket)type: enhancementA general enhancementA general enhancement