Skip to content

Commit

Permalink
Merge pull request #237 from ethpandaops/feat/config-topics
Browse files Browse the repository at this point in the history
feat(sentry): allow config subscription of topics
  • Loading branch information
Savid authored Oct 12, 2023
2 parents e1a9e0d + 3fcd1bf commit c9704a2
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 1 deletion.
1 change: 1 addition & 0 deletions docs/sentry.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ Sentry requires a single `yaml` config file. An example file can be found [here]
| name | string | | Unique name of the sentry |
| labels | object | | A key value map of labels to append to every sentry event |
| ethereum.beaconNodeAddress | string | | [Ethereum consensus client](https://ethereum.org/en/developers/docs/nodes-and-clients/#consensus-clients) http server endpoint |
| ethereum.beaconSubscriptions | array<string> | | List of [topcis](https://ethereum.github.io/beacon-APIs/#/Events/eventstream) to subscribe to. If empty, all subscriptions are subscribed to.
| ntpServer | string | `pool.ntp.org` | NTP server to calculate clock drift for events |
| outputs | array<object> | | List of outputs for the sentry to send data to |
| outputs[].name | string | | Name of the output |
Expand Down
10 changes: 9 additions & 1 deletion pkg/sentry/ethereum/beacon.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,17 @@ type BeaconNode struct {
func NewBeaconNode(ctx context.Context, name string, config *Config, log logrus.FieldLogger) (*BeaconNode, error) {
opts := *beacon.
DefaultOptions().
EnableDefaultBeaconSubscription().
DisablePrometheusMetrics()

if config.BeaconSubscriptions != nil {
opts.BeaconSubscription = beacon.BeaconSubscriptionOptions{
Enabled: true,
Topics: *config.BeaconSubscriptions,
}
} else {
opts.EnableDefaultBeaconSubscription()
}

opts.HealthCheck.Interval.Duration = time.Second * 3
opts.HealthCheck.SuccessfulResponses = 1

Expand Down
2 changes: 2 additions & 0 deletions pkg/sentry/ethereum/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ type Config struct {
OverrideNetworkName string `yaml:"overrideNetworkName" default:""`
// BeaconNodeHeaders is a map of headers to send to the beacon node.
BeaconNodeHeaders map[string]string `yaml:"beaconNodeHeaders"`
// BeaconSubscriptions is a list of beacon subscriptions to subscribe to.
BeaconSubscriptions *[]string `yaml:"beaconSubscriptions"`
}

func (c *Config) Validate() error {
Expand Down

0 comments on commit c9704a2

Please sign in to comment.