newrelic 7.0.1 → 7.0.2

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 CHANGED
@@ -1,4 +1,10 @@
1
- ### 7.0.1 (2020-11-07):
1
+ ### 7.0.2 (2020-12-01):
2
+
3
+ * Fixes a bug where the `http.statusCode` attribute was not being captured for an async invoked lambda.
4
+ * Fixed typos in code comments, documentation, and debugging logger messages.
5
+ Thank you @TysonAndre for the contribution.
6
+
7
+ ### 7.0.1 (2020-11-17):
2
8
 
3
9
  * Fixed a bug where spans queued up during backpressure situations would be improperly formatted and ultimately dropped when sent to an Infinite Tracing trace observer.
4
10
  * Updated @grpc/grpc-js to version v1.2.0.
@@ -336,7 +342,7 @@ Special thanks to Ryan Copley (@RyanCopley) for the contribution.
336
342
  object from API#getLinkingMetadata().
337
343
 
338
344
  This issue would cause the `@newrelic/winston-enricher` module to crash when
339
- attempting to inject log metatdata.
345
+ attempting to inject log metadata.
340
346
 
341
347
  * Reduced logging level of raw `x-queue-start` or `x-request-start` header values
342
348
  to avoid logging very large values at default logging levels.
@@ -3288,7 +3294,7 @@ Special thanks to Ryan Copley (@RyanCopley) for the contribution.
3288
3294
 
3289
3295
  * Fixed a bug where custom events weren't being sent.
3290
3296
 
3291
- In a refactor of our data collection cycle, we omited the custom
3297
+ In a refactor of our data collection cycle, we omitted the custom
3292
3298
  events from the list of commands, this is now fixed.
3293
3299
 
3294
3300
  * Fixed a very rare bug where the custom event pool could be set to 10
@@ -3512,7 +3518,7 @@ Special thanks to Ryan Copley (@RyanCopley) for the contribution.
3512
3518
  ended when the view ended.
3513
3519
 
3514
3520
  * Added a configuration option to completely disable logging. `logger.enabled`
3515
- defaults to true, if set to false it wont try to create the log file.
3521
+ defaults to true, if set to false it won't try to create the log file.
3516
3522
 
3517
3523
  ### v1.16.2 (2015-02-13):
3518
3524
 
@@ -4283,7 +4289,7 @@ Special thanks to Ryan Copley (@RyanCopley) for the contribution.
4283
4289
  too many times. Thanks to José F. Romaniello for confirming the fix.
4284
4290
  * Changed how requests handled by Express and Restify routes are named. This
4285
4291
  change is being rolled out both in this module and on the New Relic website,
4286
- so there is a chance you will see the same route (or very similiar routes)
4292
+ so there is a chance you will see the same route (or very similar routes)
4287
4293
  show up twice in aggregated metrics.
4288
4294
  * Dropped the default apdex tolerating value from 500 milliseconds to 100
4289
4295
  milliseconds. This means that transactions slower than 400 milliseconds will
@@ -4520,7 +4526,7 @@ Special thanks to Ryan Copley (@RyanCopley) for the contribution.
4520
4526
  crash.
4521
4527
  * Some metric normalization rules were not being interpreted correctly, leading
4522
4528
  to malformed normalized metric names.
4523
- * Metric normalization rules that specifed that matching metrics were to be
4529
+ * Metric normalization rules that specified that matching metrics were to be
4524
4530
  ignored were not being enforced.
4525
4531
 
4526
4532
  ### v0.9.12-91 / beta-12 (2012-12-28):
package/ROADMAP_Node.md CHANGED
@@ -15,7 +15,7 @@ This roadmap project is broken down into the following sections:
15
15
  - **Next**:
16
16
  - This section contains work planned within the next three months. These features may still be deprioritized and moved to Future.
17
17
  - **Future**:
