Use the go-wsstat
Golang package to trace WebSocket connection and latency in your Go applications. It wraps the gorilla/websocket package for the WebSocket protocol implementation, and measures the duration of the different phases of the connection cycle. The program takes inspiration from the go-httpstat package, which is useful for tracing HTTP requests.
The package is built on Go 1.21 but it has been tested to work with Go 1.18, in case that is of interest. Install to use in your project with go get
:
go get github.com/jakobilobi/go-wsstat
The _example/main.go program demonstrates how to use the go-wsstat
package to trace a WebSocket connection.
Run the example:
go run _example/main.go <a WebSocket URL>
Run the tests:
make test