Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions aggregator/cmd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -148,8 +148,8 @@ func runServer(configPath string, lggr logger.Logger, sugaredLggr logger.Sugared
}
lggr.Infow("Successfully loaded configuration from environment variables")

var aggMonitoring common.AggregatorMonitoring = &monitoring.NoopAggregatorMonitoring{}
if config.Monitoring.Enabled && config.Monitoring.Type == "beholder" {
var aggMonitoring common.AggregatorMonitoring = monitoring.NewNoopAggregatorMonitoring()
if config.Monitoring.Beholder.Enabled {
m, err := monitoring.InitMonitoring(beholder.Config{
InsecureConnection: config.Monitoring.Beholder.InsecureConnection,
CACertFile: config.Monitoring.Beholder.CACertFile,
Expand Down
2 changes: 1 addition & 1 deletion aggregator/pkg/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -314,7 +314,7 @@ func NewServer(l logger.SugaredLogger, config *model.AggregatorConfig, aggMonito

l.Infow("Server configuration loaded",
"storage_type", config.Storage.StorageType,
"monitoring_enabled", config.Monitoring.Enabled,
"monitoring_beholder_enabled", config.Monitoring.Beholder.Enabled,
"rate_limiting_enabled", config.RateLimiting.Enabled,
"health_check_enabled", config.HealthCheck.Enabled,
"orphan_recovery_enabled", config.OrphanRecovery.Enabled,
Expand Down
4 changes: 1 addition & 3 deletions aggregator/tests/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -173,9 +173,7 @@ func CreateServerOnlyWithMessageRulesControl(t *testing.T, options ...ConfigOpti
Storage: &model.StorageConfig{
StorageType: model.StorageTypePostgreSQL, // Default to PostgreSQL
},
Monitoring: model.MonitoringConfig{
Enabled: false,
},
Monitoring: model.MonitoringConfig{},
APIClients: []*model.ClientConfig{
{
ClientID: "test-client",
Expand Down
18 changes: 16 additions & 2 deletions bootstrap/bootstrap.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import (
"time"

"github.com/BurntSushi/toml"
"github.com/grafana/pyroscope-go"
"github.com/jmoiron/sqlx"
sdkmetric "go.opentelemetry.io/otel/sdk/metric"
"go.uber.org/zap/zapcore"
Expand Down Expand Up @@ -142,6 +143,8 @@ type Bootstrapper struct {

// accCloser is set by startWithAppConfig; JD mode uses runner.accCloser instead.
accCloser *AccessorCloserRegistry
// pyroscope is a saved reference to profiler to close it on stop
pyroscope *pyroscope.Profiler

logLevel zapcore.Level
}
Expand Down Expand Up @@ -211,15 +214,20 @@ func NewBootstrapper(
if b.config != nil && b.config.Monitoring != nil {
mon = *b.config.Monitoring
}
err := monitoring.SetupBeholder(mon, fac.MetricViews())
err := monitoring.SetupBeholder(mon.Beholder, fac.MetricViews())
if err != nil {
return nil, fmt.Errorf("failed to setup beholder: %w", err)
}
lggr, err := logging.InitLogger(b.name, b.logLevel, mon)
lggr, err := logging.InitLogger(b.name, mon.LogLevel, mon)
if err != nil {
return nil, fmt.Errorf("failed to init logger: %w", err)
}
b.lggr = lggr
pyroscopeProfiler, err := monitoring.SetupPyroscope(lggr, b.name, mon.Pyroscope)
if err != nil {
return nil, fmt.Errorf("failed to setup pyroscope: %w", err)
}
b.pyroscope = pyroscopeProfiler
lggr.Infow("Monitoring initialized", "config", mon)

return b, nil
Expand Down Expand Up @@ -462,6 +470,12 @@ func (b *Bootstrapper) Stop(ctx context.Context) error {
}
return errors.Join(errs...)
Comment thread
bukata-sa marked this conversation as resolved.
}
if b.pyroscope != nil {
err := b.pyroscope.Stop()
if err != nil {
return fmt.Errorf("failed to stop pyroscope: %w", err)
}
}
Comment thread
bukata-sa marked this conversation as resolved.
Outdated
return nil
}

Expand Down
19 changes: 4 additions & 15 deletions bootstrap/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,8 @@ const validEd25519PublicKeyHex = "0123456789abcdef0123456789abcdef0123456789abcd
// whose Validate() passes, for use in Config validation tests.
func validBeholderMonitoring() *monitoring.Config {
return &monitoring.Config{
Enabled: true,
Type: "beholder",
Beholder: monitoring.BeholderConfig{
Enabled: true,
MetricReaderInterval: 10,
TraceSampleRatio: 1.0,
TraceBatchTimeout: 5,
Expand Down Expand Up @@ -274,7 +273,7 @@ func TestConfig_validate(t *testing.T) {
name: "valid with monitoring present but disabled",
config: &Config{
JD: validJD, Keystore: validKeystore, DB: validDB, Server: validServer,
Monitoring: &monitoring.Config{Enabled: false},
Monitoring: &monitoring.Config{},
},
wantErr: false,
},
Expand All @@ -286,23 +285,13 @@ func TestConfig_validate(t *testing.T) {
},
wantErr: false,
},
{
name: "invalid monitoring: enabled without type",
config: &Config{
JD: validJD, Keystore: validKeystore, DB: validDB, Server: validServer,
Monitoring: &monitoring.Config{Enabled: true},
},
wantErr: true,
errContains: []string{"failed to validate 'monitoring' section", "monitoring type is required"},
},
{
name: "invalid monitoring: enabled beholder with non-positive metric interval",
config: &Config{
JD: validJD, Keystore: validKeystore, DB: validDB, Server: validServer,
Monitoring: &monitoring.Config{
Enabled: true,
Type: "beholder",
Beholder: monitoring.BeholderConfig{
Enabled: true,
MetricReaderInterval: 0,
TraceSampleRatio: 0.5,
TraceBatchTimeout: 5,
Expand All @@ -317,7 +306,7 @@ func TestConfig_validate(t *testing.T) {
name: "aggregates errors across db and monitoring sections",
config: &Config{
JD: validJD, Keystore: validKeystore, DB: DBConfig{URL: ""}, Server: validServer,
Monitoring: &monitoring.Config{Enabled: true},
Monitoring: &monitoring.Config{LogLevel: "invalid"},
},
wantErr: true,
errContains: []string{"failed to validate 'db' section", "failed to validate 'monitoring' section"},
Expand Down
3 changes: 1 addition & 2 deletions build/devenv/components/observability/component.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,7 @@ const Version = 1
// and executor components to consume. The toml tags keep the serialized phased
// output stable.
type Observability struct {
PyroscopeURL string `toml:"pyroscope_url"`
Monitoring ccvdeployment.MonitoringConfig `toml:"monitoring"`
Monitoring ccvdeployment.MonitoringConfig `toml:"monitoring"`
}

func init() {
Expand Down
16 changes: 10 additions & 6 deletions build/devenv/components/observability/component_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,15 @@ import (

func validConfig() map[string]any {
return map[string]any{
"version": int64(1),
"pyroscope_url": "http://host.docker.internal:4040",
"version": int64(1),
"monitoring": map[string]any{
"Enabled": true,
"Type": "beholder",
"LogLevel": "info",
"Pyroscope": map[string]any{
"Enabled": true,
"URL": "http://host.docker.internal:4040",
},
"Beholder": map[string]any{
"Enabled": true,
"InsecureConnection": true,
"OtelExporterHTTPEndpoint": "host.docker.internal:4318",
},
Expand Down Expand Up @@ -43,7 +46,8 @@ func TestRunPhase1_PublishesObservability(t *testing.T) {

obs, ok := out[Key].(*Observability)
require.True(t, ok, "output %q should be *Observability", Key)
require.Equal(t, "http://host.docker.internal:4040", obs.PyroscopeURL)
require.True(t, obs.Monitoring.Enabled)
require.True(t, obs.Monitoring.Pyroscope.Enabled)
require.Equal(t, "http://host.docker.internal:4040", obs.Monitoring.Pyroscope.URL)
require.True(t, obs.Monitoring.Beholder.Enabled)
require.Equal(t, "host.docker.internal:4318", obs.Monitoring.Beholder.OtelExporterHTTPEndpoint)
}
6 changes: 0 additions & 6 deletions build/devenv/components/tokenverifier/component.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,16 +89,10 @@ func (c *component) RunPhase4(
continue
}

template, tmplErr := tvIn.GenerateTemplateConfig()
if tmplErr != nil {
return nil, nil, fmt.Errorf("tokenverifier: generating template config: %w", tmplErr)
}

cs := ccvchangesets.GenerateTokenVerifierConfig()
output, csErr := cs.Apply(localEnv, ccvchangesets.GenerateTokenVerifierConfigInput{
ServiceIdentifier: "TokenVerifier",
ChainSelectors: selectors,
PyroscopeURL: template.PyroscopeURL,
Lombard: ccvchangesets.LombardConfigInput{
VerifierID: "LombardVerifier",
Qualifier: devenvcommon.LombardVerifierResolverQualifier,
Expand Down
6 changes: 2 additions & 4 deletions build/devenv/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,7 @@ func Load[T any](paths []string) (*T, error) {
decoder.DisallowUnknownFields()

if err := decoder.Decode(&config); err != nil {
var details *toml.StrictMissingError
if errors.As(err, &details) {
if details, ok := errors.AsType[*toml.StrictMissingError](err); ok {
Comment thread
bukata-sa marked this conversation as resolved.
fmt.Println(details.String())
}
return nil, fmt.Errorf("failed to decode TOML config, strict mode: %s", err)
Expand Down Expand Up @@ -188,8 +187,7 @@ func loadLegacyCfg(data []byte) (*Cfg, error) {
decoder := toml.NewDecoder(strings.NewReader(string(data)))
decoder.DisallowUnknownFields()
if err := decoder.Decode(&cfg); err != nil {
var details *toml.StrictMissingError
if errors.As(err, &details) {
if details, ok := errors.AsType[*toml.StrictMissingError](err); ok {
Comment thread
bukata-sa marked this conversation as resolved.
fmt.Println(details.String())
}
return nil, fmt.Errorf("failed to decode TOML config, strict mode: %s", err)
Expand Down
21 changes: 14 additions & 7 deletions build/devenv/env-cl-16.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,23 @@ cl_nodes_funding_link = 50
## Environment configuration define the topology.
[environment_topology]
indexer_address = ["http://indexer-1:8100"]
pyroscope_url = "http://host.docker.internal:4040"

[environment_topology.monitoring]
[environment_topology.Monitoring]
LogLevel = 'info'

[environment_topology.Monitoring.Pyroscope]
Enabled = true
Type = "beholder"
URL = "http://host.docker.internal:4040"

[environment_topology.monitoring.Beholder]
[environment_topology.Monitoring.Beholder]
Enabled = true
InsecureConnection = true
OtelExporterHTTPEndpoint = "host.docker.internal:4318"
LogStreamingEnabled = true
MetricReaderInterval = 5
TraceSampleRatio = 1.0
TraceBatchTimeout = 10
[environment_topology.monitoring.Beholder.TelemetryAttributes]
[environment_topology.Monitoring.Beholder.TelemetryAttributes]
ccip_env = "devenv"

[[environment_topology.nop_topology.nops]]
Expand Down Expand Up @@ -971,10 +974,14 @@ execution_interval = 15_000_000_000

[indexer.indexer_config]
[indexer.indexer_config.Monitoring]
Enabled = true
Type = 'beholder'
LogLevel = 'info'

[indexer.indexer_config.Monitoring.Pyroscope]
Enabled = false
URL = ''

[indexer.indexer_config.Monitoring.Beholder]
Enabled = true
InsecureConnection = true
CACertFile = ''
OtelExporterGRPCEndpoint = ''
Expand Down
13 changes: 8 additions & 5 deletions build/devenv/env-cl.toml
Original file line number Diff line number Diff line change
@@ -1,20 +1,23 @@
## CL mode environment topology for 2-node setup
[environment_topology]
indexer_address = ["http://indexer-1:8100"]
pyroscope_url = "http://host.docker.internal:4040"

[environment_topology.monitoring]
[environment_topology.Monitoring]
LogLevel = 'info'

[environment_topology.Monitoring.Pyroscope]
Enabled = true
Type = "beholder"
URL = "http://host.docker.internal:4040"

[environment_topology.monitoring.Beholder]
[environment_topology.Monitoring.Beholder]
Enabled = true
InsecureConnection = true
OtelExporterHTTPEndpoint = "host.docker.internal:4318"
LogStreamingEnabled = true
MetricReaderInterval = 5
TraceSampleRatio = 1.0
TraceBatchTimeout = 10
[environment_topology.monitoring.Beholder.TelemetryAttributes]
[environment_topology.Monitoring.Beholder.TelemetryAttributes]
ccip_env = "devenv"

[[environment_topology.nop_topology.nops]]
Expand Down
22 changes: 14 additions & 8 deletions build/devenv/env-phased.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,20 +14,22 @@ version = 1
## the top-level [environment_topology] section in env.toml.
[observability]
version = 1
pyroscope_url = "http://host.docker.internal:4040"
[observability.Monitoring]
LogLevel = 'info'

[observability.monitoring]
Enabled = true
Type = "beholder"
[observability.Monitoring.Pyroscope]
Enabled = false
URL = ''

[observability.monitoring.Beholder]
[observability.Monitoring.Beholder]
Enabled = true
InsecureConnection = true
OtelExporterHTTPEndpoint = "host.docker.internal:4318"
LogStreamingEnabled = true
MetricReaderInterval = 5
TraceSampleRatio = 1.0
TraceBatchTimeout = 10
[observability.monitoring.Beholder.TelemetryAttributes]
[observability.Monitoring.Beholder.TelemetryAttributes]
ccip_env = "devenv"

[protocol_contracts]
Expand Down Expand Up @@ -397,10 +399,14 @@ execution_interval = 15_000_000_000
LogLevel = 'info'

[indexer.indexer_config.Monitoring]
Enabled = true
Type = 'beholder'
LogLevel = 'info'

[indexer.indexer_config.Monitoring.Pyroscope]
Enabled = false
URL = ''

[indexer.indexer_config.Monitoring.Beholder]
Enabled = true
InsecureConnection = true
CACertFile = ''
OtelExporterGRPCEndpoint = ''
Expand Down
21 changes: 14 additions & 7 deletions build/devenv/env.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,20 +13,23 @@ high_availability = false
## Environment configuration define the topology. Eventually the topology should be the only config that is needed.
[environment_topology]
indexer_address = ["http://indexer-1:8100"]
pyroscope_url = "http://host.docker.internal:4040"

[environment_topology.monitoring]
[environment_topology.Monitoring]
LogLevel = 'info'

[environment_topology.Monitoring.Pyroscope]
Enabled = true
Type = "beholder"
URL = "http://host.docker.internal:4040"

[environment_topology.monitoring.Beholder]
[environment_topology.Monitoring.Beholder]
Enabled = true
InsecureConnection = true
OtelExporterHTTPEndpoint = "host.docker.internal:4318"
LogStreamingEnabled = true
MetricReaderInterval = 5
TraceSampleRatio = 1.0
TraceBatchTimeout = 10
[environment_topology.monitoring.Beholder.TelemetryAttributes]
[environment_topology.Monitoring.Beholder.TelemetryAttributes]
ccip_env = "devenv"

[[environment_topology.nop_topology.nops]]
Expand Down Expand Up @@ -353,10 +356,14 @@ execution_interval = 15_000_000_000
LogLevel = 'info'

[indexer.indexer_config.Monitoring]
Enabled = true
Type = 'beholder'
LogLevel = 'info'

[indexer.indexer_config.Monitoring.Pyroscope]
Enabled = false
URL = ''

[indexer.indexer_config.Monitoring.Beholder]
Enabled = true
InsecureConnection = true
CACertFile = ''
OtelExporterGRPCEndpoint = ''
Expand Down
Loading
Loading