From 840073f8193fd23fd6ef88e875709212a0a0947f Mon Sep 17 00:00:00 2001 From: Ethen Pociask Date: Wed, 30 Aug 2023 16:07:16 -0700 Subject: [PATCH] Lagniappe Cleanups (#155) --- docs/architecture/alerting.markdown | 21 ++++-- genesis.example.json | 2 +- .../{routing_directory.go => routing.go} | 0 ...ting_directory_test.go => routing_test.go} | 0 internal/client/{eth_client.go => eth.go} | 0 internal/client/{geth_client.go => geth.go} | 0 .../{pagerduty_client.go => pagerduty.go} | 0 ...rduty_client_test.go => pagerduty_test.go} | 0 internal/client/{slack_client.go => slack.go} | 0 .../{slack_client_test.go => slack_test.go} | 0 mocks/alert_client.go | 65 ------------------- 11 files changed, 16 insertions(+), 72 deletions(-) rename internal/alert/{routing_directory.go => routing.go} (100%) rename internal/alert/{routing_directory_test.go => routing_test.go} (100%) rename internal/client/{eth_client.go => eth.go} (100%) rename internal/client/{geth_client.go => geth.go} (100%) rename internal/client/{pagerduty_client.go => pagerduty.go} (100%) rename internal/client/{pagerduty_client_test.go => pagerduty_test.go} (100%) rename internal/client/{slack_client.go => slack.go} (100%) rename internal/client/{slack_client_test.go => slack_test.go} (100%) delete mode 100644 mocks/alert_client.go diff --git a/docs/architecture/alerting.markdown b/docs/architecture/alerting.markdown index 9be6647f..b88c6aa6 100644 --- a/docs/architecture/alerting.markdown +++ b/docs/architecture/alerting.markdown @@ -24,14 +24,17 @@ end subgraph AM["Alerting Manager"] alertingRelay --> |Alert|EL EL[eventLoop] --> |Alert SUUID|AS["AlertStore"] - AS --> |Alert Destination|EL - EL --> |Submit alert|AD[Destination] - AD --> |Slack|SH["Slack Handler"] - AD --> |counterParty|CPH["Counterparty Handler"] + AS --> |Alert Policy|EL + EL --> |Submit alert|SR["SeverityRouter"] + SR --> SH["Slack"] + SR --> PH["PagerDuty"] + SR --> CPH["CounterParty Handler"] end CPH --> |"HTTP POST"|TPH["Third Party API"] SH --> |"HTTP POST"|SlackAPI("Slack Webhook API") +PH --> |"HTTP POST"|PagerDutyAPI("PagerDuty API") + {% endraw %} @@ -49,9 +52,12 @@ An alert destination is a configurable destination that an alert can be sent to. #### Slack The Slack alert destination is a configurable destination that allows alerts to be sent to a specific Slack channel. The Slack alert destination will be configured with a Slack webhook URL. The Slack alert destination will then use this URL to send alerts to the specified Slack channel. -**NOTE: As of now Pessimism can only post alerts to a single slack channel** -### Cooldown +#### PagerDuty +The PagerDuty alert destination is a configurable destination that allows alerts to be sent to a specific PagerDuty services via the use of integration keys. Pessimism also uses the SUUID associated with an alert as a deduplication key for PagerDuty. This is done to ensure that PagerDuty will not be spammed with duplicate or incidents. + + +### Alert CoolDowns To ensure that alerts aren't spammed to destinations once invoked, a time based cooldown value (`cooldown_time`) can be defined within the `alert_params` of a heuristic session config. This time value determines how long a heuristic session must wait before being allowed to alert again. An example of this is shown below: @@ -73,3 +79,6 @@ An example of this is shown below: } } ``` + +### Alert Messages +Pessimism allows for the arbitrary customization of alert messages. This is done by defining an `message` value string within the `alerting_params` of a heuristic session bootstrap config or session creation request. This is critical for providing additional context on alerts that allow for easier ingestion by downstream consumers (i.e, alert responders). \ No newline at end of file diff --git a/genesis.example.json b/genesis.example.json index 841830b7..ad244e09 100644 --- a/genesis.example.json +++ b/genesis.example.json @@ -10,7 +10,7 @@ }, "heuristic_params": { "address": "0xfC0157aA4F5DB7177830ACddB3D5a9BB5BE9cc5e", - "args": ["Transfer(address, address, uint256)"] + "args": ["Transfer(address,address,uint256)"] } }, { diff --git a/internal/alert/routing_directory.go b/internal/alert/routing.go similarity index 100% rename from internal/alert/routing_directory.go rename to internal/alert/routing.go diff --git a/internal/alert/routing_directory_test.go b/internal/alert/routing_test.go similarity index 100% rename from internal/alert/routing_directory_test.go rename to internal/alert/routing_test.go diff --git a/internal/client/eth_client.go b/internal/client/eth.go similarity index 100% rename from internal/client/eth_client.go rename to internal/client/eth.go diff --git a/internal/client/geth_client.go b/internal/client/geth.go similarity index 100% rename from internal/client/geth_client.go rename to internal/client/geth.go diff --git a/internal/client/pagerduty_client.go b/internal/client/pagerduty.go similarity index 100% rename from internal/client/pagerduty_client.go rename to internal/client/pagerduty.go diff --git a/internal/client/pagerduty_client_test.go b/internal/client/pagerduty_test.go similarity index 100% rename from internal/client/pagerduty_client_test.go rename to internal/client/pagerduty_test.go diff --git a/internal/client/slack_client.go b/internal/client/slack.go similarity index 100% rename from internal/client/slack_client.go rename to internal/client/slack.go diff --git a/internal/client/slack_client_test.go b/internal/client/slack_test.go similarity index 100% rename from internal/client/slack_client_test.go rename to internal/client/slack_test.go diff --git a/mocks/alert_client.go b/mocks/alert_client.go deleted file mode 100644 index 1aae3778..00000000 --- a/mocks/alert_client.go +++ /dev/null @@ -1,65 +0,0 @@ -// Code generated by MockGen. DO NOT EDIT. -// Source: github.com/base-org/pessimism/internal/client (interfaces: AlertClient) - -// Package mocks is a generated GoMock package. -package mocks - -import ( - context "context" - reflect "reflect" - - client "github.com/base-org/pessimism/internal/client" - gomock "github.com/golang/mock/gomock" -) - -// MockAlertClient is a mock of AlertClient interface. -type MockAlertClient struct { - ctrl *gomock.Controller - recorder *MockAlertClientMockRecorder -} - -// MockAlertClientMockRecorder is the mock recorder for MockAlertClient. -type MockAlertClientMockRecorder struct { - mock *MockAlertClient -} - -// NewMockAlertClient creates a new mock instance. -func NewMockAlertClient(ctrl *gomock.Controller) *MockAlertClient { - mock := &MockAlertClient{ctrl: ctrl} - mock.recorder = &MockAlertClientMockRecorder{mock} - return mock -} - -// EXPECT returns an object that allows the caller to indicate expected use. -func (m *MockAlertClient) EXPECT() *MockAlertClientMockRecorder { - return m.recorder -} - -// GetName mocks base method. -func (m *MockAlertClient) GetName() string { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "GetName") - ret0, _ := ret[0].(string) - return ret0 -} - -// GetName indicates an expected call of GetName. -func (mr *MockAlertClientMockRecorder) GetName() *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetName", reflect.TypeOf((*MockAlertClient)(nil).GetName)) -} - -// PostEvent mocks base method. -func (m *MockAlertClient) PostEvent(arg0 context.Context, arg1 *client.AlertEventTrigger) (*client.AlertAPIResponse, error) { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "PostEvent", arg0, arg1) - ret0, _ := ret[0].(*client.AlertAPIResponse) - ret1, _ := ret[1].(error) - return ret0, ret1 -} - -// PostEvent indicates an expected call of PostEvent. -func (mr *MockAlertClientMockRecorder) PostEvent(arg0, arg1 interface{}) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "PostEvent", reflect.TypeOf((*MockAlertClient)(nil).PostEvent), arg0, arg1) -}