newrelic 13.3.3 → 13.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/NEWS.md +54 -0
- package/THIRD_PARTY_NOTICES.md +11 -11
- package/api.js +1 -1
- package/esm-loader.mjs +2 -2
- package/lib/agent.js +2 -2
- package/lib/aggregators/event-aggregator.js +0 -2
- package/lib/attributes.js +6 -6
- package/lib/collector/api.js +1 -1
- package/lib/collector/facts.js +1 -1
- package/lib/collector/http-agents.js +2 -2
- package/lib/collector/parse-response.js +9 -12
- package/lib/collector/remote-method.js +4 -5
- package/lib/collector/serverless.js +1 -1
- package/lib/config/build-instrumentation-config.js +13 -3
- package/lib/config/default.js +21 -10
- package/lib/config/formatters.js +5 -6
- package/lib/config/index.js +37 -24
- package/lib/harvester.js +1 -1
- package/lib/header-processing.js +3 -3
- package/lib/health-reporter.js +2 -2
- package/lib/instrumentation/@node-redis/client.js +1 -1
- package/lib/instrumentation/@prisma/client.js +1 -1
- package/lib/instrumentation/aws-sdk/util.js +3 -3
- package/lib/instrumentation/aws-sdk/v2/instrumentation-helper.js +2 -2
- package/lib/instrumentation/aws-sdk/v3/bedrock.js +5 -5
- package/lib/instrumentation/aws-sdk/v3/common.js +14 -14
- package/lib/instrumentation/aws-sdk/v3/dynamodb.js +13 -13
- package/lib/instrumentation/aws-sdk/v3/lambda.js +3 -3
- package/lib/instrumentation/aws-sdk/v3/sns.js +12 -12
- package/lib/instrumentation/aws-sdk/v3/sqs.js +9 -9
- package/lib/instrumentation/core/http-outbound.js +1 -2
- package/lib/instrumentation/fastify/spec-builders.js +9 -29
- package/lib/instrumentation/fastify.js +23 -94
- package/lib/instrumentation/kafkajs/consumer.js +1 -1
- package/lib/instrumentation/koa/instrumentation.js +1 -1
- package/lib/instrumentation/langchain/runnable.js +1 -1
- package/lib/instrumentation/memcached.js +4 -4
- package/lib/instrumentation/mongodb.js +2 -2
- package/lib/instrumentation/nextjs/next-server.js +1 -3
- package/lib/instrumentation/nextjs/utils.js +2 -2
- package/lib/instrumentation/restify.js +2 -2
- package/lib/instrumentation/when/contextualizer.js +1 -1
- package/lib/instrumentation-descriptor.js +2 -11
- package/lib/instrumentations.js +1 -20
- package/lib/llm-events/aws-bedrock/bedrock-response.js +6 -6
- package/lib/llm-events/aws-bedrock/chat-completion-summary.js +2 -1
- package/lib/llm-events/aws-bedrock/converse-stream-handler.js +1 -1
- package/lib/llm-events/aws-bedrock/stream-handler.js +4 -4
- package/lib/metrics/index.js +2 -2
- package/lib/metrics/normalizer/rule.js +1 -1
- package/lib/metrics/normalizer.js +4 -5
- package/lib/metrics/recorders/database-operation.js +2 -3
- package/lib/metrics/recorders/message-transaction.js +3 -3
- package/lib/metrics/recorders/middleware.js +1 -2
- package/lib/otel/context-manager.js +4 -4
- package/lib/otel/trace-propagator.js +1 -1
- package/lib/otel/traces/segments/database.js +1 -1
- package/lib/otel/traces/utils.js +9 -9
- package/lib/prioritized-attributes.js +2 -2
- package/lib/{adaptive-sampler.js → samplers/adaptive-sampler.js} +8 -0
- package/lib/serverless/aws-lambda.js +4 -4
- package/lib/shim/datastore-shim.js +2 -2
- package/lib/shim/message-shim/consume.js +4 -4
- package/lib/shim/message-shim/subscribe-consume.js +1 -2
- package/lib/shim/promise-shim.js +1 -4
- package/lib/shim/shim.js +14 -29
- package/lib/shim/specs/class.js +3 -3
- package/lib/shim/specs/middleware-mounter.js +2 -2
- package/lib/shim/specs/middleware.js +3 -3
- package/lib/shim/specs/query.js +1 -1
- package/lib/shim/specs/recorder.js +1 -1
- package/lib/shim/specs/wrap.js +2 -2
- package/lib/shim/transaction-shim.js +0 -1
- package/lib/shim/webframework-shim/common.js +2 -4
- package/lib/shim/webframework-shim/index.js +10 -1
- package/lib/shim/webframework-shim/middleware.js +17 -21
- package/lib/shimmer.js +56 -103
- package/lib/spans/span-context.js +1 -1
- package/lib/spans/span-event-aggregator.js +2 -2
- package/lib/spans/span-event.js +6 -5
- package/lib/spans/streaming-span-attributes.js +1 -1
- package/lib/spans/streaming-span-event-aggregator.js +5 -3
- package/lib/spans/streaming-span-event.js +1 -1
- package/lib/stats/index.js +1 -1
- package/lib/subscriber-configs.js +6 -1
- package/lib/subscribers/amqplib/accept-message.js +14 -0
- package/lib/subscribers/amqplib/callback-model.js +39 -0
- package/lib/subscribers/amqplib/channel-model.js +39 -0
- package/lib/subscribers/amqplib/config.js +697 -0
- package/lib/subscribers/amqplib/connect.js +74 -0
- package/lib/subscribers/amqplib/consume.js +54 -0
- package/lib/subscribers/amqplib/get-cb.js +16 -0
- package/lib/subscribers/amqplib/get.js +50 -0
- package/lib/subscribers/amqplib/purge-queue-cb.js +16 -0
- package/lib/subscribers/amqplib/purge-queue.js +37 -0
- package/lib/subscribers/amqplib/send-message.js +44 -0
- package/lib/subscribers/amqplib/send-or-enqueue.js +18 -0
- package/lib/subscribers/amqplib/utils.js +53 -0
- package/lib/subscribers/application-logs.js +1 -1
- package/lib/subscribers/base.js +113 -29
- package/lib/subscribers/cassandra-driver/client-batch.js +49 -0
- package/lib/subscribers/cassandra-driver/client-connect.js +35 -0
- package/lib/subscribers/cassandra-driver/client-each-row.js +36 -0
- package/lib/subscribers/cassandra-driver/client-execute.js +36 -0
- package/lib/subscribers/cassandra-driver/client-shutdown.js +32 -0
- package/lib/subscribers/cassandra-driver/config.js +145 -0
- package/lib/subscribers/cassandra-driver/legacy-client-batch.js +22 -0
- package/lib/subscribers/cassandra-driver/legacy-client-connect.js +22 -0
- package/lib/subscribers/cassandra-driver/legacy-client-each-row.js +22 -0
- package/lib/subscribers/cassandra-driver/legacy-client-execute.js +21 -0
- package/lib/subscribers/cassandra-driver/legacy-client-shutdown.js +32 -0
- package/lib/subscribers/create-config.js +4 -6
- package/lib/subscribers/db-operation.js +12 -0
- package/lib/subscribers/db-query.js +5 -1
- package/lib/subscribers/dc-base.js +89 -0
- package/lib/subscribers/fastify/add-hook.js +46 -0
- package/lib/subscribers/fastify/common.js +121 -0
- package/lib/subscribers/fastify/config.js +39 -0
- package/lib/subscribers/fastify/decorate.js +35 -0
- package/lib/subscribers/fastify/index.js +31 -0
- package/lib/subscribers/mcp-sdk/client-request.js +1 -1
- package/lib/subscribers/mcp-sdk/config.js +2 -0
- package/lib/subscribers/message-consumer.js +146 -0
- package/lib/subscribers/message-producer.js +60 -0
- package/lib/subscribers/meta-subscriber.js +69 -0
- package/lib/subscribers/openai/base.js +27 -1
- package/lib/subscribers/openai/chat.js +0 -27
- package/lib/subscribers/openai/config.js +3 -3
- package/lib/subscribers/openai/utils.js +10 -11
- package/lib/subscribers/pg/config.js +91 -0
- package/lib/subscribers/pg/connect.js +28 -0
- package/lib/subscribers/pg/native-connect.js +25 -0
- package/lib/subscribers/pg/native-query.js +22 -0
- package/lib/subscribers/pg/query.js +66 -0
- package/lib/subscribers/pino/index.js +2 -2
- package/lib/subscribers/propagation.js +23 -0
- package/lib/subscribers/undici/config.js +11 -0
- package/lib/subscribers/undici/index.js +195 -0
- package/lib/synthetics.js +4 -4
- package/lib/timer.js +1 -1
- package/lib/tracking-packages.js +25 -0
- package/lib/transaction/dt-payload.js +1 -1
- package/lib/transaction/handle.js +8 -9
- package/lib/transaction/index.js +25 -21
- package/lib/transaction/name-state.js +11 -11
- package/lib/transaction/trace/segment.js +3 -4
- package/lib/transaction/tracer/index.js +1 -1
- package/lib/util/attribute-types.js +1 -1
- package/lib/util/byte-limit.js +1 -1
- package/lib/util/cat.js +13 -13
- package/lib/util/flatten.js +2 -3
- package/lib/util/is-absolute-path.js +1 -1
- package/lib/util/is-string.js +15 -0
- package/lib/util/llm-utils.js +3 -3
- package/lib/util/logger.js +8 -8
- package/lib/util/stream-sink.js +1 -1
- package/lib/utilization/docker-info.js +4 -3
- package/lib/utilization/ecs-info.js +1 -1
- package/lib/w3c/traceparent.js +3 -3
- package/lib/w3c/tracestate.js +1 -1
- package/package.json +2 -2
- package/lib/instrumentation/amqplib/amqplib.js +0 -122
- package/lib/instrumentation/amqplib/channel-model.js +0 -124
- package/lib/instrumentation/amqplib/channel.js +0 -72
- package/lib/instrumentation/amqplib/nr-hooks.js +0 -21
- package/lib/instrumentation/amqplib/utils.js +0 -143
- package/lib/instrumentation/cassandra-driver.js +0 -131
- package/lib/instrumentation/pg.js +0 -137
- package/lib/instrumentation/undici.js +0 -229
package/lib/config/index.js
CHANGED
|
@@ -123,7 +123,8 @@ function Config(config) {
|
|
|
123
123
|
this.primary_application_id = null
|
|
124
124
|
this.trusted_account_ids = null
|
|
125
125
|
this.trusted_account_key = null
|
|
126
|
-
|
|
126
|
+
|
|
127
|
+
this.sampling_target = this.distributed_tracing.sampler.adaptive_sampling_target
|
|
127
128
|
this.sampling_target_period_in_seconds = 60
|
|
128
129
|
this.max_payload_size_in_bytes = DEFAULT_MAX_PAYLOAD_SIZE_IN_BYTES
|
|
129
130
|
|
|
@@ -184,9 +185,9 @@ function Config(config) {
|
|
|
184
185
|
if (this.security_policies_token) {
|
|
185
186
|
throw new Error(
|
|
186
187
|
'Security Policies and High Security Mode cannot both be present ' +
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
188
|
+
'in the agent configuration. If Security Policies have been set ' +
|
|
189
|
+
'for your account, please ensure the security_policies_token is ' +
|
|
190
|
+
'set but high_security is disabled (default).'
|
|
190
191
|
)
|
|
191
192
|
}
|
|
192
193
|
this._applyHighSecurity()
|
|
@@ -199,8 +200,20 @@ function Config(config) {
|
|
|
199
200
|
this.parsedLabels = parseLabels(this.labels, logger)
|
|
200
201
|
this.loggingLabels = this._setApplicationLoggingLabels()
|
|
201
202
|
}
|
|
203
|
+
|
|
202
204
|
util.inherits(Config, EventEmitter)
|
|
203
205
|
|
|
206
|
+
// Expose sampling_target as an accessor that proxies to distributed_tracing.sampler.adaptive_sampling_target.
|
|
207
|
+
Object.defineProperty(Config.prototype, 'sampling_target', {
|
|
208
|
+
get: function () {
|
|
209
|
+
return this.distributed_tracing.sampler.adaptive_sampling_target
|
|
210
|
+
},
|
|
211
|
+
set: function (value) {
|
|
212
|
+
this.distributed_tracing.sampler.adaptive_sampling_target = value
|
|
213
|
+
this.emit('sampling_target', value)
|
|
214
|
+
}
|
|
215
|
+
})
|
|
216
|
+
|
|
204
217
|
/**
|
|
205
218
|
* Compares the labels list to the application logging excluded label list and removes any labels that need to be excluded.
|
|
206
219
|
* Then prefixing each label with "tags."
|
|
@@ -694,7 +707,7 @@ function _validateThenUpdateStatusCodes(remote, local, remoteKey, localKey) {
|
|
|
694
707
|
if (!(typeof thingToTest === 'string' || typeof thingToTest === 'number')) {
|
|
695
708
|
logger.warn(
|
|
696
709
|
'Saw SSC (ignore|expect)_status_code that is not a number or string,' +
|
|
697
|
-
|
|
710
|
+
'will not merge: %s',
|
|
698
711
|
thingToTest
|
|
699
712
|
)
|
|
700
713
|
valid = false
|
|
@@ -858,7 +871,7 @@ Config.prototype.logDisabled = function logDisabled(json, key) {
|
|
|
858
871
|
if (value != null) {
|
|
859
872
|
logger.debug(
|
|
860
873
|
'Server-side configuration of %s is currently disabled by local configuration. ' +
|
|
861
|
-
|
|
874
|
+
'(Server sent value of %s.)',
|
|
862
875
|
key,
|
|
863
876
|
value
|
|
864
877
|
)
|
|
@@ -877,7 +890,7 @@ Config.prototype.logUnsupported = function logUnsupported(json, key) {
|
|
|
877
890
|
if (value !== null && value !== undefined) {
|
|
878
891
|
logger.debug(
|
|
879
892
|
'Server-side configuration of %s is currently not supported by the ' +
|
|
880
|
-
|
|
893
|
+
'Node.js agent. (Server sent value of %s.)',
|
|
881
894
|
key,
|
|
882
895
|
value
|
|
883
896
|
)
|
|
@@ -1218,8 +1231,8 @@ Config.prototype._serverlessLogging = function _serverlessLogging(inputConfig) {
|
|
|
1218
1231
|
|
|
1219
1232
|
logger.info(
|
|
1220
1233
|
'Logging is disabled by default when serverless_mode is enabled. ' +
|
|
1221
|
-
|
|
1222
|
-
|
|
1234
|
+
'If desired, enable logging via config file or environment variable and ' +
|
|
1235
|
+
'set filepath to a valid path for current environment, stdout or stderr.'
|
|
1223
1236
|
)
|
|
1224
1237
|
}
|
|
1225
1238
|
}
|
|
@@ -1241,17 +1254,17 @@ Config.prototype._serverlessNativeMetrics = function _serverlessNativeMetrics(in
|
|
|
1241
1254
|
) {
|
|
1242
1255
|
logger.info(
|
|
1243
1256
|
'Enabling the native-metrics module when in serverless mode may greatly ' +
|
|
1244
|
-
|
|
1245
|
-
|
|
1246
|
-
|
|
1257
|
+
'increase cold-start times. Given the limited benefit of the VM metrics' +
|
|
1258
|
+
'and general lack of control in a serverless environment, we do not ' +
|
|
1259
|
+
'recommend this trade-off.'
|
|
1247
1260
|
)
|
|
1248
1261
|
} else {
|
|
1249
1262
|
this.plugins.native_metrics.enabled = false
|
|
1250
1263
|
|
|
1251
1264
|
logger.info(
|
|
1252
1265
|
'The native-metrics module is disabled by default when serverless_mode ' +
|
|
1253
|
-
|
|
1254
|
-
|
|
1266
|
+
'is enabled. If desired, enable the native-metrics module via config file ' +
|
|
1267
|
+
'or environment variable.'
|
|
1255
1268
|
)
|
|
1256
1269
|
}
|
|
1257
1270
|
}
|
|
@@ -1305,8 +1318,8 @@ Config.prototype._serverlessDT = function _serverlessDT() {
|
|
|
1305
1318
|
if (this.distributed_tracing.enabled) {
|
|
1306
1319
|
logger.warn(
|
|
1307
1320
|
'Using distributed tracing in serverless mode requires account_id be ' +
|
|
1308
|
-
|
|
1309
|
-
|
|
1321
|
+
'defined, either in your newrelic.js file or via environment variables. ' +
|
|
1322
|
+
'Disabling distributed tracing.'
|
|
1310
1323
|
)
|
|
1311
1324
|
this.distributed_tracing.enabled = false
|
|
1312
1325
|
}
|
|
@@ -1332,8 +1345,8 @@ Config.prototype._preventServerlessDT = function _preventServerlessDT() {
|
|
|
1332
1345
|
if (this[key]) {
|
|
1333
1346
|
logger.warn(
|
|
1334
1347
|
key +
|
|
1335
|
-
|
|
1336
|
-
|
|
1348
|
+
' was configured locally without enabling serverless_mode. ' +
|
|
1349
|
+
'This local value will be ignored and set by the New Relic servers.'
|
|
1337
1350
|
)
|
|
1338
1351
|
this[key] = null
|
|
1339
1352
|
}
|
|
@@ -1529,7 +1542,7 @@ function _laspReponse(keys) {
|
|
|
1529
1542
|
/**
|
|
1530
1543
|
* Applies the server side LASP policies to a local configuration object
|
|
1531
1544
|
*
|
|
1532
|
-
* @param agent
|
|
1545
|
+
* @param {Agent} agent Agent instance
|
|
1533
1546
|
* @param {object} policies server side LASP policy
|
|
1534
1547
|
* @returns {object} { missingRequired, finalPolicies } list of missing required fields and finalized LASP policy
|
|
1535
1548
|
*/
|
|
@@ -1595,7 +1608,7 @@ Config.prototype._buildLaspPolicy = function _buildLaspPolicy(agent, policies) {
|
|
|
1595
1608
|
* by the agent, if LASP-enabled. Responds with an error to shut down
|
|
1596
1609
|
* the agent if necessary.
|
|
1597
1610
|
*
|
|
1598
|
-
* @param agent
|
|
1611
|
+
* @param {Agent} agent Agent instance
|
|
1599
1612
|
* @param {object} policies lasp policy
|
|
1600
1613
|
* @returns {CollectorResponse} The result of the processing, with the known
|
|
1601
1614
|
* policies as the response payload.
|
|
@@ -1670,7 +1683,7 @@ function redactValue(value) {
|
|
|
1670
1683
|
* Get a JSONifiable object containing all settings we want to report to the
|
|
1671
1684
|
* collector and store in the environment_values table.
|
|
1672
1685
|
*
|
|
1673
|
-
* @returns {object} containing simple key-value pairs of settings
|
|
1686
|
+
* @returns {object|undefined} containing simple key-value pairs of settings, or undefined if an error occurred
|
|
1674
1687
|
*/
|
|
1675
1688
|
Config.prototype.publicSettings = function publicSettings() {
|
|
1676
1689
|
let settings = Object.create(null)
|
|
@@ -1745,9 +1758,9 @@ Config.prototype._warnDeprecations = function _warnDeprecations() {
|
|
|
1745
1758
|
* the environment variables will override their corresponding
|
|
1746
1759
|
* configuration file settings.
|
|
1747
1760
|
*
|
|
1748
|
-
* @param {object} config Optional configuration to be used in place of a config file.
|
|
1749
|
-
* @param
|
|
1750
|
-
* @param
|
|
1761
|
+
* @param {object} [config] Optional configuration to be used in place of a config file.
|
|
1762
|
+
* @param {object} [deps] Optional dependencies
|
|
1763
|
+
* @param {object} [deps.loggerInstance] Logger instance
|
|
1751
1764
|
* @returns {object} instantiated configuration object
|
|
1752
1765
|
*/
|
|
1753
1766
|
function initialize(config, { loggerInstance } = {}) {
|
package/lib/harvester.js
CHANGED
package/lib/header-processing.js
CHANGED
|
@@ -15,8 +15,8 @@ const CONTENT_LENGTH_REGEX = /^Content-Length$/i
|
|
|
15
15
|
* Queue time is provided by certain providers by stamping the request
|
|
16
16
|
* header with the time the request arrived at the router.
|
|
17
17
|
*
|
|
18
|
-
* @param {
|
|
19
|
-
* @param {
|
|
18
|
+
* @param {object} logger Logger instance
|
|
19
|
+
* @param {object} requestHeaders Incoming request headers
|
|
20
20
|
*/
|
|
21
21
|
function getQueueTime(logger, requestHeaders) {
|
|
22
22
|
const headerValue = requestHeaders[REQUEST_START_HEADER] || requestHeaders[QUEUE_HEADER]
|
|
@@ -62,7 +62,7 @@ function convertUnit(time) {
|
|
|
62
62
|
*
|
|
63
63
|
* If no header is found, returns -1
|
|
64
64
|
*
|
|
65
|
-
* @param {
|
|
65
|
+
* @param {object} headers Incoming request headers
|
|
66
66
|
*/
|
|
67
67
|
function getContentLengthFromHeaders(headers) {
|
|
68
68
|
const contentLength = -1
|
package/lib/health-reporter.js
CHANGED
|
@@ -112,7 +112,7 @@ class HealthReporter {
|
|
|
112
112
|
* object that has an `agent_control` property which is an instance of
|
|
113
113
|
* {@link AgentControlConfig}.
|
|
114
114
|
* @param {object} [params.logger] A standard logger instance.
|
|
115
|
-
* @param {
|
|
115
|
+
* @param {Function} [params.setInterval] A function to use as `setInterval`.
|
|
116
116
|
* Must return an interval object that supports the `unref()` method.
|
|
117
117
|
*/
|
|
118
118
|
constructor({
|
|
@@ -217,7 +217,7 @@ class HealthReporter {
|
|
|
217
217
|
* initiate an immediate write of the status file, and then invoke the
|
|
218
218
|
* provided callback.
|
|
219
219
|
*
|
|
220
|
-
* @param {
|
|
220
|
+
* @param {Function} done Callback to be invoked after the status file has
|
|
221
221
|
* been updated.
|
|
222
222
|
*/
|
|
223
223
|
stop(done) {
|
|
@@ -43,7 +43,7 @@ module.exports = function initialize(_agent, redis, _moduleName, shim) {
|
|
|
43
43
|
/**
|
|
44
44
|
* Instruments a given command when added to the command queue by calling `shim.recordOperation`
|
|
45
45
|
*
|
|
46
|
-
* @param {object} params
|
|
46
|
+
* @param {object} params params object
|
|
47
47
|
* @param {Shim} params.shim shim instance
|
|
48
48
|
* @param {object} params.commandsQueue instance
|
|
49
49
|
*/
|
|
@@ -75,7 +75,7 @@ function extractQueryArgs(args, pkgVersion) {
|
|
|
75
75
|
*
|
|
76
76
|
* @param {Array} args arguments to a prisma operation
|
|
77
77
|
* @param {string} pkgVersion prisma version
|
|
78
|
-
* @returns {string} query raw query string or model call <collection>.<operation>
|
|
78
|
+
* @returns {string|undefined} query raw query string or model call <collection>.<operation>
|
|
79
79
|
*/
|
|
80
80
|
function retrieveQuery(args, pkgVersion) {
|
|
81
81
|
if (Array.isArray(args)) {
|
|
@@ -20,9 +20,9 @@ function grabLastUrlSegment(url = '/') {
|
|
|
20
20
|
/**
|
|
21
21
|
* Retrieves the db segment params from endpoint and command parameters
|
|
22
22
|
*
|
|
23
|
-
* @param {
|
|
24
|
-
* @param {
|
|
25
|
-
* @returns {
|
|
23
|
+
* @param {object} endpoint instance of ddb endpoint
|
|
24
|
+
* @param {object} params parameters passed to a ddb command
|
|
25
|
+
* @returns {object}
|
|
26
26
|
*/
|
|
27
27
|
function setDynamoParameters(endpoint, params) {
|
|
28
28
|
return new DatastoreParameters({
|
|
@@ -7,8 +7,8 @@
|
|
|
7
7
|
|
|
8
8
|
/**
|
|
9
9
|
* Series of tests to determine if the library
|
|
10
|
-
* has the features needed to provide instrumentation
|
|
11
|
-
* @param AWS
|
|
10
|
+
* has the features needed to provide instrumentation.
|
|
11
|
+
* @param {object} AWS AWS SDK object
|
|
12
12
|
*/
|
|
13
13
|
const instrumentationSupported = function instrumentationSupported(AWS) {
|
|
14
14
|
// instrumentation requires the serviceClientOperationsMap property
|
|
@@ -43,7 +43,7 @@ const CONVERSE_COMMANDS = new Set([
|
|
|
43
43
|
/**
|
|
44
44
|
* Helper to determine if we should instrument the bedrock middleware call
|
|
45
45
|
*
|
|
46
|
-
* @param {
|
|
46
|
+
* @param {object} config agent configuration
|
|
47
47
|
* @returns {boolean} to instrument or not to instrument
|
|
48
48
|
*/
|
|
49
49
|
function shouldSkipInstrumentation(config) {
|
|
@@ -251,9 +251,9 @@ function createBedrockResponse({ bedrockCommand, response, err }) {
|
|
|
251
251
|
* @param {object} params { config, commandName } aws config and command name
|
|
252
252
|
* @param {string} params.commandName name of command
|
|
253
253
|
* @param {Shim} shim instance of shim
|
|
254
|
-
* @param {
|
|
254
|
+
* @param {Function} _original original middleware function
|
|
255
255
|
* @param {string} _name function name
|
|
256
|
-
* @param {
|
|
256
|
+
* @param {Array} args argument passed to middleware
|
|
257
257
|
* @returns {object} specification object that records middleware as promise
|
|
258
258
|
* with an after hook to create LLM events
|
|
259
259
|
*/
|
|
@@ -357,10 +357,10 @@ function handleResponse({ shim, err, response, segment, transaction, bedrockComm
|
|
|
357
357
|
*
|
|
358
358
|
* @param {Shim} shim instance of shim
|
|
359
359
|
* @param {object} config AWS configuration object
|
|
360
|
-
* @param {
|
|
360
|
+
* @param {Function} next the next middleware function in stack
|
|
361
361
|
* @param {object} context AWS client context info
|
|
362
362
|
*
|
|
363
|
-
* @returns {
|
|
363
|
+
* @returns {Function} the next middleware function in stack
|
|
364
364
|
*/
|
|
365
365
|
function bedrockMiddleware(shim, config, next, context) {
|
|
366
366
|
const { commandName } = context
|
|
@@ -12,10 +12,10 @@ const InstrumentationDescriptor = require('../../../instrumentation-descriptor')
|
|
|
12
12
|
* Wraps the build middleware step to add the disable DT
|
|
13
13
|
* header to all outgoing requests
|
|
14
14
|
*
|
|
15
|
-
* @param {Shim} shim
|
|
16
|
-
* @param config
|
|
17
|
-
* @param {
|
|
18
|
-
* @returns {
|
|
15
|
+
* @param {Shim} shim instance
|
|
16
|
+
* @param {object} config configuration options
|
|
17
|
+
* @param {Function} next next function in middleware chain
|
|
18
|
+
* @returns {Function}
|
|
19
19
|
*
|
|
20
20
|
*/
|
|
21
21
|
function headerMiddleware(shim, config, next) {
|
|
@@ -31,11 +31,11 @@ function headerMiddleware(shim, config, next) {
|
|
|
31
31
|
* Wraps the deserialize middleware step to add the
|
|
32
32
|
* appropriate segment attributes for the AWS command
|
|
33
33
|
*
|
|
34
|
-
* @param {Shim} shim
|
|
35
|
-
* @param {
|
|
36
|
-
* @param {
|
|
37
|
-
* @param {
|
|
38
|
-
* @returns {
|
|
34
|
+
* @param {Shim} shim instance
|
|
35
|
+
* @param {object} config AWS command configuration
|
|
36
|
+
* @param {Function} next next function in middleware chain
|
|
37
|
+
* @param {object} context AWS command context
|
|
38
|
+
* @returns {Function}
|
|
39
39
|
*/
|
|
40
40
|
function attrMiddleware(shim, config, next, context) {
|
|
41
41
|
return async function wrappedMiddleware(args) {
|
|
@@ -55,12 +55,12 @@ function attrMiddleware(shim, config, next, context) {
|
|
|
55
55
|
* Adds the necessary aws.* attributes to either the External or first
|
|
56
56
|
* class operation segment
|
|
57
57
|
*
|
|
58
|
-
* @param {
|
|
59
|
-
* @param {
|
|
60
|
-
* @param {
|
|
58
|
+
* @param {object} params params object
|
|
59
|
+
* @param {object} params.result result from middleware
|
|
60
|
+
* @param {object} params.config AWS config
|
|
61
61
|
* @param {string} params.region AWS region
|
|
62
|
-
* @param {Shim} params.shim
|
|
63
|
-
* @param {
|
|
62
|
+
* @param {Shim} params.shim Shim instance
|
|
63
|
+
* @param {object} params.context smithy client context
|
|
64
64
|
*/
|
|
65
65
|
function addAwsAttributes({ result, config, region, shim, context }) {
|
|
66
66
|
try {
|
|
@@ -11,11 +11,11 @@ const InstrumentationDescriptor = require('../../../instrumentation-descriptor')
|
|
|
11
11
|
/**
|
|
12
12
|
* Returns the spec for Dynamo commands
|
|
13
13
|
*
|
|
14
|
-
* @param {Shim} shim
|
|
14
|
+
* @param {Shim} shim Shim instance
|
|
15
15
|
* @param {original} original Original middleware function
|
|
16
|
-
* @param {
|
|
16
|
+
* @param {string} name Name of the calling function
|
|
17
17
|
* @param {Array} args Arguments for the middleware function
|
|
18
|
-
* @returns {
|
|
18
|
+
* @returns {object}
|
|
19
19
|
*/
|
|
20
20
|
function getDynamoSpec(shim, original, name, args) {
|
|
21
21
|
const [{ input }] = args
|
|
@@ -35,7 +35,7 @@ function getDynamoSpec(shim, original, name, args) {
|
|
|
35
35
|
* unless you provide an endpoint override to your library constructor
|
|
36
36
|
* This function will derive the endpoint in that scenario by grabbing the region
|
|
37
37
|
* and building the URL
|
|
38
|
-
* @param config
|
|
38
|
+
* @param {object} config configuration options
|
|
39
39
|
*/
|
|
40
40
|
async function getEndpoint(config) {
|
|
41
41
|
if (typeof config.endpoint === 'function') {
|
|
@@ -50,11 +50,11 @@ async function getEndpoint(config) {
|
|
|
50
50
|
* Middleware hook that records the middleware chain
|
|
51
51
|
* when command is in a list of monitored commands.
|
|
52
52
|
*
|
|
53
|
-
* @param {Shim} shim
|
|
54
|
-
* @param {
|
|
55
|
-
* @param {
|
|
56
|
-
* @param {
|
|
57
|
-
* @returns {
|
|
53
|
+
* @param {Shim} shim Shim instance
|
|
54
|
+
* @param {object} config AWS SDK client configuration
|
|
55
|
+
* @param {Function} next middleware function
|
|
56
|
+
* @param {object} context Context for the running command
|
|
57
|
+
* @returns {Function}
|
|
58
58
|
*/
|
|
59
59
|
function dynamoMiddleware(shim, config, next, context) {
|
|
60
60
|
const { commandName } = context
|
|
@@ -76,10 +76,10 @@ function dynamoMiddleware(shim, config, next, context) {
|
|
|
76
76
|
* Wraps the deserialize middleware step to add the
|
|
77
77
|
* cloud.resource_id segment attributes for the AWS command
|
|
78
78
|
*
|
|
79
|
-
* @param {Shim} shim
|
|
80
|
-
* @param {
|
|
81
|
-
* @param {
|
|
82
|
-
* @returns {
|
|
79
|
+
* @param {Shim} shim Shim instance
|
|
80
|
+
* @param {object} config AWS command configuration
|
|
81
|
+
* @param {Function} next next function in middleware chain
|
|
82
|
+
* @returns {Function}
|
|
83
83
|
*/
|
|
84
84
|
function resourceIdMiddlerware(shim, config, next) {
|
|
85
85
|
return async function wrappedResourceIdMiddlerware(args) {
|
|
@@ -11,9 +11,9 @@ const InstrumentationDescriptor = require('../../../instrumentation-descriptor')
|
|
|
11
11
|
* cloud.resource_id segment attributes for the AWS command
|
|
12
12
|
*
|
|
13
13
|
* @param {Shim} shim New Relic agent shim
|
|
14
|
-
* @param {
|
|
15
|
-
* @param {
|
|
16
|
-
* @returns {
|
|
14
|
+
* @param {object} config AWS command configuration
|
|
15
|
+
* @param {Function} next next function in middleware chain
|
|
16
|
+
* @returns {Function} wrapped version of middleware function
|
|
17
17
|
*/
|
|
18
18
|
function resourceIdMiddleware(shim, config, next) {
|
|
19
19
|
return async function wrappedResourceIdMiddleware(args) {
|
|
@@ -11,11 +11,11 @@ const InstrumentationDescriptor = require('../../../instrumentation-descriptor')
|
|
|
11
11
|
* Middleware hook that records the middleware chain
|
|
12
12
|
* when command is `PublishCommand`
|
|
13
13
|
*
|
|
14
|
-
* @param {Shim} shim
|
|
15
|
-
* @param config
|
|
16
|
-
* @param {
|
|
17
|
-
* @param {
|
|
18
|
-
* @returns {
|
|
14
|
+
* @param {Shim} shim instance
|
|
15
|
+
* @param {object} config configuration options
|
|
16
|
+
* @param {Function} next middleware function
|
|
17
|
+
* @param {object} context context
|
|
18
|
+
* @returns {Function}
|
|
19
19
|
*/
|
|
20
20
|
function snsMiddleware(shim, config, next, context) {
|
|
21
21
|
if (context.commandName === 'PublishCommand') {
|
|
@@ -29,11 +29,11 @@ function snsMiddleware(shim, config, next, context) {
|
|
|
29
29
|
/**
|
|
30
30
|
* Returns the spec for PublishCommand
|
|
31
31
|
*
|
|
32
|
-
* @param {Shim} shim
|
|
33
|
-
* @param {
|
|
34
|
-
* @param name
|
|
32
|
+
* @param {Shim} shim instance
|
|
33
|
+
* @param {Function} original original middleware function
|
|
34
|
+
* @param {string} name function name
|
|
35
35
|
* @param {Array} args to the middleware function
|
|
36
|
-
* @returns {
|
|
36
|
+
* @returns {object}
|
|
37
37
|
*/
|
|
38
38
|
function getSnsSpec(shim, original, name, args) {
|
|
39
39
|
const [command] = args
|
|
@@ -50,9 +50,9 @@ function getSnsSpec(shim, original, name, args) {
|
|
|
50
50
|
* Helper to set the appropriate destinationName based on
|
|
51
51
|
* the command input
|
|
52
52
|
*
|
|
53
|
-
* @param
|
|
54
|
-
* @param
|
|
55
|
-
* @param
|
|
53
|
+
* @param {object} params params object
|
|
54
|
+
* @param {string} params.TopicArn TopicArn if available
|
|
55
|
+
* @param {string} params.TargetArn TargetArn if available
|
|
56
56
|
*/
|
|
57
57
|
function getDestinationName({ TopicArn, TargetArn }) {
|
|
58
58
|
return TopicArn || TargetArn || 'PhoneNumber' // We don't want the value of PhoneNumber
|
|
@@ -17,11 +17,11 @@ const InstrumentationDescriptor = require('../../../instrumentation-descriptor')
|
|
|
17
17
|
* Middleware hook that records the middleware chain
|
|
18
18
|
* when command is `PublishCommand`
|
|
19
19
|
*
|
|
20
|
-
* @param {Shim} shim
|
|
21
|
-
* @param config
|
|
22
|
-
* @param {
|
|
23
|
-
* @param {
|
|
24
|
-
* @returns {
|
|
20
|
+
* @param {Shim} shim instance
|
|
21
|
+
* @param {object} config configuration options
|
|
22
|
+
* @param {Function} next middleware function
|
|
23
|
+
* @param {object} context context
|
|
24
|
+
* @returns {Function}
|
|
25
25
|
*/
|
|
26
26
|
function sqsMiddleware(shim, config, next, context) {
|
|
27
27
|
if (SEND_COMMANDS.includes(context.commandName)) {
|
|
@@ -37,11 +37,11 @@ function sqsMiddleware(shim, config, next, context) {
|
|
|
37
37
|
/**
|
|
38
38
|
* Returns the spec for PublishCommand
|
|
39
39
|
*
|
|
40
|
-
* @param {Shim} shim
|
|
41
|
-
* @param {
|
|
42
|
-
* @param name
|
|
40
|
+
* @param {Shim} shim instance
|
|
41
|
+
* @param {Function} original original middleware function
|
|
42
|
+
* @param {string} name function name
|
|
43
43
|
* @param {Array} args to the middleware function
|
|
44
|
-
* @returns {
|
|
44
|
+
* @returns {object}
|
|
45
45
|
*/
|
|
46
46
|
function getSqsSpec(shim, original, name, args) {
|
|
47
47
|
const [command] = args
|
|
@@ -289,8 +289,7 @@ function applySegment({ opts, makeRequest, host, port, hostname, segment, config
|
|
|
289
289
|
* events.
|
|
290
290
|
*
|
|
291
291
|
* @param {Agent} agent New Relic agent
|
|
292
|
-
* @param {string}
|
|
293
|
-
* @param host
|
|
292
|
+
* @param {string} host host of outbound request
|
|
294
293
|
* @param {TraceSegment} segment outbound http segment
|
|
295
294
|
* @param {http.IncomingMessage} request actual http outbound request
|
|
296
295
|
*/
|
|
@@ -11,7 +11,7 @@ const { MiddlewareSpec } = require('../../shim/specs')
|
|
|
11
11
|
* Retrieves the IncomingMessage from a Fastify request. Depending on the
|
|
12
12
|
* context of this function it either exists on `request.raw` or just `request`
|
|
13
13
|
*
|
|
14
|
-
* @param {WebFrameworkShim} shim
|
|
14
|
+
* @param {WebFrameworkShim} shim instance
|
|
15
15
|
* @param {Function} fn middleware function executing
|
|
16
16
|
* @param {string} fnName name of middleware executing
|
|
17
17
|
* @param {args} args that are passed to middleware
|
|
@@ -32,7 +32,7 @@ const getRequestFromFastify = (shim, fn, fnName, args) => {
|
|
|
32
32
|
/**
|
|
33
33
|
* Retrieves the params from the Fastify request.
|
|
34
34
|
*
|
|
35
|
-
* @param {WebFrameworkShim} shim
|
|
35
|
+
* @param {WebFrameworkShim} shim instance
|
|
36
36
|
* @param {Function} fn middleware function executing
|
|
37
37
|
* @param {string} fnName name of middleware executing
|
|
38
38
|
* @param {args} args that are passed to middleware
|
|
@@ -52,7 +52,7 @@ const getParamsFromFastifyRequest = (shim, fn, fnName, args) => {
|
|
|
52
52
|
* do its job. You could also think of it as a
|
|
53
53
|
* mini-DSL
|
|
54
54
|
*
|
|
55
|
-
* @param {WebFrameworkShim} shim
|
|
55
|
+
* @param {WebFrameworkShim} shim instance
|
|
56
56
|
* @param {string} path URL route being executed
|
|
57
57
|
* @returns {object} spec for Fastify route handler
|
|
58
58
|
*/
|
|
@@ -78,11 +78,11 @@ function buildMiddlewareSpecForRouteHandler(shim, path) {
|
|
|
78
78
|
* this particular piece of middleware. (i.e. if this is the final handler
|
|
79
79
|
* that is actually handling the request, the path is actually left on)
|
|
80
80
|
*
|
|
81
|
-
* @param shim
|
|
82
|
-
* @param fn
|
|
83
|
-
* @param fnName
|
|
84
|
-
* @param args
|
|
85
|
-
* @param bindSegment
|
|
81
|
+
* @param {WebFrameworkShim} shim instance
|
|
82
|
+
* @param {Function} fn function
|
|
83
|
+
* @param {string} fnName function name
|
|
84
|
+
* @param {Array} args arguments
|
|
85
|
+
* @param {Function} bindSegment the bindSegment function
|
|
86
86
|
*/
|
|
87
87
|
next: function wrapNext(shim, fn, fnName, args, bindSegment) {
|
|
88
88
|
const reply = args[1]
|
|
@@ -98,26 +98,6 @@ function buildMiddlewareSpecForRouteHandler(shim, path) {
|
|
|
98
98
|
})
|
|
99
99
|
}
|
|
100
100
|
|
|
101
|
-
/**
|
|
102
|
-
* Spec for all Fastify middleware(excluding route handlers)
|
|
103
|
-
*
|
|
104
|
-
* @param {WebFrameworkShim} shim
|
|
105
|
-
* @param {string} name metric name for middleware being executed
|
|
106
|
-
* @param route
|
|
107
|
-
* @returns {object} spec for Fastify middleware
|
|
108
|
-
*/
|
|
109
|
-
function buildMiddlewareSpecForMiddlewareFunction(shim, name, route) {
|
|
110
|
-
return new MiddlewareSpec({
|
|
111
|
-
name,
|
|
112
|
-
route,
|
|
113
|
-
next: shim.LAST,
|
|
114
|
-
params: getParamsFromFastifyRequest,
|
|
115
|
-
req: getRequestFromFastify,
|
|
116
|
-
type: shim.MIDDLEWARE
|
|
117
|
-
})
|
|
118
|
-
}
|
|
119
|
-
|
|
120
101
|
module.exports = {
|
|
121
|
-
buildMiddlewareSpecForRouteHandler
|
|
122
|
-
buildMiddlewareSpecForMiddlewareFunction
|
|
102
|
+
buildMiddlewareSpecForRouteHandler
|
|
123
103
|
}
|