Skip to content

Commit bd04238

Browse files
committed
add Prometheus bridge to otel
1 parent c6fffd5 commit bd04238

36 files changed

Lines changed: 204 additions & 46 deletions

.changeset/happy-books-boil.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"chainlink": minor
3+
---
4+
5+
Add Telemetry.PrometheusBridge to TOML config to support forwarding Prometheus metrics through Open Telemetry

core/config/docs/core.toml

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -872,7 +872,6 @@ ChipIngressEndpoint = '' # Default
872872
ChipIngressInsecureConnection = false # Default
873873
# DurableEmitterEnabled enables persisting outbound CHIP events to Postgres for at-least-once delivery.
874874
DurableEmitterEnabled = false # Default
875-
876875
# HeartbeatInterval is the interval at which a the application heartbeat is sent to telemetry backends.
877876
HeartbeatInterval = '1s' # Default
878877
# LogLevel sets the log level for telemetry streaming (debug, info, warn, error, crit, panic, fatal)
@@ -895,6 +894,14 @@ LogMaxQueueSize = 2048 # Default
895894
# foo is an example resource attribute
896895
foo = "bar" # Example
897896

897+
# The Prometheus bridge automatically forwards metrics through open telemetry.
898+
[Telemetry.PrometheusBridge]
899+
# Enabled enables the Promtheus bridge.
900+
Enabled = false # Default
901+
# Prefixes is a set of filters to restrict which prometheus metrics are forwarded based on prefix matching.
902+
# By default, we only forward the go runtime metrics. Empty means forward everything.
903+
Prefixes = ["go_"] # Default
904+
898905
[CRE.Streams]
899906
# WsURL is the websockets url for the streams sdk config
900907
WsURL = "streams.url" # Example

core/config/telemetry_config.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,4 +27,10 @@ type Telemetry interface {
2727
LogExportMaxBatchSize() int
2828
LogExportInterval() time.Duration
2929
LogMaxQueueSize() int
30+
PrometheusBridge() PrometheusBridge
31+
}
32+
33+
type PrometheusBridge interface {
34+
Enabled() bool
35+
Prefixes() []string
3036
}

core/config/toml/types.go

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2868,6 +2868,8 @@ type Telemetry struct {
28682868
LogExportMaxBatchSize *int
28692869
LogExportInterval *commonconfig.Duration
28702870
LogMaxQueueSize *int
2871+
2872+
PrometheusBridge PrometheusBridge `toml:",omitempty"`
28712873
}
28722874

28732875
func (b *Telemetry) setFrom(f *Telemetry) {
@@ -2931,6 +2933,7 @@ func (b *Telemetry) setFrom(f *Telemetry) {
29312933
if v := f.LogMaxQueueSize; v != nil {
29322934
b.LogMaxQueueSize = v
29332935
}
2936+
b.PrometheusBridge.setFrom(&f.PrometheusBridge)
29342937
}
29352938

29362939
func (b *Telemetry) ValidateConfig() (err error) {
@@ -2952,6 +2955,20 @@ func (b *Telemetry) ValidateConfig() (err error) {
29522955
return err
29532956
}
29542957

2958+
type PrometheusBridge struct {
2959+
Enabled *bool
2960+
Prefixes []string
2961+
}
2962+
2963+
func (b *PrometheusBridge) setFrom(f *PrometheusBridge) {
2964+
if v := f.Enabled; v != nil {
2965+
b.Enabled = v
2966+
}
2967+
if v := f.Prefixes; v != nil {
2968+
b.Prefixes = v
2969+
}
2970+
}
2971+
29552972
var hostnameRegex = regexp.MustCompile(`^[a-zA-Z0-9-]+(\.[a-zA-Z0-9-]+)*$`)
29562973

29572974
// Validates uri is valid external or local URI

core/scripts/go.mod

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ require (
4343
github.com/smartcontractkit/chain-selectors v1.0.100
4444
github.com/smartcontractkit/chainlink-automation v0.8.1
4545
github.com/smartcontractkit/chainlink-ccip/chains/evm v0.0.0-20260506144252-c100eabfda74
46-
github.com/smartcontractkit/chainlink-common v0.11.2-0.20260518100439-9564f35fd264
46+
github.com/smartcontractkit/chainlink-common v0.11.2-0.20260520224710-ed772131f8f0
4747
github.com/smartcontractkit/chainlink-common/keystore v1.1.0
4848
github.com/smartcontractkit/chainlink-data-streams v0.1.15-0.20260520173048-0333bc7b082f
4949
github.com/smartcontractkit/chainlink-deployments-framework v0.105.0
@@ -480,7 +480,7 @@ require (
480480
github.com/smartcontractkit/chainlink-ccip/chains/solana v0.0.0-20260506144252-c100eabfda74 // indirect
481481
github.com/smartcontractkit/chainlink-ccip/chains/solana/gobindings v0.0.0-20260511195239-0f6e1b177fc7 // indirect
482482
github.com/smartcontractkit/chainlink-ccv v0.0.2-0.20260428133800-3b1484e8b1fd // indirect
483-
github.com/smartcontractkit/chainlink-common/pkg/chipingress v0.0.11-0.20260511200925-b94130438417 // indirect
483+
github.com/smartcontractkit/chainlink-common/pkg/chipingress v0.0.11-0.20260518142424-bacfb6ba4146 // indirect
484484
github.com/smartcontractkit/chainlink-evm/contracts/cre/gobindings v0.0.0-20260403151002-2c91155b5501 // indirect
485485
github.com/smartcontractkit/chainlink-feeds v0.1.2-0.20250227211209-7cd000095135 // indirect
486486
github.com/smartcontractkit/chainlink-framework/capabilities v0.0.0-20260423135514-5b1a7565a99c // indirect
@@ -566,6 +566,7 @@ require (
566566
go.etcd.io/bbolt v1.4.3 // indirect
567567
go.mongodb.org/mongo-driver v1.17.9 // indirect
568568
go.opentelemetry.io/auto/sdk v1.2.1 // indirect
569+
go.opentelemetry.io/contrib/bridges/prometheus v0.68.0 // indirect
569570
go.opentelemetry.io/contrib/instrumentation/github.com/gin-gonic/gin/otelgin v0.49.0 // indirect
570571
go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.68.0 // indirect
571572
go.opentelemetry.io/contrib/instrumentation/net/http/httptrace/otelhttptrace v0.67.0 // indirect

core/scripts/go.sum

Lines changed: 6 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

core/services/chainlink/config_telemetry.go

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -174,3 +174,19 @@ func (b *telemetryConfig) LogMaxQueueSize() int {
174174
}
175175
return *b.s.LogMaxQueueSize
176176
}
177+
178+
func (b *telemetryConfig) PrometheusBridge() config.PrometheusBridge {
179+
return &prometheusBridgeConfig{b.s.PrometheusBridge}
180+
}
181+
182+
type prometheusBridgeConfig struct {
183+
s toml.PrometheusBridge
184+
}
185+
186+
func (p *prometheusBridgeConfig) Enabled() bool {
187+
return *p.s.Enabled
188+
}
189+
190+
func (p *prometheusBridgeConfig) Prefixes() []string {
191+
return p.s.Prefixes
192+
}

core/services/chainlink/testdata/config-full.toml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,10 @@ ChainID = '1'
5151
URL = 'prom.test'
5252
ServerPubKey = 'test-pub-key'
5353

54+
[Telemetry.PrometheusBridge]
55+
Enabled = true
56+
Prefixes = ["ocr_"]
57+
5458
[AuditLogger]
5559
Enabled = true
5660
ForwardToUrl = 'http://localhost:9898'

core/web/resolver/testdata/config-empty-effective.toml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -357,6 +357,10 @@ LogExportMaxBatchSize = 512
357357
LogExportInterval = '1s'
358358
LogMaxQueueSize = 2048
359359

360+
[Telemetry.PrometheusBridge]
361+
Enabled = false
362+
Prefixes = ["go_"]
363+
360364
[Workflows]
361365
[Workflows.Limits]
362366
Global = 200

core/web/resolver/testdata/config-multi-chain-effective.toml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -357,6 +357,10 @@ LogExportMaxBatchSize = 512
357357
LogExportInterval = '1s'
358358
LogMaxQueueSize = 2048
359359

360+
[Telemetry.PrometheusBridge]
361+
Enabled = false
362+
Prefixes = ["go_"]
363+
360364
[Workflows]
361365
[Workflows.Limits]
362366
Global = 200

0 commit comments

Comments
 (0)