Skip to content

Commit 8211674

Browse files
committed
feat: add fleet agent cfg deprecation notice
1 parent 069f748 commit 8211674

File tree

3 files changed

+29
-0
lines changed

3 files changed

+29
-0
lines changed

internal/beater/beater.go

+1
Original file line numberDiff line numberDiff line change
@@ -410,6 +410,7 @@ func (s *Runner) Run(ctx context.Context) error {
410410
kibanaClient,
411411
newElasticsearchClient,
412412
tracer,
413+
s.logger,
413414
)
414415
if err != nil {
415416
return err

internal/beater/beater_test.go

+24
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,8 @@ import (
3737
"github.com/stretchr/testify/require"
3838
"go.elastic.co/apm/v2/apmtest"
3939
"go.uber.org/zap"
40+
"go.uber.org/zap/zapcore"
41+
"go.uber.org/zap/zaptest/observer"
4042

4143
"github.com/elastic/apm-server/internal/beater/config"
4244
"github.com/elastic/apm-server/internal/elasticsearch"
@@ -243,6 +245,28 @@ func TestRunnerNewDocappenderConfig(t *testing.T) {
243245
}
244246
}
245247

248+
func TestAgentConfigFetcherDeprecation(t *testing.T) {
249+
core, observed := observer.New(zapcore.DebugLevel)
250+
logger := logp.NewLogger("bo", zap.WrapCore(func(in zapcore.Core) zapcore.Core {
251+
return zapcore.NewTee(in, core)
252+
}))
253+
254+
_, _, err := newAgentConfigFetcher(context.Background(), &config.Config{
255+
FleetAgentConfigs: []config.FleetAgentConfig{
256+
{
257+
AgentName: "foo",
258+
},
259+
},
260+
}, nil, func(c *elasticsearch.Config) (*elasticsearch.Client, error) { return nil, nil }, nil, logger)
261+
require.NoError(t, err)
262+
263+
all := observed.All()
264+
assert.Len(t, all, 1)
265+
record := all[0]
266+
assert.Equal(t, zapcore.WarnLevel, record.Level, record.Message)
267+
assert.Equal(t, agentcfgDeprecationNotice, record.Message)
268+
}
269+
246270
func TestNewInstrumentation(t *testing.T) {
247271
var auth string
248272
labels := make(chan map[string]string, 1)

internal/beater/server.go

+4
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,8 @@ import (
4949

5050
var (
5151
agentcfgMonitoringRegistry = monitoring.Default.NewRegistry("apm-server.agentcfg")
52+
53+
agentcfgDeprecationNotice = "deprecation notice: support for manually passing fleet agent configs will be remove in an upcoming version"
5254
)
5355

5456
// WrapServerFunc is a function for injecting behaviour into ServerParams
@@ -240,6 +242,7 @@ func newAgentConfigFetcher(
240242
kibanaClient *kibana.Client,
241243
newElasticsearchClient func(*elasticsearch.Config) (*elasticsearch.Client, error),
242244
tracer *apm.Tracer,
245+
logger *logp.Logger,
243246
) (agentcfg.Fetcher, func(context.Context) error, error) {
244247
// Always use ElasticsearchFetcher, and as a fallback, use:
245248
// 1. no fallback if Elasticsearch is explicitly configured
@@ -252,6 +255,7 @@ func newAgentConfigFetcher(
252255
case cfg.AgentConfig.ESOverrideConfigured:
253256
// Disable fallback because agent config Elasticsearch is explicitly configured.
254257
case cfg.FleetAgentConfigs != nil:
258+
logger.Warn(agentcfgDeprecationNotice)
255259
agentConfigurations := agentcfg.ConvertAgentConfigs(cfg.FleetAgentConfigs)
256260
fallbackFetcher = agentcfg.NewDirectFetcher(agentConfigurations)
257261
case kibanaClient != nil:

0 commit comments

Comments
 (0)