Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
5 changes: 5 additions & 0 deletions .changeset/beholder-telemetry-metric-export-batch-size.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"chainlink": patch
---

#added `Telemetry.MetricExportBatchSize` config limiting metric data points per OTLP export request (0 disables batching); passed to the Beholder client and LOOP plugins
1 change: 1 addition & 0 deletions core/cmd/shell.go
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,7 @@ func newBeholderClient(
MetricViews: metricViews(),
MetricViewsDenyAttributes: cfgTelemetry.MetricViewsDenyAttributes(),
MetricCardinalityLimit: cfgTelemetry.MetricCardinalityLimit(),
MetricExportBatchSize: cfgTelemetry.MetricExportBatchSize(),
}

if cfgTracing.Enabled() {
Expand Down
2 changes: 2 additions & 0 deletions core/config/docs/core.toml
Original file line number Diff line number Diff line change
Expand Up @@ -913,6 +913,8 @@ LogMaxQueueSize = 2048 # Default
MetricViewsDenyAttributes = ['event_id'] # Default
# MetricCardinalityLimit sets the OTel SDK per-instrument attribute-set limit (0 disables).
MetricCardinalityLimit = 100000 # Default
# MetricExportBatchSize limits metric data points per OTLP export request. 0 disables SDK-side batching.
MetricExportBatchSize = 0 # Default

# ResourceAttributes are global metadata to include with all telemetry.
[Telemetry.ResourceAttributes]
Expand Down
1 change: 1 addition & 0 deletions core/config/telemetry_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ type Telemetry interface {
LogMaxQueueSize() int
MetricViewsDenyAttributes() []string
MetricCardinalityLimit() int
MetricExportBatchSize() int
PrometheusBridge() PrometheusBridge
}

Expand Down
4 changes: 4 additions & 0 deletions core/config/toml/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -3047,6 +3047,7 @@ type Telemetry struct {
LogMaxQueueSize *int
MetricViewsDenyAttributes []string
MetricCardinalityLimit *int
MetricExportBatchSize *int

PrometheusBridge PrometheusBridge `toml:",omitempty"`
}
Expand Down Expand Up @@ -3154,6 +3155,9 @@ func (b *Telemetry) setFrom(f *Telemetry) {
if v := f.MetricCardinalityLimit; v != nil {
b.MetricCardinalityLimit = v
}
if v := f.MetricExportBatchSize; v != nil {
b.MetricExportBatchSize = v
}
b.PrometheusBridge.setFrom(&f.PrometheusBridge)
}

Expand Down
7 changes: 7 additions & 0 deletions core/services/chainlink/config_telemetry.go
Original file line number Diff line number Diff line change
Expand Up @@ -288,6 +288,13 @@ func (b *telemetryConfig) MetricCardinalityLimit() int {
return *b.s.MetricCardinalityLimit
}

func (b *telemetryConfig) MetricExportBatchSize() int {
if b.s.MetricExportBatchSize == nil || *b.s.MetricExportBatchSize <= 0 {
return 0
}
return *b.s.MetricExportBatchSize
}

func (b *telemetryConfig) PrometheusBridge() config.PrometheusBridge {
return &prometheusBridgeConfig{b.s.PrometheusBridge}
}
Expand Down
23 changes: 23 additions & 0 deletions core/services/chainlink/config_telemetry_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -623,3 +623,26 @@ func TestTelemetryConfig_MetricCardinalityLimit(t *testing.T) {
assert.Equal(t, 100000, tc.MetricCardinalityLimit())
})
}

