Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

@ServerWebsocket annotation results in too many metrics and out of memory conditions #458

Closed
joelezellLP opened this issue Oct 19, 2022 · 0 comments

Comments

@joelezellLP
Copy link

joelezellLP commented Oct 19, 2022

Steps to Reproduce

  1. Create a class with an annotation similar to this: @ServerWebSocket("/media/v1/conversation/{conversationId}/websocket") and appropriately annotated @onopen and @OnMessage methods.
  2. Open websockets to this service with different values for conversationId
  3. Check the metrics scrape endpoint.

Expected Behaviour

I think that duration of websocket sessions doesn't make sense as a metric, especially not compared with regular http requests. I originally thought there should be a single pair of metrics as below because parameterized websocket controller paths should be treated like http parameterized controller paths. I now think websocket endpoints simply shouldn't have these metrics.

http_server_requests_seconds_count{exception="none",method="POST",status="200",uri="/media/v1/conversation/{conversationId}/websocket",} 3.0
http_server_requests_seconds_sum{exception="none",method="POST",status="200",uri="/media/v1/conversation/{conversationId}/websocket",} 0.56403263

Actual Behaviour

There are multiple pairs of metrics like this:
http_server_requests_seconds_count{exception="none",method="POST",status="200",uri="/media/v1/conversation/ID-1/websocket",} 3.0
http_server_requests_seconds_sum{exception="none",method="POST",status="200",uri="/media/v1/conversation/ID-1/websocket",} 0.56403263
http_server_requests_seconds_count{exception="none",method="POST",status="200",uri="/media/v1/conversation/ID-2/websocket",} 3.0
http_server_requests_seconds_sum{exception="none",method="POST",status="200",uri="/media/v1/conversation/ID-2} 0.56403263

Over time this results in us running out of memory.

** I have worked around the problem by setting the micronaut.metrics.http.path property to a path that excludes my websocket endpoint. **

Environment Information

  • Micronaut Version: 3.7.1
  • Micrometer Version: 4.6.1

Additional Information

https://github.com/micronaut-projects/micronaut-micrometer/tree/master/micrometer-core/src/main/java/io/micronaut/configuration/metrics/binder/web

I think you may need a WebsocketRequestMeterRegistryFilter like you have for client and server.

@joelezellLP joelezellLP changed the title @ServerWebsocket annotation results in too many metrics @ServerWebsocket annotation results in too many metrics and out of memory conditions Oct 25, 2022
n0tl3ss added a commit that referenced this issue Mar 9, 2023
n0tl3ss added a commit that referenced this issue Mar 9, 2023
n0tl3ss added a commit that referenced this issue Mar 9, 2023
n0tl3ss added a commit that referenced this issue Mar 9, 2023
graemerocher added a commit that referenced this issue Mar 10, 2023
* Use service ID instead of host to identify clients
* Fallback to a fixed unmatched URI when template is not found 

Fixes #458 and Fixes #397

---------

Co-authored-by: Graeme Rocher <graeme.rocher@oracle.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants