Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

INFOPLAT-1468 Enable batching for beholder emitter #15173

Merged
merged 10 commits into from
Nov 11, 2024
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
2 changes: 2 additions & 0 deletions core/cmd/shell.go
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,8 @@ func initGlobals(cfgProm config.Prometheus, cfgTracing config.Tracing, cfgTeleme
OtelExporterGRPCEndpoint: cfgTelemetry.OtelExporterGRPCEndpoint(),
ResourceAttributes: attributes,
TraceSampleRatio: cfgTelemetry.TraceSampleRatio(),
EmitterBatchProcessor: cfgTelemetry.EmitterBatchProcessor(),
EmitterExportTimeout: cfgTelemetry.EmitterExportTimeout(),
}
if tracingCfg.Enabled {
clientCfg.TraceSpanExporter, err = tracingCfg.NewSpanExporter()
Expand Down
4 changes: 4 additions & 0 deletions core/config/docs/core.toml
Original file line number Diff line number Diff line change
Expand Up @@ -706,6 +706,10 @@ CACertFile = 'cert-file' # Example
InsecureConnection = false # Default
# TraceSampleRatio is the rate at which to sample traces. Must be between 0 and 1.
TraceSampleRatio = 0.01 # Default
# Enables batching for telemetry events
EmitterBatchProcessor = true # Default
# Sets export timeout for telemetry events
EmitterExportTimeout = "1s" # Default

# ResourceAttributes are global metadata to include with all telemetry.
[Telemetry.ResourceAttributes]
Expand Down
4 changes: 4 additions & 0 deletions core/config/telemetry_config.go
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
package config

import "time"

type Telemetry interface {
Enabled() bool
InsecureConnection() bool
CACertFile() string
OtelExporterGRPCEndpoint() string
ResourceAttributes() map[string]string
TraceSampleRatio() float64
EmitterBatchProcessor() bool
EmitterExportTimeout() time.Duration
}
20 changes: 14 additions & 6 deletions core/config/toml/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -1657,12 +1657,14 @@ func (t *Tracing) ValidateConfig() (err error) {
}

type Telemetry struct {
Enabled *bool
CACertFile *string
Endpoint *string
InsecureConnection *bool
ResourceAttributes map[string]string `toml:",omitempty"`
TraceSampleRatio *float64
Enabled *bool
CACertFile *string
Endpoint *string
InsecureConnection *bool
ResourceAttributes map[string]string `toml:",omitempty"`
TraceSampleRatio *float64
EmitterBatchProcessor *bool
EmitterExportTimeout *commonconfig.Duration
}

func (b *Telemetry) setFrom(f *Telemetry) {
Expand All @@ -1684,6 +1686,12 @@ func (b *Telemetry) setFrom(f *Telemetry) {
if v := f.TraceSampleRatio; v != nil {
b.TraceSampleRatio = v
}
if v := f.EmitterBatchProcessor; v != nil {
b.EmitterBatchProcessor = v
}
if v := f.EmitterExportTimeout; v != nil {
b.EmitterExportTimeout = v
}
}

func (b *Telemetry) ValidateConfig() (err error) {
Expand Down
16 changes: 16 additions & 0 deletions core/services/chainlink/config_telemetry.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package chainlink

import (
"time"

"github.com/smartcontractkit/chainlink/v2/core/config/toml"
)

Expand Down Expand Up @@ -41,3 +43,17 @@ func (b *telemetryConfig) TraceSampleRatio() float64 {
}
return *b.s.TraceSampleRatio
}

func (b *telemetryConfig) EmitterBatchProcessor() bool {
if b.s.EmitterBatchProcessor == nil {
return false
pkcll marked this conversation as resolved.
Show resolved Hide resolved
}
return *b.s.EmitterBatchProcessor
}

func (b *telemetryConfig) EmitterExportTimeout() time.Duration {
if b.s.EmitterExportTimeout == nil {
return 0
pkcll marked this conversation as resolved.
Show resolved Hide resolved
}
return b.s.EmitterExportTimeout.Duration()
}
5 changes: 5 additions & 0 deletions plugins/loop_registry_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package plugins

import (
"testing"
"time"

"github.com/stretchr/testify/require"

Expand Down Expand Up @@ -55,6 +56,10 @@ func (m mockCfgTelemetry) ResourceAttributes() map[string]string {

func (m mockCfgTelemetry) TraceSampleRatio() float64 { return 0.42 }

func (m mockCfgTelemetry) EmitterBatchProcessor() bool { return false }

func (m mockCfgTelemetry) EmitterExportTimeout() time.Duration { return 0 }

func TestLoopRegistry_Register(t *testing.T) {
mockCfgTracing := &mockCfgTracing{}
mockCfgTelemetry := &mockCfgTelemetry{}
Expand Down
Loading