diff --git a/v3/newrelic/config.go b/v3/newrelic/config.go index 5d79bf8fa..a74add79c 100644 --- a/v3/newrelic/config.go +++ b/v3/newrelic/config.go @@ -235,6 +235,15 @@ type Config struct { DynoNamePrefixesToShorten []string } + // AIMonitoring controls the behavior of AI monitoring features. + AIMonitoring struct { + Enabled bool + // Indicates whether streams will be instrumented + Streaming struct { + Enabled bool + } + } + // CrossApplicationTracer controls behavior relating to cross application // tracing (CAT). In the case where CrossApplicationTracer and // DistributedTracer are both enabled, DistributedTracer takes precedence. @@ -666,7 +675,8 @@ func defaultConfig() Config { c.Heroku.UseDynoNames = true c.Heroku.DynoNamePrefixesToShorten = []string{"scheduler", "run"} - + c.AIMonitoring.Enabled = false + c.AIMonitoring.Streaming.Enabled = true c.InfiniteTracing.TraceObserver.Port = 443 c.InfiniteTracing.SpanEvents.QueueSize = 10000 diff --git a/v3/newrelic/config_options.go b/v3/newrelic/config_options.go index 5b9261e17..2ccc65fe1 100644 --- a/v3/newrelic/config_options.go +++ b/v3/newrelic/config_options.go @@ -236,6 +236,16 @@ func ConfigAppLogDecoratingEnabled(enabled bool) ConfigOption { } } +func ConfigAIMonitoringEnabled(enabled bool) ConfigOption { + return func(cfg *Config) { + if enabled && !cfg.HighSecurity { + cfg.AIMonitoring.Enabled = true + } else { + cfg.AIMonitoring.Enabled = false + } + } +} + // ConfigAppLogMetricsEnabled enables or disables the collection of metrics // data for logs seen by an instrumented logging framework // default: true diff --git a/v3/newrelic/config_test.go b/v3/newrelic/config_test.go index 37eb88159..10b64dfb1 100644 --- a/v3/newrelic/config_test.go +++ b/v3/newrelic/config_test.go @@ -130,6 +130,12 @@ func TestCopyConfigReferenceFieldsPresent(t *testing.T) { "agent_version":"0.2.2", "host":"my-hostname", "settings":{ + "AIMonitoring": { + "Enabled": false, + "Streaming": { + "Enabled": true + } + }, "AppName":"my appname", "ApplicationLogging": { "Enabled": true, @@ -326,6 +332,12 @@ func TestCopyConfigReferenceFieldsAbsent(t *testing.T) { "agent_version":"0.2.2", "host":"my-hostname", "settings":{ + "AIMonitoring": { + "Enabled": false, + "Streaming": { + "Enabled": true + } + }, "AppName":"my appname", "ApplicationLogging": { "Enabled": true,