Skip to content

Commit

Permalink
feat: Add ai_monitoring configuration (#1873)
Browse files Browse the repository at this point in the history
  • Loading branch information
jsumners-nr committed Nov 16, 2023
1 parent 1c62321 commit 52bf9f3
Show file tree
Hide file tree
Showing 7 changed files with 36 additions and 9 deletions.
6 changes: 0 additions & 6 deletions documentation/feature-flags.md
Expand Up @@ -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 }}`
Expand Down
14 changes: 14 additions & 0 deletions lib/config/default.js
Expand Up @@ -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
}
}
})

Expand Down
3 changes: 3 additions & 0 deletions lib/config/hsm.js
Expand Up @@ -55,6 +55,9 @@ const HIGH_SECURITY_SETTINGS = {
forwarding: {
enabled: false
}
},
ai_monitoring: {
enabled: false
}
}

Expand Down
1 change: 0 additions & 1 deletion lib/feature_flags.js
Expand Up @@ -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,
Expand Down
5 changes: 5 additions & 0 deletions test/unit/config/config-defaults.test.js
Expand Up @@ -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()
})
})
13 changes: 13 additions & 0 deletions test/unit/config/config-security.test.js
Expand Up @@ -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()
})
3 changes: 1 addition & 2 deletions test/unit/feature_flag.test.js
Expand Up @@ -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) => {
Expand Down

0 comments on commit 52bf9f3

Please sign in to comment.