Skip to content

Commit

Permalink
feat: Removed undici feature flag. This will now instrument undici by…
Browse files Browse the repository at this point in the history
… default (#1772)
  • Loading branch information
bizob2828 committed Sep 1, 2023
1 parent 6ecde97 commit 683b254
Show file tree
Hide file tree
Showing 5 changed files with 4 additions and 37 deletions.
6 changes: 0 additions & 6 deletions documentation/feature-flags.md
Expand Up @@ -20,12 +20,6 @@ Any prerelease flags can be enabled or disabled in your agent config by adding a
* Environment Variable: `NEW_RELIC_FEATURE_FLAG_REVERSE_NAMING_RULES`
* Description: Naming rules are in forward order by default.

#### undici_instrumentation
* Enabled by default: `false`
* Configuration: `{ feature_flag: { undici_instrumentation: true|false }}`
* Environment Variable: `NEW_RELIC_FEATURE_FLAG_UNDICI_INSTRUMENTATION`
* Description: Enable experimental instrumentation for the [undici](https://github.com/nodejs/undici) http client. Note that support for undici client is Node.js 16.x minimum, and requires at minimum [v4.7.0+](https://github.com/nodejs/undici/releases/tag/v4.7.0) of the undici client.

#### undici_async_tracking
* Enabled by default: `true`
* Configuration: `{ feature_flag: { undici_async_tracking: true|false }}`
Expand Down
4 changes: 2 additions & 2 deletions lib/feature_flags.js
Expand Up @@ -10,7 +10,6 @@ exports.prerelease = {
express5: false,
promise_segments: false,
reverse_naming_rules: false,
undici_instrumentation: false,
undici_async_tracking: true,
unresolved_promise_cleanup: true,
legacy_context_manager: false
Expand All @@ -33,7 +32,8 @@ exports.released = [
'fastify_instrumentation',
'await_support',
'certificate_bundle',
'async_local_context'
'async_local_context',
'undici_instrumentation'
]

// flags that are no longer used for unreleased features
Expand Down
15 changes: 1 addition & 14 deletions lib/instrumentation/undici.js
Expand Up @@ -12,22 +12,9 @@ const NAMES = require('../metrics/names')
const NEWRELIC_SYNTHETICS_HEADER = 'x-newrelic-synthetics'
const symbols = require('../symbols')
const { executionAsyncResource } = require('async_hooks')
let diagnosticsChannel = null
try {
diagnosticsChannel = require('diagnostics_channel')
} catch (e) {
// quick check to see if module exists
// module was not added until v15.x
}
const diagnosticsChannel = require('diagnostics_channel')

module.exports = function addUndiciChannels(agent, _undici, _modName, shim) {
if (!diagnosticsChannel || !agent.config.feature_flag.undici_instrumentation) {
logger.warn(
'diagnostics_channel or feature_flag.undici_instrumentation = false. Skipping undici instrumentation.'
)
return
}

registerHookPoints(shim)
}

Expand Down
10 changes: 0 additions & 10 deletions test/unit/instrumentation/undici.test.js
Expand Up @@ -38,7 +38,6 @@ tap.test('undici instrumentation', function (t) {
agent.config.distributed_tracing.enabled = false
agent.config.cross_application_tracer.enabled = false
agent.config.feature_flag = {
undici_instrumentation: true,
undici_async_tracking: true
}
shim = new TransactionShim(agent, 'undici')
Expand All @@ -59,15 +58,6 @@ tap.test('undici instrumentation', function (t) {
helper.unloadAgent(agent)
}

t.test('should log warning if feature flag is not enabled', function (t) {
agent.config.feature_flag.undici_instrumentation = false
undiciInstrumentation(agent)
t.same(loggerMock.warn.args[0], [
'diagnostics_channel or feature_flag.undici_instrumentation = false. Skipping undici instrumentation.'
])
t.end()
})

t.test('request:create', function (t) {
t.autoend()
t.afterEach(afterEach)
Expand Down
6 changes: 1 addition & 5 deletions test/versioned/undici/requests.tap.js
Expand Up @@ -49,11 +49,7 @@ tap.test('Undici request tests', (t) => {
}

t.before(() => {
agent = helper.instrumentMockedAgent({
feature_flag: {
undici_instrumentation: true
}
})
agent = helper.instrumentMockedAgent()

undici = require('undici')
server = createServer()
Expand Down

0 comments on commit 683b254

Please sign in to comment.