Skip to content

Commit

Permalink
Fix issues with Beyla component defaults (#564)
Browse files Browse the repository at this point in the history
  • Loading branch information
marctc authored Apr 12, 2024
1 parent e8907e7 commit f4b78ef
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 5 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@ Main (unreleased)
- In `prometheus.exporter.kafka`, the interpolation table used to compute estimated lag metrics is now pruned
on `metadata_refresh_interval` instead of `prune_interval_seconds`. (@wildum)

### Bugfixes

- Fixed issue with defaults for Beyla component not being applied correctly. (marctc)

v1.0.0 (2024-04-09)
-------------------

Expand Down
8 changes: 4 additions & 4 deletions internal/component/beyla/ebpf/beyla_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,11 +62,11 @@ func (args Routes) Convert() *transform.RoutesConfig {
}

func (args Attributes) Convert() beyla.Attributes {
return beyla.Attributes{
Kubernetes: transform.KubernetesDecorator{
Enable: transform.KubeEnableFlag(args.Kubernetes.Enable),
},
attrs := beyla.DefaultConfig.Attributes
if args.Kubernetes.Enable != "" {
attrs.Kubernetes.Enable = transform.KubeEnableFlag(args.Kubernetes.Enable)
}
return attrs
}

func (args Discovery) Convert() (services.DiscoveryConfig, error) {
Expand Down
23 changes: 22 additions & 1 deletion internal/component/beyla/ebpf/beyla_linux_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ package beyla
import (
"errors"
"testing"
"time"

"github.com/grafana/alloy/syntax"
"github.com/grafana/beyla/pkg/beyla"
Expand Down Expand Up @@ -58,6 +59,24 @@ func TestArguments_UnmarshalSyntax(t *testing.T) {
require.Equal(t, "default", cfg.Discovery.Services[0].Namespace)
}

func TestArguments_ConvertDefaultConfig(t *testing.T) {
args := Arguments{}
cfg, err := args.Convert()
require.NoError(t, err)
require.Equal(t, cfg.ChannelBufferLen, beyla.DefaultConfig.ChannelBufferLen)
require.Equal(t, cfg.LogLevel, beyla.DefaultConfig.LogLevel)
require.Equal(t, cfg.EBPF, beyla.DefaultConfig.EBPF)
require.Equal(t, cfg.NetworkFlows, beyla.DefaultConfig.NetworkFlows)
require.Equal(t, cfg.Grafana, beyla.DefaultConfig.Grafana)
require.Equal(t, cfg.Attributes, beyla.DefaultConfig.Attributes)
require.Equal(t, cfg.Routes, beyla.DefaultConfig.Routes)
require.Equal(t, cfg.Metrics, beyla.DefaultConfig.Metrics)
require.Equal(t, cfg.Traces, beyla.DefaultConfig.Traces)
require.Equal(t, cfg.Prometheus, beyla.DefaultConfig.Prometheus)
require.Equal(t, cfg.InternalMetrics, beyla.DefaultConfig.InternalMetrics)
require.Equal(t, cfg.NetworkFlows, beyla.DefaultConfig.NetworkFlows)
}

func TestArguments_UnmarshalInvalidSyntax(t *testing.T) {
var tests = []struct {
testname string
Expand Down Expand Up @@ -117,8 +136,10 @@ func TestConvert_Attribute(t *testing.T) {
}

expectedConfig := beyla.Attributes{
InstanceID: beyla.DefaultConfig.Attributes.InstanceID,
Kubernetes: transform.KubernetesDecorator{
Enable: transform.KubeEnableFlag(args.Kubernetes.Enable),
Enable: transform.KubeEnableFlag(args.Kubernetes.Enable),
InformersSyncTimeout: 30 * time.Second,
},
}

Expand Down

0 comments on commit f4b78ef

Please sign in to comment.