18
- - This section is for ideas for future work that is alined with the product vision and possible opportunities for community contribution. It contains a list of features that anyone can implement. No guarantees can be provided on if or when these features will be completed.
18
+ - This section is for ideas for future work that is aligned with the product vision and possible opportunities for community contribution. It contains a list of features that anyone can implement. No guarantees can be provided on if or when these features will be completed.
19
19
 
20
20
 
21
21
  **The roadmap project is found [here](https://github.com/orgs/newrelic/projects/11)**
@@ -511,12 +511,12 @@ CollectorAPI.prototype._sendData = function _sendData(method, data, callback) {
511
511
  if (response.agentRun === AGENT_RUN_BEHAVIOR.SHUTDOWN) {
512
512
  // TODO: for now, shut handled in _handleResponseCode for consistency
513
513
  // either find way to safely change while side-by-side or move
514
- // once side-by-side gone. Currently, stop is called twice on teh old code path
514
+ // once side-by-side gone. Currently, stop is called twice on the old code path
515
515
 
516
516
  // TODO: almost seems better to let aggregator finish (cb) then shutdown?
517
517
 
518
518
  // this._agent.stop((err) => {
519
- // // TODO: agent stop requires a callback. if we don't care to do anythig here
519
+ // // TODO: agent stop requires a callback. if we don't care to do anything here
520
520
  // // do we loosen that requirement or perhaps have a different "shutdown"
521
521
  // // method? Does seem like you'd want to log a shutdown error
522
522
  // // but don't really care about that *here*
@@ -42,7 +42,7 @@ exports.keepAliveAgent = function keepAliveAgent(config) {
42
42
  * NPM package with configuration suitable for working via
43
43
  * the configured newrelic-agent's proxy configuration.
44
44
  *
45
- * Include keep-alive configuration, but ultimatly its up
45
+ * Include keep-alive configuration, but ultimately its up
46
46
  * to the proxy server as to how its connection is made
47
47
  * with New Relic's servers.
48
48
  */
@@ -190,7 +190,7 @@ RemoteMethod.prototype._safeRequest = function _safeRequest(options) {
190
190
  throw new Error('Maximum payload size exceeded')
191
191
  }
192
192
 
193
- // If trace level is not explicity enabled check to see if the audit log is
193
+ // If trace level is not explicitly enabled check to see if the audit log is
194
194
  // enabled.
195
195
  if (logConfig != null && logConfig.level !== 'trace' && auditLog.enabled) {
196
196
  // If the filter property is empty, then always log the event otherwise
@@ -145,7 +145,7 @@ AttributeFilter.prototype._filter = function _filter(scope, destinations, key) {
145
145
  var globalInclude = null
146
146
  var globalExclude = null
147
147
 
148
- // Iterate over each desination and see if the rules apply.
148
+ // Iterate over each destination and see if the rules apply.
149
149
  for (var i = 0; i < scope.length; ++i) {
150
150
  var dest = scope[i]
151
151
  var destId = dest.id
@@ -231,7 +231,7 @@ exports.config = () => ({
231
231
  enabled: false,
232
232
 
233
233
  /**
234
- * Specify which methods are logged. Used in conjuction with the audit_log flag
234
+ * Specify which methods are logged. Used in conjunction with the audit_log flag
235
235
  * If audit_log is enabled and this property is empty, all methods will be logged
236
236
  * Otherwise, if the audit log is enabled, only the methods specified
237
237
  * in the filter will be logged
@@ -340,7 +340,7 @@ exports.config = () => ({
340
340
  detect_aws: true,
341
341
  /**
342
342
  * This flag dictates whether the agent attempts to detect if the
343
- * the process is running on Pivotal Cloud Foundary.
343
+ * the process is running on Pivotal Cloud Foundry.
344
344
  *
345
345
  * @env NEW_RELIC_UTILIZATION_DETECT_PCF
346
346
  */
@@ -846,7 +846,7 @@ exports.config = () => ({
846
846
  enabled: false,
847
847
 
848
848
  /**
849
- * Exludes New Relic format distributed tracing header (`newrelic`) on
849
+ * Excludes New Relic format distributed tracing header (`newrelic`) on
850
850
  * outbound requests when set to `true`. By default (when false)
851
851
  * both W3C TraceContext (`traceparent`, `tracecontext`) and
852
852
  * New Relic formats will be sent.
@@ -1460,7 +1460,7 @@ Config.prototype.applyLasp = function applyLasp(agent, policies) {
1460
1460
  var localVal = settingBlock[valueName]
1461
1461
 
1462
1462
  // Indexes into "allowed values" based on "enabled" setting
1463
- // to retreive proper mapping.
1463
+ // to retrieve proper mapping.
1464
1464
  var policyValues = localMapping.allowedValues
1465
1465
  var policyValue = policyValues[policy.enabled ? 1 : 0]
1466
1466
 
@@ -1602,7 +1602,7 @@ Config.prototype.getAggregatorConfig = function getAggregatorConfig(method) {
1602
1602
  * 5. If this module is installed as a dependency, the directory above the
1603
1603
  * node_modules folder in which newrelic is installed.
1604
1604
  *
1605
- * For configration via environment (useful on Joyent, Azure, Heroku, or
1605
+ * For configuration via environment (useful on Joyent, Azure, Heroku, or
1606
1606
  * other PaaS offerings), set NEW_RELIC_NO_CONFIG_FILE to something truthy
1607
1607
  * and read README.md for details on what configuration variables are
1608
1608
  * necessary, as well as a complete enumeration of the other available
@@ -22,7 +22,7 @@ var OPERATIONS = [
22
22
  ]
23
23
  var COMMENT_PATTERN = /\/\\*.*?\\*\//
24
24
 
25
- // This must be called syncronously after the initial db call for backtraces to
25
+ // This must be called synchronously after the initial db call for backtraces to
26
26
  // work correctly
27
27
 
28
28
  module.exports = function parseSql(type, sql) {
@@ -24,7 +24,7 @@ var OPERATIONS = [
24
24
  ]
25
25
  var COMMENT_PATTERN = /\/\\*.*?\\*\//g
26
26
 
27
- // This must be called syncronously after the initial db call for backtraces to
27
+ // This must be called synchronously after the initial db call for backtraces to
28
28
  // work correctly
29
29
 
30
30
  module.exports = function parseSql(sql) {
@@ -38,7 +38,7 @@ class GrpcConnection extends EventEmitter {
38
38
  /**
39
39
  * GrpcConnection constructor
40
40
  *
41
- * Standard property setting/initilization, and sets an initial
41
+ * Standard property setting/initialization, and sets an initial
42
42
  * connection state of disconnected
43
43
  *
44
44
  * @param {Object} traceObserverConfig config item config.infinite_tracing.trace_observer
@@ -290,7 +290,7 @@ class GrpcConnection extends EventEmitter {
290
290
  _generateCredentials(grpcApi) {
291
291
  let certBuffer = null
292
292
 
293
- // Current settable value for testing. If allowed to be overriden via
293
+ // Current settable value for testing. If allowed to be overridden via
294
294
  // configuration, this should be removed in place of setting
295
295
  // this._rootCerts from config via normal configuration precedence.
296
296
  const envTestCerts = process.env.NEWRELIC_GRPCCONNECTION_CA
@@ -177,7 +177,7 @@ function wrapEmitWithTransaction(agent, emit, isHTTPS) {
177
177
  'http.statusCode',
178
178
  responseCode
179
179
  )
180
-
180
+
181
181
  segment.addSpanAttribute('http.statusCode', responseCode)
182
182
  }
183
183
  }
@@ -267,7 +267,7 @@ function wrapResponseEnd(agent, proto) {
267
267
  return end.apply(this, arguments)
268
268
  }
269
269
 
270
- // If an error happend, add it to the aggregator.
270
+ // If an error happened, add it to the aggregator.
271
271
  if (txInfo.error) {
272
272
  if (!txInfo.errorHandled || urltils.isError(agent.config, this.statusCode)) {
273
273
  agent.errors.add(txInfo.transaction, txInfo.error)
@@ -291,7 +291,7 @@ function wrapResponseEnd(agent, proto) {
291
291
  })
292
292
  }
293
293
 
294
- // CAT this wont be used unless CAT is enabled, see below where we actually do
294
+ // CAT this won't be used unless CAT is enabled, see below where we actually do
295
295
  // the shimmer stuff if you'd like to verify.
296
296
  function wrapWriteHead(agent, writeHead) {
297
297
  return function wrappedWriteHead() {
@@ -59,7 +59,7 @@ function buildMiddlewareSpecForRouteHandler(shim, path) {
59
59
  * then this method is required/useful again.
60
60
  *
61
61
  * The isFinal param determines whether or not a path is appended for
62
- * this particuar piece of middleware. (i.e. if this is the final handler
62
+ * this particular piece of middleware. (i.e. if this is the final handler
63
63
  * that is actually handling the request, the path is actually left on)
64
64
  */
65
65
  next: function wrapNext(shim, fn, fnName, args, bindSegment) {
@@ -22,7 +22,7 @@ function parseProcCPUInfo(data) {
22
22
  packages: null
23
23
  }
24
24
 
25
- // seperate the processors
25
+ // separate the processors
26
26
  var splitData = data.split('\n')
27
27
  .map(function formatAttribute(attr) {
28
28
  return attr.split(':')
package/lib/proxy/grpc.js CHANGED
@@ -8,7 +8,7 @@ class ProxyGrpc {
8
8
  constructor(grpcLibrary = '@grpc/grpc-js') {
9
9
  this.library = require(grpcLibrary)
10
10
 
11
- // add methods or objets from base grpc class that we need as needed
11
+ // add methods or objects from base grpc class that we need as needed
12
12
  this.credentials = this.library.credentials
13
13
  this.Metadata = this.library.Metadata
14
14
  this.loadPackageDefinition = this.library.loadPackageDefinition
@@ -129,7 +129,6 @@ class AwsLambda {
129
129
  const segmentRecorder = isApiGatewayLambdaProxy ? recordWeb : recordBackground
130
130
  const segment = shim.createSegment(functionName, segmentRecorder)
131
131
  transaction.baseSegment = segment
132
-
133
132
  // resultProcessor is used to execute additional logic based on the
134
133
  // payload supplied to the callback.
135
134
  let resultProcessor
@@ -180,7 +179,6 @@ class AwsLambda {
180
179
  shim.agent.setLambdaArn(context.invokedFunctionArn)
181
180
 
182
181
  shim.agent.setLambdaFunctionVersion(context.functionVersion)
183
-
184
182
  segment.addSpanAttributes(awsAttributes)
185
183
 
186
184
  segment.start()
@@ -194,7 +192,7 @@ class AwsLambda {
194
192
  throw err
195
193
  }
196
194
  if (shim.isPromise(res)) {
197
- res = lambdaInterceptPromise(res, txnEnder)
195
+ res = lambdaInterceptPromise(res, resultProcessor, txnEnder)
198
196
  }
199
197
  return res
200
198
  }
@@ -202,8 +200,11 @@ class AwsLambda {
202
200
  // In order to capture error events
203
201
  // we need to store the error in uncaughtException
204
202
  // otherwise the transaction will end before they are captured
205
- function lambdaInterceptPromise(prom, cb) {
203
+ function lambdaInterceptPromise(prom, resultProcessor, cb) {
206
204
  return prom.then(function onThen(arg) {
205
+ if (resultProcessor) {
206
+ resultProcessor(arg)
207
+ }
207
208
  cb()
208
209
  return arg
209
210
  }, function onCatch(err) {
@@ -397,7 +398,10 @@ function setWebResponse(transaction, response) {
397
398
  responseCode
398
399
  )
399
400
 
400
- const segment = transaction.agent.tracer.getSegment()
401
+ // We are adding http.statusCode to base segment as
402
+ // we found in testing async invoked lambdas, the
403
+ // active segement is not available at this point.
404
+ const segment = transaction.baseSegment
401
405
 
402
406
  segment.addSpanAttribute('http.statusCode', responseCode)
403
407
  }
@@ -46,7 +46,7 @@ class PromiseShim extends Shim {
46
46
  }
47
47
 
48
48
  /**
49
- * Sets the class used to indentify promises from the wrapped promise library.
49
+ * Sets the class used to identify promises from the wrapped promise library.
50
50
  *
51
51
  * @param {function} clss - The promise library's class.
52
52
  */
package/lib/shim/shim.js CHANGED
@@ -308,7 +308,7 @@ Shim.prototype.__NR_unwrap = unwrapAll
308
308
  *
309
309
  * @description
310
310
  * The syntax for declarative instrumentation. It can be used interlaced with
311
- * custom, hand-written instrumentation for one-off or hard to simplifiy
311
+ * custom, hand-written instrumentation for one-off or hard to simplify
312
312
  * instrumentation logic.
313
313
  *
314
314
  * @property {Spec|WrapFunction} $return
@@ -1949,10 +1949,10 @@ function bindPromise(promise, segment) {
1949
1949
  * Copies the given parameters onto the segment, respecting the current agent
1950
1950
  * configuration.
1951
1951
  *
1952
- * @memberof Shim.protoype
1952
+ * @memberof Shim.prototype
1953
1953
  *
1954
1954
  * @param {TraceSegment} segment - The segment to copy the parameters onto.
1955
- * @param {object} parameters - The paramters to copy.
1955
+ * @param {object} parameters - The parameters to copy.
1956
1956
  */
1957
1957
  function copySegmentParameters(segment, parameters) {
1958
1958
  for (var key in parameters) {
@@ -184,7 +184,7 @@ function bindCreateTransaction(nodule, property, spec) {
184
184
  *
185
185
  * - `pushTransactionName(pathSegment)`
186
186
  *
187
- * Transactions are named for the middlware that sends the reponse. Some web
187
+ * Transactions are named for the middlware that sends the response. Some web
188
188
  * frameworks are capable of mounting middlware in complex routing stacks. In
189
189
  * order to maintain the correct name, transactions keep a stack of mount points
190
190
  * for each middlware/router/app/whatever. The instrumentation should push on
@@ -331,7 +331,7 @@ function setFramework(framework) {
331
331
  }
332
332
 
333
333
  /**
334
- * Sets the URI path to be used for naming the transaction currenty in scope.
334
+ * Sets the URI path to be used for naming the transaction currently in scope.
335
335
  *
336
336
  * @memberof WebFrameworkShim.prototype
337
337
  *
package/lib/shimmer.js CHANGED
@@ -381,7 +381,7 @@ var shimmer = module.exports = {
381
381
  * Forces file name resolve for modules not in our cache when
382
382
  * their parent has already been loaded/cached by Node.
383
383
  * Provides a fall-back for unexpected cases that may occur.
384
- * Also provides flexibilty for testing now that node 11+ caches these.
384
+ * Also provides flexibility for testing now that node 11+ caches these.
385
385
  * @param {*} request
386
386
  * @param {*} parent
387
387
  * @param {*} isMain
@@ -16,7 +16,7 @@ function createSpanEventAggregator(config, collector, metrics) {
16
16
  // TODO: ideally this validation and configuration clearing would happen
17
17
  // in the config. Since we don't currently have a way to generate
18
18
  // support metrics in the config, keeping this related logic together here.
19
- // If logic happened prior, could merely check for existance of trace_observer.host.
19
+ // If logic happened prior, could merely check for existence of trace_observer.host.
20
20
  shouldCreateStreaming = validateInfiniteTracing(config.infinite_tracing.trace_observer)
21
21
 
22
22
  if (!shouldCreateStreaming) {
package/lib/timer.js CHANGED
@@ -112,7 +112,7 @@ Timer.prototype.hasEnd = function hasEnd() {
112
112
  }
113
113
 
114
114
  /*
115
- * Sets duration and stops the timer, since the passed-in duration will take precendence
115
+ * Sets duration and stops the timer, since the passed-in duration will take precedence
116
116
  * over the measured duration.
117
117
  * @param {number} duration The duration the timer should report.
118
118
  */
@@ -12,7 +12,7 @@ const DT_VERSION_MINOR = 1
12
12
 
13
13
  module.exports = class DistributedTracePayload {
14
14
  /**
15
- * The class reponsible for producing distributed trace payloads.
15
+ * The class responsible for producing distributed trace payloads.
16
16
  * Created by calling {@link TransactionHandle#_createDistributedTracePayload}.
17
17
  *
18
18
  * @constructor
@@ -509,7 +509,7 @@ Transaction.prototype._markAsWeb = function _markAsWeb(rawURL) {
509
509
  * Sets the transaction's name and determines if it will be ignored.
510
510
  *
511
511
  * @param {string} [name]
512
- * Optional. The partial name to use for the finalized transaction. If ommitted
512
+ * Optional. The partial name to use for the finalized transaction. If omitted
513
513
  * the current partial name is used.
514
514
  */
515
515
  Transaction.prototype.finalizeName = function finalizeName(name) {
@@ -813,7 +813,7 @@ Transaction.prototype.hasOnlyExpectedErrors = function hasOnlyExpectedErrors() {
813
813
 
814
814
  for (let i = 0;i < this.exceptions.length;i++) {
815
815
  const exception = this.exceptions[i]
816
- // this expection is neither expected nor ignored
816
+ // this exception is neither expected nor ignored
817
817
  const isUnexpected = !(
818
818
  errorHelper.isExpectedException(
819
819
  this,
@@ -27,7 +27,7 @@ const FLAGS = {
27
27
  }
28
28
 
29
29
  /**
30
- * The class reponsible for accepting, validating, and producing w3c tracecontext headers.
30
+ * The class responsible for accepting, validating, and producing w3c tracecontext headers.
31
31
  */
32
32
  class TraceContext {
33
33
  /**
@@ -255,7 +255,7 @@ class TraceContext {
255
255
  return traceContextData
256
256
  }
257
257
 
258
- // Keep the raw, non-NewRelic tracestate string stored so that we can propogate it
258
+ // Keep the raw, non-NewRelic tracestate string stored so that we can propagate it
259
259
  this._traceStateRaw = parsedState.newTraceState
260
260
 
261
261
  // These need to be kept to be added to root span events as an attribute
@@ -55,7 +55,7 @@ function truncate(val, limit) {
55
55
 
56
56
  // Continue the binary search till:
57
57
  // 1) The string is the desired length (i.e. cmpVal = 0) OR
58
- // 2) The desired string must split a character to acheive the desired byte length
58
+ // 2) The desired string must split a character to achieve the desired byte length
59
59
  // In this case, we should cut the character that would be split.
60
60
  // (i.e. delta > 1 character OR the string is larger than the limit)
61
61
  var substr
@@ -81,7 +81,7 @@ exports.request = function request(opts, agent, cb) {
81
81
  return cb(new Error('Request for metadata failed.'))
82
82
  } else if (!data) {
83
83
  logger.debug('Got no response data?')
84
- return cb(new Error('No reponse data received.'))
84
+ return cb(new Error('No response data received.'))
85
85
  }
86
86
 
87
87
  cb(null, data.toString('utf8'))
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "newrelic",
3
- "version": "7.0.1",
3
+ "version": "7.0.2",
4
4
  "author": "New Relic Node.js agent team <nodejs@newrelic.com>",
5
5
  "license": "Apache-2.0",
6
6
  "contributors": [
package/stub_api.js CHANGED
@@ -61,7 +61,7 @@ function setLambdaHandler(callback) {
61
61
  }
62
62
 
63
63
  function startSegment(name, record, handler, callback) {
64
- logger.debug('Not calling `startSegment` becuase New Relic is disabled.')
64
+ logger.debug('Not calling `startSegment` because New Relic is disabled.')
65
65
  if (typeof handler === 'function') {
66
66
  return handler(callback)
67
67
  }