Skip to content

[ISSUE #8430] Expose bounded client registration progress and health diagnostics - #8544

Open
konlue wants to merge 2 commits into
apache:masterfrom
konlue:feat/8430-registration-diagnostics
Open

konlue wants to merge 2 commits into
apache:masterfrom
konlue:feat/8430-registration-diagnostics

Conversation

@konlue

@konlue konlue commented Nov 22, 2026

Copy link
Copy Markdown
Contributor

Fixes #8430.

The Java client's registration work runs asynchronously on the disruptor: transport failures land in the failback layer's bounded retry (10 s × 18) and then silently disappear, heartbeats only log, and application startup success therefore says nothing about usable gateway registration. This PR gives applications an optional, bounded view of registration progress, written only at the boundaries the flow already passes through — no extra registration calls, no second retry chain, no per-request work.

What changed

ClientRegistrationDiagnostics (in shenyu-register-client-api, next to the failback layer, so every repository implementation inherits it) keeps one bounded observation per registration identity, keyed by the identity the failback layer already builds (config/namespace/protocol scoped). FailbackRegistryRepository records at each completion boundary: an acknowledged persist return is REGISTERED (this is the Admin acknowledgement, not gateway-observed readiness — nothing is inferred from a successful POST), a failed persist or retry attempt is RETRYING with a bounded failure category (TIMEOUT or TRANSPORT, walking the exception cause chain) and a truncated credential-free reason, the owner-aware removal after the retry budget is exhausted is EXHAUSTED (previously a silent disappearance), the compatibility removal becomes UNKNOWN, and orderly close retires every retained entry as OFFLINE. Each entry carries timestamps and an attempt counter; duplicate failures and replaced retry tasks update the same entry instead of inflating logical counts, and a newer failure keeps its own task exactly as before. The disruptor enqueue side contributes a queued-events aggregate only, because per-event identity is not reliably available before a completion boundary.

Retained state is hard-capped at 512 identities (rejected overflows only bump a counter), aggregate counters are unbounded primitives, and entries never contain credentials, tokens or raw payloads. Applications read snapshot() programmatically (bounded entry list, most recently updated first, plus counters); an opt-in Spring Boot health contributor ships in the common client starter — gated on Actuator's presence (@ConditionalOnClass) and shenyu.register.diagnostics.health-enabled=true — and always reports UP with the snapshot in its details, so application liveness never fails by default and a missing Actuator library changes nothing.

Tests

FailbackRegistryRepositoryDiagnosticsTest drives the real boundaries with a controllable repository: the lifecycle fixture walks initial success, transport failure with retry, recovery at the retry boundary, exhaustion and orderly close, asserting the snapshot matches each event; duplicate failures keep one entry without inflating counters; different namespaces scope separate identities; timeouts carry the timeout category; the compatibility removal becomes UNKNOWN; 513 distinct identities overflow the cap into a counter while observations keep flowing; failure reasons are truncated; and queued events are counted at the enqueue boundary without fabricating entries. The health configuration test verifies the opt-in property, the always-UP contributor with snapshot details, and that a classpath without Actuator (filtered loader) leaves the context healthy and contributor-free. All boundary assertions are red against the previous silent-omit behavior. Module results on the current master baseline: shenyu-register-client-api 33 (was 25), shenyu-client-core 102 unchanged, shenyu-register-client-http and shenyu-spring-boot-starter-client-common green; checkstyle clean.

…ealth diagnostics

ClientRegistrationDiagnostics records one bounded observation per registration identity at the boundaries the registration flow already passes through: acknowledged persist returns, failed persists and retry attempts in FailbackRegistryRepository, retry exhaustion at the owner-aware removal, and orderly close which retires entries as offline. The vocabulary distinguishes registered, retrying, exhausted, offline and unknown, carries timestamps, an attempt counter and a bounded credential-free failure reason; retained identities are hard-capped with overflow counted, and aggregate counters stay unbounded primitives. The disruptor enqueue side contributes a queued-events aggregate only, since per-event identity is not reliably available before a completion boundary. Applications read ClientRegistrationDiagnostics.snapshot() programmatically; an opt-in Spring Boot health contributor ships in the common client starter, gated on Actuator presence and shenyu.register.diagnostics.health-enabled, and always reports UP with the snapshot in details so liveness never fails by default. No extra registration calls, no second retry chain, no per-request work; existing timing and retry semantics are covered by the unchanged suite plus new boundary fixtures that are red against the silent-omit behavior.
…queue

retireAll used an unconditional replace, so a concurrent fresh failure could be overwritten by a stale offline pass; the replace is now conditional on the observed entry. The queued-events aggregate counted before the disruptor enqueue attempt instead of after it.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Task][Java Client] Expose bounded registration progress and health diagnostics

1 participant