From 52bf9f362884f481a6dcc955be4fb1267458def8 Mon Sep 17 00:00:00 2001 From: James Sumners Date: Thu, 16 Nov 2023 10:49:26 -0500 Subject: [PATCH] feat: Add ai_monitoring configuration (#1873) --- documentation/feature-flags.md | 6 ------ lib/config/default.js | 14 ++++++++++++++ lib/config/hsm.js | 3 +++ lib/feature_flags.js | 1 - test/unit/config/config-defaults.test.js | 5 +++++ test/unit/config/config-security.test.js | 13 +++++++++++++ test/unit/feature_flag.test.js | 3 +-- 7 files changed, 36 insertions(+), 9 deletions(-) diff --git a/documentation/feature-flags.md b/documentation/feature-flags.md index af69837b78..9495700b40 100644 --- a/documentation/feature-flags.md +++ b/documentation/feature-flags.md @@ -8,12 +8,6 @@ Any prerelease flags can be enabled or disabled in your agent config by adding a ## Current prerelease feature flags -#### openai_instrumentation -* Enabled by default: `false` -* Configuration: `{ feature_flag: { openai_instrumentation: true|false }}` -* Environment Variable: `NEW_RELIC_FEATURE_FLAG_OPENAI_INSTRUMENTATION` -* Description: Enables instrumenting the `openai` module. - #### promise_segments * Enabled by default: `false` * Configuration: `{ feature_flag: { promise_segments: true|false }}` diff --git a/lib/config/default.js b/lib/config/default.js index 45039f8adc..6cdd3bc30f 100644 --- a/lib/config/default.js +++ b/lib/config/default.js @@ -1345,6 +1345,20 @@ defaultConfig.definition = () => ({ formatter: boolean, default: false } + }, + + /** + * When enabled, instrumentation of supported AI libraries will be in + * effect. + */ + ai_monitoring: { + /** + * Toggles the generation of AI monitoring events by the agent. + */ + enabled: { + formatter: boolean, + default: false + } } }) diff --git a/lib/config/hsm.js b/lib/config/hsm.js index 048be54a28..f28a19a0a5 100644 --- a/lib/config/hsm.js +++ b/lib/config/hsm.js @@ -55,6 +55,9 @@ const HIGH_SECURITY_SETTINGS = { forwarding: { enabled: false } + }, + ai_monitoring: { + enabled: false } } diff --git a/lib/feature_flags.js b/lib/feature_flags.js index 0df80ba4cf..18855749ef 100644 --- a/lib/feature_flags.js +++ b/lib/feature_flags.js @@ -8,7 +8,6 @@ // unreleased flags gating an active feature exports.prerelease = { express5: false, - openai_instrumentation: false, promise_segments: false, reverse_naming_rules: false, undici_async_tracking: true, diff --git a/test/unit/config/config-defaults.test.js b/test/unit/config/config-defaults.test.js index 74dcacdae8..df9e021141 100644 --- a/test/unit/config/config-defaults.test.js +++ b/test/unit/config/config-defaults.test.js @@ -308,4 +308,9 @@ tap.test('with default properties', (t) => { t.equal(configuration.worker_threads.enabled, false) t.end() }) + + t.test('should default ai_monitoring.enabled to false', (t) => { + t.equal(configuration.ai_monitoring.enabled, false) + t.end() + }) }) diff --git a/test/unit/config/config-security.test.js b/test/unit/config/config-security.test.js index 55ce83d52f..a24c0e7114 100644 --- a/test/unit/config/config-security.test.js +++ b/test/unit/config/config-security.test.js @@ -226,3 +226,16 @@ tap.test('#applyLasp', (t) => { t.end() }) }) + +tap.test('ai_monitoring should not be enabled in HSM', (t) => { + const config = Config.initialize({ + ai_monitoring: { + enabled: true + }, + high_security: 'true' + }) + + t.equal(config.ai_monitoring.enabled, false) + + t.end() +}) diff --git a/test/unit/feature_flag.test.js b/test/unit/feature_flag.test.js index 9faabb0d6c..21caa09e79 100644 --- a/test/unit/feature_flag.test.js +++ b/test/unit/feature_flag.test.js @@ -34,8 +34,7 @@ const used = [ 'certificate_bundle', 'unresolved_promise_cleanup', 'undici_instrumentation', - 'undici_async_tracking', - 'openai_instrumentation' + 'undici_async_tracking' ] tap.test('feature flags', (t) => {