Skip to content

Commit 683b254

Browse files
authored
feat: Removed undici feature flag. This will now instrument undici by default (#1772)
1 parent 6ecde97 commit 683b254

File tree

5 files changed

+4
-37
lines changed

5 files changed

+4
-37
lines changed

documentation/feature-flags.md

-6
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,6 @@ Any prerelease flags can be enabled or disabled in your agent config by adding a
2020
* Environment Variable: `NEW_RELIC_FEATURE_FLAG_REVERSE_NAMING_RULES`
2121
* Description: Naming rules are in forward order by default.
2222

23-
#### undici_instrumentation
24-
* Enabled by default: `false`
25-
* Configuration: `{ feature_flag: { undici_instrumentation: true|false }}`
26-
* Environment Variable: `NEW_RELIC_FEATURE_FLAG_UNDICI_INSTRUMENTATION`
27-
* 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.
28-
2923
#### undici_async_tracking
3024
* Enabled by default: `true`
3125
* Configuration: `{ feature_flag: { undici_async_tracking: true|false }}`

lib/feature_flags.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ exports.prerelease = {
1010
express5: false,
1111
promise_segments: false,
1212
reverse_naming_rules: false,
13-
undici_instrumentation: false,
1413
undici_async_tracking: true,
1514
unresolved_promise_cleanup: true,
1615
legacy_context_manager: false
@@ -33,7 +32,8 @@ exports.released = [
3332
'fastify_instrumentation',
3433
'await_support',
3534
'certificate_bundle',
36-
'async_local_context'
35+
'async_local_context',
36+
'undici_instrumentation'
3737
]
3838

3939
// flags that are no longer used for unreleased features

lib/instrumentation/undici.js

+1-14
Original file line numberDiff line numberDiff line change
@@ -12,22 +12,9 @@ const NAMES = require('../metrics/names')
1212
const NEWRELIC_SYNTHETICS_HEADER = 'x-newrelic-synthetics'
1313
const symbols = require('../symbols')
1414
const { executionAsyncResource } = require('async_hooks')
15-
let diagnosticsChannel = null
16-
try {
17-
diagnosticsChannel = require('diagnostics_channel')
18-
} catch (e) {
19-
// quick check to see if module exists
20-
// module was not added until v15.x
21-
}
15+
const diagnosticsChannel = require('diagnostics_channel')
2216

2317
module.exports = function addUndiciChannels(agent, _undici, _modName, shim) {
24-
if (!diagnosticsChannel || !agent.config.feature_flag.undici_instrumentation) {
25-
logger.warn(
26-
'diagnostics_channel or feature_flag.undici_instrumentation = false. Skipping undici instrumentation.'
27-
)
28-
return
29-
}
30-
3118
registerHookPoints(shim)
3219
}
3320

test/unit/instrumentation/undici.test.js

-10
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@ tap.test('undici instrumentation', function (t) {
3838
agent.config.distributed_tracing.enabled = false
3939
agent.config.cross_application_tracer.enabled = false
4040
agent.config.feature_flag = {
41-
undici_instrumentation: true,
4241
undici_async_tracking: true
4342
}
4443
shim = new TransactionShim(agent, 'undici')
@@ -59,15 +58,6 @@ tap.test('undici instrumentation', function (t) {
5958
helper.unloadAgent(agent)
6059
}
6160

62-
t.test('should log warning if feature flag is not enabled', function (t) {
63-
agent.config.feature_flag.undici_instrumentation = false
64-
undiciInstrumentation(agent)
65-
t.same(loggerMock.warn.args[0], [
66-
'diagnostics_channel or feature_flag.undici_instrumentation = false. Skipping undici instrumentation.'
67-
])
68-
t.end()
69-
})
70-
7161
t.test('request:create', function (t) {
7262
t.autoend()
7363
t.afterEach(afterEach)

test/versioned/undici/requests.tap.js

+1-5
Original file line numberDiff line numberDiff line change
@@ -49,11 +49,7 @@ tap.test('Undici request tests', (t) => {
4949
}
5050

5151
t.before(() => {
52-
agent = helper.instrumentMockedAgent({
53-
feature_flag: {
54-
undici_instrumentation: true
55-
}
56-
})
52+
agent = helper.instrumentMockedAgent()
5753

5854
undici = require('undici')
5955
server = createServer()

0 commit comments

Comments
 (0)