feat(observer): per-RPC observer groups with global fallback#62
feat(observer): per-RPC observer groups with global fallback#62qk-santi wants to merge 2 commits into
Conversation
Add support for overriding the observer set on a per-RPC-provider basis.
Each provider can now define its own observers group in config; providers
without one fall back to the global observers.rpc set. Non-RPC providers
(exchange_rates, system, hash_divergence, etc.) use a separate
observers.system set on their own EventBus.
- Add GlobalObservers{RPC, System} config struct; observers.rpc becomes
the fallback for all RPC providers, observers.system for non-RPC
- Add optional observers field on RPC provider config; when set, a
dedicated EventBus is created for that provider
- Rename GetEnabledObserverSet → GetObserverSetFrom(cfg Observers) to
accept an explicit config instead of reading global state
- Replace promauto with manual Register + registerOrExisting helper to
prevent duplicate-registration panics on repeated Init calls
- Fix Publish to only warn on empty subscriber sets for topics that were
explicitly subscribed (avoids false warnings for unregistered topics)
| } | ||
|
|
||
| p := provider.NewHeimdallProvider(n, eb, h) | ||
| p := provider.NewHeimdallProvider(n, systemEB, h) |
There was a problem hiding this comment.
We're leveraging here the systemEB as it's a singleton, even if it's chain related
We could create another event bus for chain-related stuff, but might be too much?
This affects:
HeimdallSensorNetworkProverNetworkAggchain
| ## @param rpc.disabled - list of strings - optional | ||
| ## @env PANOPTICHAIN_OBSERVERS_RPC_DISABLED - list of strings - optional | ||
| # | ||
| # rpc: |
There was a problem hiding this comment.
The new nesting level forces this to be a breaking change
|
Hey @qk-santi 👋 I've been looking at this PR and wanted to suggest an alternative approach that might avoid the breaking config change. The core idea: Keep the existing Instead of changing
For observer groups, YAML anchors work out of the box with Viper: # Global default (unchanged from current schema)
observers:
enabled:
- block
- transaction_count
- finalized_height
# Define reusable groups with YAML anchors
x-observer-groups:
light: &light
enabled:
- block
- finalized_height
providers:
rpc:
- name: "Polygon Mainnet"
url: "https://internal-rpc"
label: "internal"
# No override = uses global observers
- name: "Polygon Mainnet"
url: "https://external-rpc"
label: "external"
observers: *light # Uses the 'light' groupI verified that Viper correctly resolves YAML anchors - the This achieves the main goal (per-provider observers) without changing the config schema for existing users. The RPC/system split could be added later as an opt-in feature if needed. What do you think? |
|



Summary
Add support for overriding the observer set on a per-RPC-provider basis.
Each provider can now define its own
observersgroup in config; providers without one fall back to the globalobservers.rpcset.Non-RPC providers (exchange_rates, system, hash_divergence, heimdall, sensor, etc.) use a separate
observers.systemset on their own EventBus.Changes
GlobalObservers{RPC, System}config struct;observers.rpcbecomes the fallback for all RPC providers,observers.systemfor non-RPCobserversfield on RPC provider config; when set, a dedicated EventBus is created for that providerGetEnabledObserverSet→GetObserverSetFrom(cfg Observers)to accept an explicit config instead of reading global statepromautowith manualprometheus.Register+registerOrExistinghelper to prevent duplicate-registration panics on repeatedInitcallsPublishto only warn on empty subscriber sets for topics that were explicitly subscribed (avoids false warnings for unregistered topics)Config example