socket.io icon indicating copy to clipboard operation
socket.io copied to clipboard

Ability to get all namespaces

Open DataTables opened this issue 4 years ago • 3 comments

Is your feature request related to a problem? Please describe.

I'm using socket.io-prometheus-metrics to report metrics about sockets to Prometheus and it works great with SocketIO 1/2, but not not with 3/4 due to the change in variable name for _nsps.

Describe the solution you'd like

Could we get an API method added to the server which will give a list of all namespaces available - something like:

public namespaces() {
  return Object.keys(this._nsps);
}

Describe alternatives you've considered

I've got a typing hack in locally at the moment to workaround it.

Additional context

N/A

Thanks! Wonderful to see Socket.IO moving forwards again.

DataTables avatar May 07 '21 11:05 DataTables

@DataTables I'm working on a (hopefully temporary) fork of socket.io-prometheus-metrics to work with socket.io v4 and I've ran into the same namespaces issue. Would you mind sharing your typing hack workaround?

joshbwlng avatar Jul 28 '21 02:07 joshbwlng

@joshbwlng If you Click DataTables' handle and then Repositories, you can search for socket.io and find their fork of socket.io-prometheus-metrics. In that repo is a v2 branch and the latest commit is:

https://github.com/DataTables/socket.io-prometheus-metrics/commit/83fe75e8f035da6a6dcad6d6aed28da2e1a68702

btimby avatar Aug 10 '21 22:08 btimby

It would be great if there was a standardized way to retrieve a list of all namespaces, rather than having to access a private property. Something like io.namespaces rather than using io._nsps.

bra1n avatar May 04 '23 08:05 bra1n