Repository navigation
Conversation
snowkide
force-pushed
the
feat/ws-client-metrics
branch
from
November 3, 2026 10:57
4be4dbf to
9371482
Compare
snowkide
force-pushed
the
feat/ws-client-metrics
branch
from
November 3, 2026 11:23
9371482 to
1071e70
Compare
snowkide
force-pushed
the
feat/ws-client-metrics
branch
from
November 3, 2026 13:31
1071e70 to
51e00bb
Compare
snowkide
force-pushed
the
feat/ws-client-metrics
branch
from
November 4, 2026 14:03
51e00bb to
1504e16
Compare
… metrics
Client WebSocket traffic is only partly visible in metrics: requests that
reach the network are counted in network_request_received_total exactly
like HTTP ones, requests rejected before the network (invalid JSON,
disallowed method, failed auth, consumer rate limit, network unavailable)
are not counted at all, and nothing records why connections close. The
subscription metrics cover connections, subscriptions and notifications
per network, but not per client.
- network_request_received_total gains a trailing transport label
("http" or "ws"), recorded on NormalizedRequest and defaulting to "http".
- erpc_websocket_requests_total{project,network,category,user,agent_name,
outcome} counts every JSON-RPC request on a client connection (batch
items individually), including pre-network rejections. outcome is one of
ok, error, rate_limited, invalid, invalid_batch, method_not_allowed,
unauthorized, network_unavailable. category stays "n/a" until the
request is authenticated and network until the network resolves, so a
rejected request cannot mint series from a client-chosen method name or
chain id.
- erpc_websocket_connections_closed_total{project,close_code,initiator}.
initiator is "client" when the peer ended the connection (its close
code, or 1006 when it vanished or stopped answering pings) and "server"
otherwise. close_code is bounded to the RFC 6455 range 1000-1015, else
"other".
- websocket_notifications_sent_total and
websocket_subscription_notifications_dropped_total gain trailing user
and agent_name labels, captured at eth_subscribe time and carried on the
subscription (wsclient.SubscriptionLabels). Both become labeled counters,
so metrics.customizations can drop the per-client labels.
Docs: Metrics section in operation/websocket, rows in reference/metrics,
and the transport label wherever network_request_received_total labels
are listed.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
snowkide
force-pushed
the
feat/ws-client-metrics
branch
from
November 5, 2026 13:52
1504e16 to
457777b
Compare
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Client WebSocket traffic is only partly visible in metrics. Requests that reach the network are counted in
erpc_network_request_received_totalexactly like HTTP ones. Requests rejected before the network (invalid JSON, disallowed method, failed auth, consumer rate limit, network unavailable) are not counted at all, and nothing records why connections close. This builds on the subscription metrics from erpc#1255 instead of adding parallel ones:transport(http|ws) as a trailing label onerpc_network_request_received_total, recorded onNormalizedRequest(defaults tohttp).erpc_websocket_requests_total{project,network,category,user,agent_name,outcome}: every request on a client connection, batch items individually, including pre-network rejections. Outcomes:ok,error,rate_limited,invalid,invalid_batch,method_not_allowed,unauthorized,network_unavailable.categorystaysn/auntil auth andnetworkuntil the network resolves, so rejected requests cannot create series from a method name or chain id the client chose.erpc_websocket_connections_closed_total{project,network,close_code,initiator}, withclose_codebounded to RFC 6455 1000-1015, elseother.networkonerpc_websocket_connections_active, so open connections can be broken down per network like the subscription metrics.user/agent_nameonerpc_websocket_notifications_sent_totalanderpc_websocket_subscription_notifications_dropped_total, captured ateth_subscribe. Both become labeled counters, sometrics.customizationscan drop the per-client labels.Notes for review:
networkis set once at upgrade from the project config (static or already lazy-loaded networks), the same value asNetwork.Label(), andn/afor any other chain id. The upgrade accepts any chain id in the URL, so using it as is would let clients create unbounded series;GetNetworkis not used because it would block the upgrade until the network is bootstrapped. Covered byTestWebSocket_ConnectionNetworkLabelIsBounded.networkonwebsocket_connections_activechanges that gauge's label set; queries that aggregate it (sum(...)) are unaffected.initiator="client",close_code="1006"(documented).operation/websocket, rows inreference/metrics.Verification
Based on fork
main@ f97c9f6 (erpc/erpc0.5.0 @ 204f98c).go build ./...,go veton touched packages andgofmt -lon touched files are clean.go test ./common/ -run TestNormalizedRequest_Transport,go test ./telemetry/ ./indexer/adapters/wsclient/: ok.go test ./erpc/ -run 'TestWebSocket|TestWs|TestSubscription|TestHttpServer_WebSocket': ok.-race, onlyTestWebSocket_ProjectsSharingANetworkUseTheirOwnUpstreamsfails, andTestWebSocket_UnsubscribeIsScopedToConnectionis flaky (1 in 5); both fail the same way on plainmain.TestWebSocket_RequestAccounting,TestWebSocket_RequestAccountingAuthRateLimited,TestWebSocket_CloseCodeLabelIsBounded,TestNormalizedRequest_TransportDefaultsToHttp,TestWebSocket_LogsSubscribeOnAllUpstreamsAndDedupe.AI assistance
🤖 Generated with Claude Code