proton-bridge: gRPC metrics exporter (prototype)#4
Merged
Conversation
Replace the external-probe metrics approach with an in-container Prometheus exporter that scrapes Bridge's gRPC frontend, so account login state and dropped-auth are observable -- not just transport readiness. - run bridge as `--grpc` by default (same mail bridge as --noninteractive, plus the machine API the GUI uses; --parent-pid defaults to -1 so no watchdog shutdown). noninteractive/cli still selectable via BRIDGE_MODE. - add exporter/ Go module: reads grpcServerConfig.json, dials the unix socket with the pinned TLS cert + server-token, polls GetUserList/Version and subscribes RunEventStream. Exposes proton_bridge_account_state/connected, used/total bytes, and user_disconnected/bad_event/imap_login_failed counters. - vendored Bridge gRPC stubs (GPL-3.0) under exporter/bridgepb; documented re-vendor step for upstream bumps. - build exporter in a dedicated stage; add `exporter` s6 service; healthcheck now checks the service + /metrics 200; CONTAINER_METRICS_PORT (default 9154). Validated on arm64: image builds, bridge --grpc bootstraps, exporter connects (proton_bridge_up 1, scrape_errors 0), /metrics 200, container healthy. Account/event series need a real Proton login to populate -- not yet exercised. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This was referenced Jun 26, 2026
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.
Summary
Prototype of Option B from the metrics discussion: replace the external black-box probe approach (the stale
feat/proton-bridge-metricsbranch) with an in-container Prometheus exporter that scrapes Bridge's gRPC frontend, so we get per-account login state and dropped-auth signals — not just transport readiness.Opened as a draft: the live gRPC path is proven, but the account/event metrics need a real Proton login to exercise (see below).
Approach
--grpcby default (BRIDGE_MODE=grpc). This serves the exact same mail bridge as--noninteractiveplus the gRPC machine API the desktop GUI uses.--parent-piddefaults to-1, so the GUI watchdog that would otherwise shut it down stays disabled.noninteractive/cliremain selectable.exporter/Go module readsgrpcServerConfig.json, dials the unix socket, pins Bridge's self-signed TLS cert (CN127.0.0.1) and presents theserver-token— same handshake as the GUI. It pollsGetUserList/Versionand subscribes toRunEventStream.exporter/bridgepb/, GPL-3.0, taken verbatim from upstream with only the Go package renamed) — avoids a protoc toolchain in the build. Re-vendor step documented inexporter/README.mdfor each version bump (the gRPC API is Bridge's internal GUI contract and can shift between releases).exporters6 service; healthcheck now also checks the service +/metrics200;CONTAINER_METRICS_PORT(default9154).Metrics
proton_bridge_up,proton_bridge_info{version},proton_bridge_accounts_total,proton_bridge_account_connected{account},proton_bridge_account_state{account,state},proton_bridge_account_used_bytes/_total_bytes{account},proton_bridge_internet_connected, and countersproton_bridge_user_disconnected_total/user_bad_event_total/imap_login_failed_total(+exporter_scrape_errors_total).Validation (local, linux/arm64)
bridge --grpcbootstraps headless, writes config, no watchdog killproton_bridge_up 1,scrape_errors 0/metricsserves 200;proton_bridge_info{version="3.25.0+git"}HEALTHCHECKNot yet exercised: account/event series (
account_connected,*_disconnected_total, …) need a real logged-in Proton account — they're registered but emit no samples until then. CI will also run the full multi-arch build.Follow-ups before un-drafting
account_statetransitions + a forced disconnect increments the counter).--grpcshould be the default or opt-in.🤖 Generated with Claude Code