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

feat: add fleet agent cfg deprecation notice #15260

Merged
merged 2 commits into from
Jan 16, 2025
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
1 change: 1 addition & 0 deletions internal/beater/beater.go
Original file line number Diff line number Diff line change
Expand Up @@ -410,6 +410,7 @@ func (s *Runner) Run(ctx context.Context) error {
kibanaClient,
newElasticsearchClient,
tracer,
s.logger,
)
if err != nil {
return err
Expand Down
24 changes: 24 additions & 0 deletions internal/beater/beater_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ import (
"github.com/stretchr/testify/require"
"go.elastic.co/apm/v2/apmtest"
"go.uber.org/zap"
"go.uber.org/zap/zapcore"
"go.uber.org/zap/zaptest/observer"

"github.com/elastic/apm-server/internal/beater/config"
"github.com/elastic/apm-server/internal/elasticsearch"
Expand Down Expand Up @@ -243,6 +245,28 @@ func TestRunnerNewDocappenderConfig(t *testing.T) {
}
}

func TestAgentConfigFetcherDeprecation(t *testing.T) {
core, observed := observer.New(zapcore.DebugLevel)
logger := logp.NewLogger("bo", zap.WrapCore(func(in zapcore.Core) zapcore.Core {
return zapcore.NewTee(in, core)
}))

_, _, err := newAgentConfigFetcher(context.Background(), &config.Config{
FleetAgentConfigs: []config.FleetAgentConfig{
{
AgentName: "foo",
},
},
}, nil, func(c *elasticsearch.Config) (*elasticsearch.Client, error) { return nil, nil }, nil, logger)
require.NoError(t, err)

all := observed.All()
assert.Len(t, all, 1)
record := all[0]
assert.Equal(t, zapcore.WarnLevel, record.Level, record.Message)
assert.Equal(t, agentcfgDeprecationNotice, record.Message)
}

func TestNewInstrumentation(t *testing.T) {
var auth string
labels := make(chan map[string]string, 1)
Expand Down
4 changes: 4 additions & 0 deletions internal/beater/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ import (

var (
agentcfgMonitoringRegistry = monitoring.Default.NewRegistry("apm-server.agentcfg")

agentcfgDeprecationNotice = "deprecation notice: support for passing fleet agent configs will be removed in an upcoming version"
)

// WrapServerFunc is a function for injecting behaviour into ServerParams
Expand Down Expand Up @@ -240,6 +242,7 @@ func newAgentConfigFetcher(
kibanaClient *kibana.Client,
newElasticsearchClient func(*elasticsearch.Config) (*elasticsearch.Client, error),
tracer *apm.Tracer,
logger *logp.Logger,
) (agentcfg.Fetcher, func(context.Context) error, error) {
// Always use ElasticsearchFetcher, and as a fallback, use:
// 1. no fallback if Elasticsearch is explicitly configured
Expand All @@ -252,6 +255,7 @@ func newAgentConfigFetcher(
case cfg.AgentConfig.ESOverrideConfigured:
// Disable fallback because agent config Elasticsearch is explicitly configured.
case cfg.FleetAgentConfigs != nil:
logger.Warn(agentcfgDeprecationNotice)
agentConfigurations := agentcfg.ConvertAgentConfigs(cfg.FleetAgentConfigs)
fallbackFetcher = agentcfg.NewDirectFetcher(agentConfigurations)
case kibanaClient != nil:
Expand Down
Loading