newrelic 13.3.3 → 13.4.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 +22 -0
- package/THIRD_PARTY_NOTICES.md +11 -11
- package/esm-loader.mjs +2 -2
- package/lib/attributes.js +4 -4
- 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/config/formatters.js +2 -3
- package/lib/config/index.js +6 -6
- package/lib/harvester.js +1 -1
- package/lib/header-processing.js +3 -3
- package/lib/instrumentation/@node-redis/client.js +1 -1
- package/lib/instrumentation/aws-sdk/v2/instrumentation-helper.js +2 -2
- package/lib/instrumentation/aws-sdk/v3/common.js +5 -5
- package/lib/instrumentation/aws-sdk/v3/dynamodb.js +4 -4
- package/lib/instrumentation/aws-sdk/v3/sns.js +9 -9
- package/lib/instrumentation/aws-sdk/v3/sqs.js +6 -6
- package/lib/instrumentation/core/http-outbound.js +1 -2
- package/lib/instrumentation/fastify/spec-builders.js +11 -11
- package/lib/instrumentation/fastify.js +4 -4
- package/lib/instrumentation/memcached.js +4 -4
- package/lib/instrumentation/mongodb.js +2 -2
- package/lib/instrumentation/undici.js +3 -3
- package/lib/instrumentations.js +0 -2
- package/lib/llm-events/aws-bedrock/bedrock-response.js +6 -6
- 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/message-transaction.js +3 -3
- package/lib/otel/context-manager.js +4 -4
- package/lib/otel/trace-propagator.js +1 -1
- package/lib/prioritized-attributes.js +2 -2
- package/lib/serverless/aws-lambda.js +4 -4
- package/lib/shim/datastore-shim.js +1 -1
- package/lib/shim/message-shim/consume.js +1 -1
- package/lib/shim/message-shim/subscribe-consume.js +1 -2
- package/lib/shim/promise-shim.js +1 -3
- package/lib/shim/shim.js +3 -4
- package/lib/shim/transaction-shim.js +0 -1
- package/lib/shim/webframework-shim/common.js +2 -4
- package/lib/shim/webframework-shim/middleware.js +8 -8
- 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 +1 -2
- package/lib/stats/index.js +1 -1
- package/lib/subscriber-configs.js +2 -0
- 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 +695 -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 +20 -0
- package/lib/subscribers/amqplib/utils.js +53 -0
- package/lib/subscribers/application-logs.js +1 -1
- package/lib/subscribers/base.js +67 -1
- 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 +2 -4
- package/lib/subscribers/db-query.js +5 -1
- 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 +9 -11
- package/lib/subscribers/propagation.js +43 -0
- package/lib/timer.js +1 -1
- package/lib/transaction/dt-payload.js +1 -1
- package/lib/transaction/handle.js +8 -9
- package/lib/transaction/name-state.js +11 -11
- package/lib/transaction/trace/segment.js +2 -3
- 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/logger.js +6 -6
- package/lib/util/stream-sink.js +1 -1
- package/lib/utilization/docker-info.js +4 -3
- package/lib/w3c/traceparent.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
|
@@ -25,7 +25,7 @@ const channels = [
|
|
|
25
25
|
* Subscribes to all relevant undici hook points
|
|
26
26
|
* See: https://github.com/nodejs/undici/blob/main/docs/api/DiagnosticsChannel.md
|
|
27
27
|
*
|
|
28
|
-
* @param agent
|
|
28
|
+
* @param {Agent} agent instance
|
|
29
29
|
*/
|
|
30
30
|
module.exports = function addUndiciChannels(agent) {
|
|
31
31
|
channels.forEach(({ channel, hook }, index) => {
|
|
@@ -72,8 +72,8 @@ function addDTHeaders({ transaction, config, request }) {
|
|
|
72
72
|
*
|
|
73
73
|
* @param {object} params object to fn
|
|
74
74
|
* @param {Agent} params.agent NR agent instance
|
|
75
|
+
* @param {object} params.request undici request object
|
|
75
76
|
* @param {object} params.context active context
|
|
76
|
-
* @param params.request
|
|
77
77
|
*/
|
|
78
78
|
function createExternalSegment({ agent, request, context }) {
|
|
79
79
|
const url = new URL(request.origin + request.path)
|
|
@@ -155,7 +155,7 @@ function requestCreateHook(agent, { request }) {
|
|
|
155
155
|
* We will add the relevant http response attributes to active segment.
|
|
156
156
|
* Also add CAT specific keys to active segment.
|
|
157
157
|
*
|
|
158
|
-
* @param {
|
|
158
|
+
* @param {Agent} agent instance
|
|
159
159
|
* @param {object} params object from undici hook
|
|
160
160
|
* @param {object} params.response { statusCode, headers, statusText }
|
|
161
161
|
*/
|
package/lib/instrumentations.js
CHANGED
|
@@ -19,11 +19,9 @@ module.exports = function instrumentations() {
|
|
|
19
19
|
'@node-redis/client': { type: InstrumentationDescriptor.TYPE_DATASTORE },
|
|
20
20
|
'@prisma/client': { type: InstrumentationDescriptor.TYPE_DATASTORE },
|
|
21
21
|
'@redis/client': { type: InstrumentationDescriptor.TYPE_DATASTORE },
|
|
22
|
-
amqplib: { module: './instrumentation/amqplib' },
|
|
23
22
|
'aws-sdk': { module: './instrumentation/aws-sdk' },
|
|
24
23
|
bluebird: { type: InstrumentationDescriptor.TYPE_PROMISE },
|
|
25
24
|
bunyan: { type: InstrumentationDescriptor.TYPE_GENERIC },
|
|
26
|
-
'cassandra-driver': { type: InstrumentationDescriptor.TYPE_DATASTORE },
|
|
27
25
|
connect: { type: InstrumentationDescriptor.TYPE_WEB_FRAMEWORK },
|
|
28
26
|
express: { type: InstrumentationDescriptor.TYPE_WEB_FRAMEWORK },
|
|
29
27
|
fastify: { type: InstrumentationDescriptor.TYPE_WEB_FRAMEWORK },
|
|
@@ -34,10 +34,10 @@ class BedrockResponse {
|
|
|
34
34
|
#isConverse
|
|
35
35
|
|
|
36
36
|
/**
|
|
37
|
-
* @param {object} params
|
|
38
|
-
* @param {AwsBedrockMiddlewareResponse} params.response
|
|
39
|
-
* @param {BedrockCommand} params.bedrockCommand
|
|
40
|
-
* @param {boolean} params.isError
|
|
37
|
+
* @param {object} params params object
|
|
38
|
+
* @param {AwsBedrockMiddlewareResponse} params.response AWS Bedrock middleware response
|
|
39
|
+
* @param {BedrockCommand} params.bedrockCommand AWS Bedrock command
|
|
40
|
+
* @param {boolean} params.isError is there an error
|
|
41
41
|
*/
|
|
42
42
|
constructor({ response, bedrockCommand, isError = false }) {
|
|
43
43
|
this.#originalResponse = response
|
|
@@ -146,8 +146,8 @@ class BedrockResponse {
|
|
|
146
146
|
|
|
147
147
|
/**
|
|
148
148
|
* Extracts and sets #completions and #id from the InvokeModel response body.
|
|
149
|
-
* @param {BedrockCommand} cmd
|
|
150
|
-
* @param {*} body
|
|
149
|
+
* @param {BedrockCommand} cmd AWS Bedrock Command
|
|
150
|
+
* @param {*} body InvokeModel response body
|
|
151
151
|
*/
|
|
152
152
|
#extractCompletionsAndId(cmd, body) {
|
|
153
153
|
if (cmd.isClaude() === true) {
|
|
@@ -101,7 +101,7 @@ class ConverseStreamHandler {
|
|
|
101
101
|
* If the given event is the last event in the stream, update the response
|
|
102
102
|
* headers with the metrics data from the event.
|
|
103
103
|
*
|
|
104
|
-
* @param {object} parsedEvent
|
|
104
|
+
* @param {object} parsedEvent parsed stream event
|
|
105
105
|
*/
|
|
106
106
|
updateHeaders(parsedEvent) {
|
|
107
107
|
this.response.response.headers = {
|
|
@@ -145,8 +145,8 @@ class StreamHandler {
|
|
|
145
145
|
* Finds the reason for the end of the stream based upon the model's known
|
|
146
146
|
* stop reason key.
|
|
147
147
|
*
|
|
148
|
-
* @param {object} event
|
|
149
|
-
* @returns {string}
|
|
148
|
+
* @param {object} event stream event
|
|
149
|
+
* @returns {string} the stop reason
|
|
150
150
|
*/
|
|
151
151
|
getStopReason(event) {
|
|
152
152
|
if (this.stopReasonKey.includes('.')) {
|
|
@@ -164,7 +164,7 @@ class StreamHandler {
|
|
|
164
164
|
/**
|
|
165
165
|
* Decodes the Uint8Array that represents a model response.
|
|
166
166
|
*
|
|
167
|
-
* @param {object} event
|
|
167
|
+
* @param {object} event stream event
|
|
168
168
|
*
|
|
169
169
|
* @returns {object}
|
|
170
170
|
*/
|
|
@@ -177,7 +177,7 @@ class StreamHandler {
|
|
|
177
177
|
* If the given event is the last event in the stream, update the response
|
|
178
178
|
* headers with the metrics data from the event.
|
|
179
179
|
*
|
|
180
|
-
* @param {object} parsedEvent
|
|
180
|
+
* @param {object} parsedEvent the parsed stream event
|
|
181
181
|
*/
|
|
182
182
|
updateHeaders(parsedEvent) {
|
|
183
183
|
if (this.getStopReason(parsedEvent) === null) {
|
package/lib/metrics/index.js
CHANGED
|
@@ -44,7 +44,7 @@ const FROM_MILLIS = 1e-3
|
|
|
44
44
|
* @param {number} apdexT The apdex-tolerating value, for use in creating apdex
|
|
45
45
|
* statistics.
|
|
46
46
|
* @param {MetricMapper} mapper The mapper that turns metric names into IDs.
|
|
47
|
-
* @param normalizer
|
|
47
|
+
* @param {NameNormalizer} normalizer The normalizer that standardizes metric names.
|
|
48
48
|
*/
|
|
49
49
|
function Metrics(apdexT, mapper, normalizer) {
|
|
50
50
|
if (apdexT == null || apdexT === '') {
|
|
@@ -268,7 +268,7 @@ Metrics.prototype._getUnscopedData = function _getUnscopedData(name) {
|
|
|
268
268
|
* mappings along the way. Split from _getUnscopedData for performance.
|
|
269
269
|
*
|
|
270
270
|
* @param {string} name The string to look up.
|
|
271
|
-
* @param scope
|
|
271
|
+
* @param {string} scope The scope to map with.
|
|
272
272
|
*/
|
|
273
273
|
Metrics.prototype._getScopedData = function _getScopedData(name, scope) {
|
|
274
274
|
if (!this.scoped[scope][name]) {
|
|
@@ -10,7 +10,7 @@ const logger = require('../../logger').child({ component: 'normalizer_rule' })
|
|
|
10
10
|
/**
|
|
11
11
|
* JavaScript just has to do things slightly differently.
|
|
12
12
|
*
|
|
13
|
-
* @param input
|
|
13
|
+
* @param {string} input the input string
|
|
14
14
|
*/
|
|
15
15
|
const replaceReplacer = function replaceReplacer(input) {
|
|
16
16
|
return input.replace(/\\/g, '$')
|
|
@@ -48,7 +48,7 @@ function plain(normalized, path) {
|
|
|
48
48
|
* @param {object} config The agent's configuration blob, which has a parameter
|
|
49
49
|
* that indicates whether to enforce the normalization
|
|
50
50
|
* backstop.
|
|
51
|
-
* @param type
|
|
51
|
+
* @param {string} type The type of normalization to apply.
|
|
52
52
|
*/
|
|
53
53
|
function MetricNormalizer(config, type) {
|
|
54
54
|
if (!config) {
|
|
@@ -88,9 +88,8 @@ util.inherits(MetricNormalizer, EventEmitter)
|
|
|
88
88
|
* Convert the raw, de-serialized JSON response into a set of
|
|
89
89
|
* NormalizationRules.
|
|
90
90
|
*
|
|
91
|
-
* @param object json The de-serialized JSON response sent on collector
|
|
91
|
+
* @param {object} json The de-serialized JSON response sent on collector
|
|
92
92
|
* connection.
|
|
93
|
-
* @param json
|
|
94
93
|
*/
|
|
95
94
|
MetricNormalizer.prototype.load = function load(json) {
|
|
96
95
|
if (json) {
|
|
@@ -118,8 +117,8 @@ MetricNormalizer.prototype.load = function load(json) {
|
|
|
118
117
|
/**
|
|
119
118
|
* Helper for loadFromConfig
|
|
120
119
|
*
|
|
121
|
-
* @param
|
|
122
|
-
* @param
|
|
120
|
+
* @param {object} rule from this.config.rules
|
|
121
|
+
* @param {object} ctx context from the calling function
|
|
123
122
|
*/
|
|
124
123
|
function processNameRule(rule, ctx) {
|
|
125
124
|
if (!rule.pattern) {
|
|
@@ -8,9 +8,9 @@
|
|
|
8
8
|
const NAMES = require('../../metrics/names.js')
|
|
9
9
|
|
|
10
10
|
/**
|
|
11
|
-
* @param {TraceSegment} segment
|
|
12
|
-
* @param {object} scope
|
|
13
|
-
* @param {Transaction} tx
|
|
11
|
+
* @param {TraceSegment} segment segment
|
|
12
|
+
* @param {object} [scope] scope
|
|
13
|
+
* @param {Transaction} tx transaction
|
|
14
14
|
*/
|
|
15
15
|
function recordMessageTransaction(segment, scope, tx) {
|
|
16
16
|
if (tx.type !== 'message' || tx.baseSegment !== segment) {
|
|
@@ -31,10 +31,10 @@ class ContextManager {
|
|
|
31
31
|
* Runs the callback within the provided context, optionally
|
|
32
32
|
* bound with a provided `this`.
|
|
33
33
|
*
|
|
34
|
-
* @param context
|
|
35
|
-
* @param callback
|
|
36
|
-
* @param thisRef
|
|
37
|
-
* @param args
|
|
34
|
+
* @param {Object} context context
|
|
35
|
+
* @param {function} callback callback
|
|
36
|
+
* @param {Object} thisRef `this` reference
|
|
37
|
+
* @param {...any} args arguments
|
|
38
38
|
*/
|
|
39
39
|
with(context, callback, thisRef, ...args) {
|
|
40
40
|
return this.#ctxMgr.runInContext(context, callback, thisRef, args)
|
|
@@ -25,7 +25,7 @@ class TraceState {
|
|
|
25
25
|
|
|
26
26
|
/**
|
|
27
27
|
* Parses information from the [traceparent] span tag and converts it into {@link SpanContext}
|
|
28
|
-
* @param traceParent - A meta property that comes from server.
|
|
28
|
+
* @param {string} traceParent - A meta property that comes from server.
|
|
29
29
|
* It should be dynamically generated server side to have the server's request trace Id,
|
|
30
30
|
* a parent span Id that was set on the server's request span,
|
|
31
31
|
* and the trace flags to indicate the server's sampling decision
|
|
@@ -139,8 +139,8 @@ class PrioritizedAttributes {
|
|
|
139
139
|
* Returns true if a given key is valid for any of the
|
|
140
140
|
* provided destinations.
|
|
141
141
|
*
|
|
142
|
-
* @param {DESTINATIONS} destinations
|
|
143
|
-
* @param {string} key
|
|
142
|
+
* @param {DESTINATIONS} destinations destinations to check against
|
|
143
|
+
* @param {string} key key to check
|
|
144
144
|
*/
|
|
145
145
|
hasValidDestination(destinations, key) {
|
|
146
146
|
const validDestinations = this.filter(destinations, key)
|
|
@@ -105,8 +105,8 @@ class AwsLambda {
|
|
|
105
105
|
/**
|
|
106
106
|
* Response-streaming handlers are identified by symbol properties on the function.
|
|
107
107
|
* We propagate any symbols if they're present, so that the handler keeps its signatue for any AWS features that rely on symbols
|
|
108
|
-
* @param handler
|
|
109
|
-
* @param nrHandler
|
|
108
|
+
* @param {Object} handler original handler
|
|
109
|
+
* @param {Object} nrHandler our copy of the handler
|
|
110
110
|
*/
|
|
111
111
|
propagateSymbols(handler, nrHandler) {
|
|
112
112
|
for (const symbol of Object.getOwnPropertySymbols(handler)) {
|
|
@@ -191,7 +191,7 @@ class AwsLambda {
|
|
|
191
191
|
* **Note**: AWS doesn't support response streaming with API gateway invoked lambdas.
|
|
192
192
|
* This means we do not handle that as it would require intercepting the stream to parse
|
|
193
193
|
* the response code and headers.
|
|
194
|
-
* @param {...any} args
|
|
194
|
+
* @param {...any} args Original arguments
|
|
195
195
|
*/
|
|
196
196
|
function wrappedStreamHandler(...args) {
|
|
197
197
|
const transaction = shim.tracer.getTransaction()
|
|
@@ -229,7 +229,7 @@ class AwsLambda {
|
|
|
229
229
|
* adds handlers if api gateway to wrap request/response
|
|
230
230
|
* wraps the callback(if present), wraps the context `done`, `succeed`, `fail methods`, intercepts promise
|
|
231
231
|
* and properly ends transaction
|
|
232
|
-
* @param {...any} args
|
|
232
|
+
* @param {...any} args Original arguments
|
|
233
233
|
*/
|
|
234
234
|
function wrappedHandler(...args) {
|
|
235
235
|
const transaction = shim.tracer.getTransaction()
|
|
@@ -500,7 +500,7 @@ function captureInstanceAttributes(host, port, database) {
|
|
|
500
500
|
/**
|
|
501
501
|
* Parses the database name from a `USE` SQL query.
|
|
502
502
|
*
|
|
503
|
-
* @
|
|
503
|
+
* @this DatastoreShim
|
|
504
504
|
* @param {string} query - The SQL query to parse the database name from.
|
|
505
505
|
* @returns {?string} The name of the database if it could be parsed, otherwise
|
|
506
506
|
* `null`.
|
|
@@ -49,7 +49,7 @@ function updateSpecFromArgs({ shim, fn, fnName, args, spec, ctx }) {
|
|
|
49
49
|
* @param {MessageShim} params.shim instance of shim
|
|
50
50
|
* @param {Function} params.fn function that is being wrapped
|
|
51
51
|
* @param {string} params.fnName name of function
|
|
52
|
-
* @param params.args
|
|
52
|
+
* @param {Array} params.args arguments passed to original consume function
|
|
53
53
|
* @param {specs.MessageSpec} params.spec spec for the wrapped consume function
|
|
54
54
|
* @returns {specs.MessageSpec} updated spec with logic to name segment and apply the genericRecorder
|
|
55
55
|
*/
|
|
@@ -37,8 +37,7 @@ function _nameMessageTransaction(shim, msgDesc) {
|
|
|
37
37
|
* @param {MessageShim} params.shim instance of shim
|
|
38
38
|
* @param {Function} params.fn subscriber function
|
|
39
39
|
* @param {specs.MessageSubscribeSpec} params.spec spec for subscriber
|
|
40
|
-
* @param params.name
|
|
41
|
-
* @param {boolean} params.destNameIsArg flag to state if destination is an argument
|
|
40
|
+
* @param {string} params.name function name
|
|
42
41
|
* @returns {Function} wrapped subscribe function
|
|
43
42
|
*/
|
|
44
43
|
function createSubscriberWrapper({ shim, fn, spec, name }) {
|
package/lib/shim/promise-shim.js
CHANGED
|
@@ -366,9 +366,7 @@ function _wrapExecutorContext(shim, args) {
|
|
|
366
366
|
|
|
367
367
|
/**
|
|
368
368
|
*
|
|
369
|
-
* @param {
|
|
370
|
-
* @param {Function} reject function of promise
|
|
371
|
-
* @param {...any} args
|
|
369
|
+
* @param {Object} args contains the `resolve` and `reject` functions of a promise
|
|
372
370
|
*/
|
|
373
371
|
function contextExporter(...args) {
|
|
374
372
|
const [resolve, reject] = args
|
package/lib/shim/shim.js
CHANGED
|
@@ -1453,8 +1453,7 @@ function isPromise(obj) {
|
|
|
1453
1453
|
* promise or async function
|
|
1454
1454
|
*
|
|
1455
1455
|
* @memberof Shim.prototype
|
|
1456
|
-
* @param fn
|
|
1457
|
-
* @param (function) function to test if async
|
|
1456
|
+
* @param {function} fn function to test if async
|
|
1458
1457
|
* @returns {boolean} True if the function is an async function
|
|
1459
1458
|
*/
|
|
1460
1459
|
function isAsyncFunction(fn) {
|
|
@@ -1871,8 +1870,8 @@ function _makeBindWrapper(shim, func, context, full) {
|
|
|
1871
1870
|
* (i.e. `bindRowCallbackSegment` for `rowCallback`), but will fall back to the
|
|
1872
1871
|
* generic callback binding method, `bindCallbackSegment`, otherwise.
|
|
1873
1872
|
*
|
|
1874
|
-
* @this *
|
|
1875
1873
|
* @private
|
|
1874
|
+
* @this *
|
|
1876
1875
|
* @param {Shim} shim
|
|
1877
1876
|
* The shim performing this binding.
|
|
1878
1877
|
* @param {Function} fn
|
|
@@ -2129,7 +2128,7 @@ function _es5WrapClass(shim, Base, fnName, spec, args) {
|
|
|
2129
2128
|
/**
|
|
2130
2129
|
* Wraps the es5 class in a function
|
|
2131
2130
|
*
|
|
2132
|
-
* @param {...any} cnstrctArgs
|
|
2131
|
+
* @param {...any} cnstrctArgs class constructor arguments
|
|
2133
2132
|
* @returns {Function|undefined} a function if not already wrapped in WrappedClass
|
|
2134
2133
|
*/
|
|
2135
2134
|
function WrappedClass(...cnstrctArgs) {
|
|
@@ -19,7 +19,6 @@ const TRANSACTION_TYPES_SET = Transaction.TYPES_SET
|
|
|
19
19
|
* @class
|
|
20
20
|
* @augments Shim
|
|
21
21
|
* @classdesc
|
|
22
|
-
* @param shimName
|
|
23
22
|
* A helper class for working with transactions.
|
|
24
23
|
* @param {Agent} agent - The agent the shim will use.
|
|
25
24
|
* @param {string} moduleName - The name of the module being instrumented.
|
|
@@ -46,8 +46,6 @@ common.getTransactionInfo = function getTransactionInfo(shim, req) {
|
|
|
46
46
|
* Adds the given error to the transaction information if it is actually an error.
|
|
47
47
|
*
|
|
48
48
|
* @private
|
|
49
|
-
* @param {WebFrameworkShim} shim
|
|
50
|
-
* The shim used for this web framework.
|
|
51
49
|
* @param {TransactionInfo} txInfo
|
|
52
50
|
* The transaction context information for the request.
|
|
53
51
|
* @param {*} err
|
|
@@ -73,8 +71,8 @@ common.isError = function isError(shim, err) {
|
|
|
73
71
|
}
|
|
74
72
|
|
|
75
73
|
/**
|
|
76
|
-
* @param shim
|
|
77
|
-
* @param req
|
|
74
|
+
* @param {Object} shim instance
|
|
75
|
+
* @param {Object} req request
|
|
78
76
|
*/
|
|
79
77
|
common.makeGetReq = function makeGetReq(shim, req) {
|
|
80
78
|
return function getReqFromArgs(shim, fn, name, args) {
|
|
@@ -331,14 +331,14 @@ module.exports._recordMiddleware = function _recordMiddleware(shim, middleware,
|
|
|
331
331
|
* push the name state if there is a next so that we can safely remove it
|
|
332
332
|
* if context leaves this middleware.
|
|
333
333
|
*
|
|
334
|
-
* @param
|
|
335
|
-
* @param
|
|
336
|
-
* @param
|
|
337
|
-
* @param
|
|
338
|
-
* @param
|
|
339
|
-
* @param
|
|
340
|
-
* @param
|
|
341
|
-
* @param
|
|
334
|
+
* @param {Object} params params object
|
|
335
|
+
* @param {Shim} params.shim shim instance
|
|
336
|
+
* @param {Object} params.spec middleware spec, should contain a next function
|
|
337
|
+
* @param {string} params.route route
|
|
338
|
+
* @param {Array} params.args arguments
|
|
339
|
+
* @param {boolean} params.isErrorWare is this error ware
|
|
340
|
+
* @param {boolean} params.isPromise is this a promise
|
|
341
|
+
* @param {Object} params.txInfo transaction information
|
|
342
342
|
* @private
|
|
343
343
|
*/
|
|
344
344
|
function wrapNextHandler({ shim, spec, route, args, isErrorWare, isPromise, txInfo }) {
|
|
@@ -87,7 +87,7 @@ class SpanEventAggregator extends EventAggregator {
|
|
|
87
87
|
/**
|
|
88
88
|
* Reconfigure the `SpanEventAggregator` based on values from server
|
|
89
89
|
*
|
|
90
|
-
* @param {Config} config
|
|
90
|
+
* @param {Config} config the config to reconfigure with
|
|
91
91
|
*/
|
|
92
92
|
reconfigure(config) {
|
|
93
93
|
super.reconfigure(config)
|
|
@@ -105,7 +105,7 @@ class SpanEventAggregator extends EventAggregator {
|
|
|
105
105
|
* When no `span_event_harvest_config` has been received from the server, applies an
|
|
106
106
|
* agent-defined fallback maximum to protect against collecting and sending too many spans.
|
|
107
107
|
*
|
|
108
|
-
* @param {Config} config
|
|
108
|
+
* @param {Config} config the config to check
|
|
109
109
|
*/
|
|
110
110
|
_getValidSpanConfiguration(config) {
|
|
111
111
|
const spanHarvestConfig = config.span_event_harvest_config
|
package/lib/spans/span-event.js
CHANGED
|
@@ -89,11 +89,12 @@ class SpanEvent {
|
|
|
89
89
|
* The constructed span event will contain extra data depending on the
|
|
90
90
|
* category of the segment.
|
|
91
91
|
*
|
|
92
|
-
* @param {
|
|
93
|
-
* @param {
|
|
94
|
-
* @param {
|
|
95
|
-
* @param {
|
|
96
|
-
* @param {boolean}
|
|
92
|
+
* @param {Object} params params object
|
|
93
|
+
* @param {TraceSegment} params.segment segment to turn into a span event.
|
|
94
|
+
* @param {Transaction} params.transaction active transaction
|
|
95
|
+
* @param {?string} [params.parentId] ID of the segment's parent.
|
|
96
|
+
* @param {boolean} [params.isRoot] if segment is root segment; defaults to `false`
|
|
97
|
+
* @param {boolean} params.inProcessSpans if the segment is in-process, create span
|
|
97
98
|
* @returns {SpanEvent} The constructed event.
|
|
98
99
|
*/
|
|
99
100
|
static fromSegment({ segment, transaction, parentId = null, isRoot = false, inProcessSpans }) {
|
|
@@ -46,7 +46,7 @@ class StreamingSpanAttributes {
|
|
|
46
46
|
*
|
|
47
47
|
* Does not apply filtering/truncation.
|
|
48
48
|
*
|
|
49
|
-
* @param {object} [attributes]
|
|
49
|
+
* @param {object} [attributes] Attributes to add.
|
|
50
50
|
* @param {string} [attributes.key] Name of the attribute to be stored.
|
|
51
51
|
* @param {string|boolean|number} [attributes.value] Value of the attribute to be stored.
|
|
52
52
|
*/
|
|
@@ -101,10 +101,9 @@ class StreamingSpanEventAggregator extends Aggregator {
|
|
|
101
101
|
*
|
|
102
102
|
* @param {object} params to function
|
|
103
103
|
* @param {TraceSegment} params.segment segment to add.
|
|
104
|
-
* @param {string} [parms.parentId] GUID of the parent span.
|
|
105
104
|
* @param {Transaction} params.transaction active transaction
|
|
105
|
+
* @param {string} [params.parentId] GUID of the parent span.
|
|
106
106
|
* @param {boolean} params.isRoot is segment root segment
|
|
107
|
-
* @param params.parentId
|
|
108
107
|
* @returns {boolean} True if the segment was added, or false if it was discarded.
|
|
109
108
|
*/
|
|
110
109
|
addSegment({ segment, transaction, parentId, isRoot }) {
|
package/lib/stats/index.js
CHANGED
|
@@ -84,7 +84,7 @@ Stats.prototype.incrementCallCount = function incrementCallCount(count) {
|
|
|
84
84
|
/**
|
|
85
85
|
* Fold another summary's statistics into this one.
|
|
86
86
|
*
|
|
87
|
-
* @param other
|
|
87
|
+
* @param {Stats} other other Stats instance
|
|
88
88
|
*/
|
|
89
89
|
Stats.prototype.merge = function merge(other) {
|
|
90
90
|
if (other.count && !other.callCount) {
|
|
@@ -8,6 +8,8 @@
|
|
|
8
8
|
// The expected export of these files is:
|
|
9
9
|
// 'package-name': [ { path: 'subscriberPath', instrumentations: [] }, ... ]
|
|
10
10
|
const subscribers = {
|
|
11
|
+
...require('./subscribers/amqplib/config'),
|
|
12
|
+
...require('./subscribers/cassandra-driver/config'),
|
|
11
13
|
...require('./subscribers/elasticsearch/config'),
|
|
12
14
|
...require('./subscribers/ioredis/config'),
|
|
13
15
|
...require('./subscribers/mcp-sdk/config'),
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright 2025 New Relic Corporation. All rights reserved.
|
|
3
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
const PropagationSubscriber = require('../propagation')
|
|
7
|
+
|
|
8
|
+
class AcceptMessageSubscriber extends PropagationSubscriber {
|
|
9
|
+
constructor({ agent, logger }) {
|
|
10
|
+
super({ agent, logger, packageName: 'amqplib', channelName: 'nr_acceptMessage', callback: 0 })
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
module.exports = AcceptMessageSubscriber
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright 2025 New Relic Corporation. All rights reserved.
|
|
3
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
const MetaSubscriber = require('../meta-subscriber')
|
|
7
|
+
const CHANNEL_METHODS = [
|
|
8
|
+
'cb_close',
|
|
9
|
+
'cb_open',
|
|
10
|
+
'cb_assertQueue',
|
|
11
|
+
'cb_checkQueue',
|
|
12
|
+
'cb_deleteQueue',
|
|
13
|
+
'cb_bindQueue',
|
|
14
|
+
'nr_unbindQueue',
|
|
15
|
+
'cb_assertExchange',
|
|
16
|
+
'cb_checkExchange',
|
|
17
|
+
'cb_deleteExchange',
|
|
18
|
+
'cb_bindExchange',
|
|
19
|
+
'cb_unbindExchange',
|
|
20
|
+
'cb_cancel',
|
|
21
|
+
'cb_prefetch',
|
|
22
|
+
'cb_recover'
|
|
23
|
+
]
|
|
24
|
+
|
|
25
|
+
class ChannelModelSubscriber extends MetaSubscriber {
|
|
26
|
+
constructor({ agent, logger }) {
|
|
27
|
+
super({ agent, logger, packageName: 'amqplib', channelName: 'channelModel', channels: CHANNEL_METHODS, events: ['asyncEnd'], callback: -1 })
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
handler(_data, ctx) {
|
|
31
|
+
const [, name] = this.channelName.split('_')
|
|
32
|
+
return this.createSegment({
|
|
33
|
+
name: `Channel#${name}`,
|
|
34
|
+
ctx
|
|
35
|
+
})
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
module.exports = ChannelModelSubscriber
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright 2025 New Relic Corporation. All rights reserved.
|
|
3
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
const MetaSubscriber = require('../meta-subscriber')
|
|
7
|
+
const CHANNEL_METHODS = [
|
|
8
|
+
'nr_close',
|
|
9
|
+
'nr_open',
|
|
10
|
+
'nr_assertQueue',
|
|
11
|
+
'nr_checkQueue',
|
|
12
|
+
'nr_deleteQueue',
|
|
13
|
+
'nr_bindQueue',
|
|
14
|
+
'nr_unbindQueue',
|
|
15
|
+
'nr_assertExchange',
|
|
16
|
+
'nr_checkExchange',
|
|
17
|
+
'nr_deleteExchange',
|
|
18
|
+
'nr_bindExchange',
|
|
19
|
+
'nr_unbindExchange',
|
|
20
|
+
'nr_cancel',
|
|
21
|
+
'nr_prefetch',
|
|
22
|
+
'nr_recover'
|
|
23
|
+
]
|
|
24
|
+
|
|
25
|
+
class ChannelModelSubscriber extends MetaSubscriber {
|
|
26
|
+
constructor({ agent, logger }) {
|
|
27
|
+
super({ agent, logger, packageName: 'amqplib', channelName: 'channelModel', channels: CHANNEL_METHODS, events: ['asyncEnd'] })
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
handler(data, ctx) {
|
|
31
|
+
const [, name] = this.channelName.split('_')
|
|
32
|
+
return this.createSegment({
|
|
33
|
+
name: `Channel#${name}`,
|
|
34
|
+
ctx
|
|
35
|
+
})
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
module.exports = ChannelModelSubscriber
|