func TestTelemetryConfig_MetricExportBatchSize(t *testing.T) {
t.Parallel()

tests := []struct {
name string
telemetry toml.Telemetry
expected int
}{
{"ExplicitPositive", toml.Telemetry{MetricExportBatchSize: new(500)}, 500},
{"NilDisables", toml.Telemetry{}, 0},
{"ZeroDisables", toml.Telemetry{MetricExportBatchSize: new(0)}, 0},
}

for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
t.Parallel()

tc := telemetryConfig{s: tt.telemetry}
assert.Equal(t, tt.expected, tc.MetricExportBatchSize())
})
}
}
1 change: 1 addition & 0 deletions core/services/chainlink/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -558,6 +558,7 @@ func TestConfig_Marshal(t *testing.T) {
LogMaxQueueSize: new(2048),
MetricViewsDenyAttributes: []string{"event_id"},
MetricCardinalityLimit: new(100000),
MetricExportBatchSize: new(0),

PrometheusBridge: toml.PrometheusBridge{
Enabled: new(true),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -358,6 +358,7 @@ LogExportInterval = '1s'
LogMaxQueueSize = 2048
MetricViewsDenyAttributes = ['event_id']
MetricCardinalityLimit = 100000
MetricExportBatchSize = 0

[Telemetry.PrometheusBridge]
Enabled = false
Expand Down
1 change: 1 addition & 0 deletions core/services/chainlink/testdata/config-full.toml
Original file line number Diff line number Diff line change
Expand Up @@ -377,6 +377,7 @@ LogExportInterval = '1s'
LogMaxQueueSize = 2048
MetricViewsDenyAttributes = ['event_id']
MetricCardinalityLimit = 100000
MetricExportBatchSize = 0

[Telemetry.ResourceAttributes]
Baz = 'test'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -358,6 +358,7 @@ LogExportInterval = '1s'
LogMaxQueueSize = 2048
MetricViewsDenyAttributes = ['event_id']
MetricCardinalityLimit = 100000
MetricExportBatchSize = 0

[Telemetry.PrometheusBridge]
Enabled = false
Expand Down
1 change: 1 addition & 0 deletions core/web/resolver/testdata/config-empty-effective.toml
Original file line number Diff line number Diff line change
Expand Up @@ -358,6 +358,7 @@ LogExportInterval = '1s'
LogMaxQueueSize = 2048
MetricViewsDenyAttributes = ['event_id']
MetricCardinalityLimit = 100000
MetricExportBatchSize = 0

[Telemetry.PrometheusBridge]
Enabled = false
Expand Down
1 change: 1 addition & 0 deletions core/web/resolver/testdata/config-full.toml
Original file line number Diff line number Diff line change
Expand Up @@ -372,6 +372,7 @@ LogExportInterval = '1s'
LogMaxQueueSize = 2048
MetricViewsDenyAttributes = ['event_id']
MetricCardinalityLimit = 100000
MetricExportBatchSize = 0

[Telemetry.ResourceAttributes]
Baz = 'test'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -358,6 +358,7 @@ LogExportInterval = '1s'
LogMaxQueueSize = 2048
MetricViewsDenyAttributes = ['event_id']
MetricCardinalityLimit = 100000
MetricExportBatchSize = 0

[Telemetry.PrometheusBridge]
Enabled = false
Expand Down
7 changes: 7 additions & 0 deletions docs/CONFIG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2324,6 +2324,7 @@ LogExportInterval = '1s' # Default
LogMaxQueueSize = 2048 # Default
MetricViewsDenyAttributes = ['event_id'] # Default
MetricCardinalityLimit = 100000 # Default
MetricExportBatchSize = 0 # Default
```
Telemetry holds OTEL settings.
This data includes open telemetry metrics, traces, & logs.
Expand Down Expand Up @@ -2534,6 +2535,12 @@ MetricCardinalityLimit = 100000 # Default
```
MetricCardinalityLimit sets the OTel SDK per-instrument attribute-set limit (0 disables).

### MetricExportBatchSize
```toml
MetricExportBatchSize = 0 # Default
```
MetricExportBatchSize limits metric data points per OTLP export request. 0 disables SDK-side batching.

## Telemetry.ResourceAttributes
```toml
[Telemetry.ResourceAttributes]
Expand Down
1 change: 1 addition & 0 deletions plugins/loop_registry.go
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,7 @@ func (m *LoopRegistry) Register(id string) (*RegisteredLoop, error) {
envCfg.TelemetryMetricViewsDenyAttributes = m.cfgTelemetry.MetricViewsDenyAttributes()
limit := m.cfgTelemetry.MetricCardinalityLimit()
envCfg.TelemetryMetricCardinalityLimit = &limit
envCfg.TelemetryMetricExportBatchSize = m.cfgTelemetry.MetricExportBatchSize()
envCfg.TelemetryPrometheusBridgeEnabled = m.cfgTelemetry.PrometheusBridge().Enabled()
envCfg.TelemetryPrometheusBridgePrefixes = m.cfgTelemetry.PrometheusBridge().Prefixes()
}
Expand Down
2 changes: 2 additions & 0 deletions plugins/loop_registry_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@ func (m mockCfgTelemetry) MetricViewsDenyAttributes() []string {
return []string{"event_id"}
}
func (m mockCfgTelemetry) MetricCardinalityLimit() int { return 100000 }
func (m mockCfgTelemetry) MetricExportBatchSize() int { return 0 }

func (m mockCfgTelemetry) PrometheusBridge() coreconfig.PrometheusBridge {
return mockPrometheusBridge{}
Expand Down Expand Up @@ -312,6 +313,7 @@ func TestLoopRegistry_Register(t *testing.T) {
require.Equal(t, []string{"event_id"}, envCfg.TelemetryMetricViewsDenyAttributes)
require.NotNil(t, envCfg.TelemetryMetricCardinalityLimit)
require.Equal(t, 100000, *envCfg.TelemetryMetricCardinalityLimit)
require.Equal(t, 0, envCfg.TelemetryMetricExportBatchSize)

require.Equal(t, "example.com/chip-ingress", envCfg.ChipIngressEndpoint)
require.False(t, envCfg.ChipIngressBatchEmitterEnabled)
Expand Down
1 change: 1 addition & 0 deletions testdata/scripts/config/merge_raw_configs.txtar
Original file line number Diff line number Diff line change
Expand Up @@ -505,6 +505,7 @@ LogExportInterval = '1s'
LogMaxQueueSize = 2048
MetricViewsDenyAttributes = ['event_id']
MetricCardinalityLimit = 100000
MetricExportBatchSize = 0

[Telemetry.PrometheusBridge]
Enabled = false
Expand Down
1 change: 1 addition & 0 deletions testdata/scripts/node/validate/default.txtar
Original file line number Diff line number Diff line change
Expand Up @@ -370,6 +370,7 @@ LogExportInterval = '1s'
LogMaxQueueSize = 2048
MetricViewsDenyAttributes = ['event_id']
MetricCardinalityLimit = 100000
MetricExportBatchSize = 0

[Telemetry.PrometheusBridge]
Enabled = false
Expand Down
1 change: 1 addition & 0 deletions testdata/scripts/node/validate/defaults-override.txtar
Original file line number Diff line number Diff line change
Expand Up @@ -431,6 +431,7 @@ LogExportInterval = '1s'
LogMaxQueueSize = 2048
MetricViewsDenyAttributes = ['event_id']
MetricCardinalityLimit = 100000
MetricExportBatchSize = 0

[Telemetry.PrometheusBridge]
Enabled = false
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -414,6 +414,7 @@ LogExportInterval = '1s'
LogMaxQueueSize = 2048
MetricViewsDenyAttributes = ['event_id']
MetricCardinalityLimit = 100000
MetricExportBatchSize = 0

[Telemetry.PrometheusBridge]
Enabled = false
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -414,6 +414,7 @@ LogExportInterval = '1s'
LogMaxQueueSize = 2048
MetricViewsDenyAttributes = ['event_id']
MetricCardinalityLimit = 100000
MetricExportBatchSize = 0

[Telemetry.PrometheusBridge]
Enabled = false
Expand Down
1 change: 1 addition & 0 deletions testdata/scripts/node/validate/disk-based-logging.txtar
Original file line number Diff line number Diff line change
Expand Up @@ -414,6 +414,7 @@ LogExportInterval = '1s'
LogMaxQueueSize = 2048
MetricViewsDenyAttributes = ['event_id']
MetricCardinalityLimit = 100000
MetricExportBatchSize = 0

[Telemetry.PrometheusBridge]
Enabled = false
Expand Down
1 change: 1 addition & 0 deletions testdata/scripts/node/validate/fallback-override.txtar
Original file line number Diff line number Diff line change
Expand Up @@ -513,6 +513,7 @@ LogExportInterval = '1s'
LogMaxQueueSize = 2048
MetricViewsDenyAttributes = ['event_id']
MetricCardinalityLimit = 100000
MetricExportBatchSize = 0

[Telemetry.PrometheusBridge]
Enabled = false
Expand Down
1 change: 1 addition & 0 deletions testdata/scripts/node/validate/invalid-ocr-p2p.txtar
Original file line number Diff line number Diff line change
Expand Up @@ -399,6 +399,7 @@ LogExportInterval = '1s'
LogMaxQueueSize = 2048
MetricViewsDenyAttributes = ['event_id']
MetricCardinalityLimit = 100000
MetricExportBatchSize = 0

[Telemetry.PrometheusBridge]
Enabled = false
Expand Down
1 change: 1 addition & 0 deletions testdata/scripts/node/validate/invalid.txtar
Original file line number Diff line number Diff line change
Expand Up @@ -410,6 +410,7 @@ LogExportInterval = '1s'
LogMaxQueueSize = 2048
MetricViewsDenyAttributes = ['event_id']
MetricCardinalityLimit = 100000
MetricExportBatchSize = 0

[Telemetry.PrometheusBridge]
Enabled = false
Expand Down
1 change: 1 addition & 0 deletions testdata/scripts/node/validate/valid.txtar
Original file line number Diff line number Diff line change
Expand Up @@ -411,6 +411,7 @@ LogExportInterval = '1s'
LogMaxQueueSize = 2048
MetricViewsDenyAttributes = ['event_id']
MetricCardinalityLimit = 100000
MetricExportBatchSize = 0

[Telemetry.PrometheusBridge]
Enabled = false
Expand Down
1 change: 1 addition & 0 deletions testdata/scripts/node/validate/warnings.txtar
Original file line number Diff line number Diff line change
Expand Up @@ -393,6 +393,7 @@ LogExportInterval = '1s'
LogMaxQueueSize = 2048
MetricViewsDenyAttributes = ['event_id']
MetricCardinalityLimit = 100000
MetricExportBatchSize = 0

[Telemetry.PrometheusBridge]
Enabled = false
Expand Down
Loading