Skip to content

Commit

Permalink
Multichain telemetry support (#10623)
Browse files Browse the repository at this point in the history
* Initial draft

* Add manager

* Update config TOML

* Update config tests

* Add telemetry manager tests

* Fix lint

* Add CHANGELOG.md

* Update TelemetryService Send interface

* Fix bad merge

* Fix hanging tests

* Change config from TelemetryIngressEndpoint to TelemetryIngress.Endpoints

* - Fix wrong context being passed

* - Remove protocol prefix from telemetry URL
- Drop context from TelemPayload

* - Fix context in tests

* - Update CHANGELOG.md

* - Add fields back and show error

* - Fix failing tests

* Move changelog entry to [dev]

* Update so that telemetry can still be configured the old way

* Update CONFIG.md
  • Loading branch information
george-dorin authored and sirenko committed Nov 9, 2023
1 parent 38eac74 commit 544a68d
Show file tree
Hide file tree
Showing 46 changed files with 1,230 additions and 317 deletions.
14 changes: 12 additions & 2 deletions core/config/docs/core.toml
Original file line number Diff line number Diff line change
Expand Up @@ -90,9 +90,9 @@ LeaseRefreshInterval = '1s' # Default
UniConn = true # Default
# Logging toggles verbose logging of the raw telemetry messages being sent.
Logging = false # Default
# ServerPubKey is the public key of the telemetry server.
# ServerPubKey is the public key of the telemetry server. This field will be removed in a furture version
ServerPubKey = 'test-pub-key' # Example
# URL is where to send telemetry.
# URL is where to send telemetry. This field will be removed in a furture version
URL = 'https://prom.test' # Example
# BufferSize is the number of telemetry messages to buffer before dropping new ones.
BufferSize = 100 # Default
Expand All @@ -105,6 +105,16 @@ SendTimeout = '10s' # Default
# UseBatchSend toggles sending telemetry to the ingress server using the batch client.
UseBatchSend = true # Default

[[TelemetryIngress.Endpoints]] # Example
# Network aka EVM, Solana, Starknet
Network = 'EVM' # Example
# ChainID of the network
ChainID = '111551111' # Example
# ServerPubKey is the public key of the telemetry server.
ServerPubKey = 'test-pub-key-111551111-evm' # Example
# URL is where to send telemetry.
URL = 'localhost-111551111-evm:9000' # Example

[AuditLogger]
# Enabled determines if this logger should be configured at all
Enabled = false # Default
Expand Down
22 changes: 22 additions & 0 deletions core/config/docs/docs.go
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,24 @@ func newTable(line string, desc lines) *table {
return t
}

func newArrayOfTables(line string, desc lines) *table {
t := &table{
name: strings.Trim(strings.Trim(line, fieldExample), "[]"),
codes: []string{line},
desc: desc,
}
if len(desc) > 0 {
if strings.HasPrefix(strings.TrimSpace(desc[0]), tokenAdvanced) {
t.adv = true
t.desc = t.desc[1:]
} else if strings.HasPrefix(strings.TrimSpace(desc[len(desc)-1]), tokenExtended) {
t.ext = true
t.desc = t.desc[:len(desc)-1]
}
}
return t
}

func (t table) advanced() string {
if t.adv {
return advancedWarning("Do not change these settings unless you know what you are doing.")
Expand Down Expand Up @@ -217,6 +235,10 @@ func parseTOMLDocs(s string) (items []fmt.Stringer, err error) {
items = append(items, desc)
desc = nil
}
} else if strings.HasPrefix(line, "[[") {
currentTable = newArrayOfTables(line, desc)
items = append(items, currentTable)
desc = nil
} else if strings.HasPrefix(line, "[") {
currentTable = newTable(line, desc)
items = append(items, currentTable)
Expand Down
7 changes: 7 additions & 0 deletions core/config/docs/docs_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import (
"github.com/smartcontractkit/chainlink/v2/core/services/chainlink"
"github.com/smartcontractkit/chainlink/v2/core/services/chainlink/cfgtest"
"github.com/smartcontractkit/chainlink/v2/core/services/keystore/keys/ethkey"
"github.com/smartcontractkit/chainlink/v2/core/store/models"
"github.com/smartcontractkit/chainlink/v2/core/utils/config"
)

Expand All @@ -37,6 +38,12 @@ func TestDoc(t *testing.T) {
require.NoError(t, err)
}

// Except for TelemetryIngress.ServerPubKey and TelemetryIngress.URL as this will be removed in the future
// and its only use is to signal to NOPs that these fields are no longer allowed
emptyString := ""
c.TelemetryIngress.ServerPubKey = &emptyString
c.TelemetryIngress.URL = new(models.URL)

cfgtest.AssertFieldsNotNil(t, c)

var defaults chainlink.Config
Expand Down
176 changes: 176 additions & 0 deletions core/config/mocks/telemetry_ingress.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

87 changes: 87 additions & 0 deletions core/config/mocks/telemetry_ingress_endpoint.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 14 additions & 2 deletions core/config/telemetry_ingress_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,26 @@ import (
"time"
)

//go:generate mockery --quiet --name TelemetryIngress --output ./mocks/ --case=underscore --filename telemetry_ingress.go

type TelemetryIngress interface {
Logging() bool
UniConn() bool
ServerPubKey() string
URL() *url.URL
BufferSize() uint
MaxBatchSize() uint
SendInterval() time.Duration
SendTimeout() time.Duration
UseBatchSend() bool
Endpoints() []TelemetryIngressEndpoint

ServerPubKey() string // Deprecated: Use TelemetryIngressEndpoint.ServerPubKey instead, this field will be removed in future versions
URL() *url.URL // Deprecated: Use TelemetryIngressEndpoint.URL instead, this field will be removed in future versions
}

//go:generate mockery --quiet --name TelemetryIngressEndpoint --output ./mocks/ --case=underscore --filename telemetry_ingress_endpoint.go
type TelemetryIngressEndpoint interface {
Network() string
ChainID() string
ServerPubKey() string
URL() *url.URL
}
Loading

0 comments on commit 544a68d

Please sign in to comment.