Repository navigation
v0.2.1
Connection metrics. Servers can now see how many WebSocket, SSE and grpcws
connections are open, why each one closed (including clients dropped for
not reading), and how many frames went each way, without hand-rolling it.
The hooks have no metrics dependency, and servicekit/prom exports them to
Prometheus (issues 11 and 13, PR 58).
Added
http.ConnObserver, withConnInfoandCloseReason. Set it on
BaseConn.Observer/BaseSSEConn.Observer, once on
WSConnConfig.Observer/SSEConnConfig.Observer, or on
grpcws.ConnOptions.Observer. It hears every open, every close with a
reason (client_close,server_close,write_timeout,write_error,
pong_timeout,read_error,start_failed) and lifetime, and every frame
sent or received. A nil observer costs nothing.servicekit/prom:ConnMetricsimplementsConnObserverfor Prometheus,
andHTTPMetricsis request middleware labelled by mux route template. The
rootgo.modnow requiresprometheus/client_golangv1.24.1, but
http/andmiddleware/don't import it, andmake check-depsnow fails if
they do.- Load tests for WebSocket (100 connections, 500 connect/disconnect cycles
with a goroutine-leak check, broadcast, a slow consumer) and SSE (100
connections, hub churn). They skip under-short. make exercise:cmd/grpcws-demo -exerciseopens 300 grpcws
subscribers, 10 of which never read, and checks/metricsagainst what the
driver did. CI runs it. The demo serves/metricsand takes
-write-timeoutand-close-on-stream-end.
Fixed
cmd/grpcws-demo: a room sent its join/leave/action events while holding
its lock, and its broadcast loop needs that lock to drain them, so many
players leaving at once could deadlock it.