Comparing version 12.6.0 to 12.6.1
@@ -416,2 +416,13 @@ /* | ||
}, | ||
cloud: { | ||
aws: { | ||
/** | ||
* The AWS account ID for the AWS account associated with this app. | ||
*/ | ||
account_id: { | ||
formatter: int, | ||
default: null | ||
} | ||
} | ||
}, | ||
/** | ||
@@ -418,0 +429,0 @@ * Options regarding collecting system information. Used for system |
@@ -8,5 +8,2 @@ /* | ||
const { DB, ALL } = require('../metrics/names') | ||
const { DESTINATIONS } = require('../config/attribute-filter') | ||
function ParsedStatement(type, operation, collection, raw) { | ||
@@ -25,53 +22,2 @@ this.type = type | ||
ParsedStatement.prototype.recordMetrics = function recordMetrics(segment, scope) { | ||
const duration = segment.getDurationInMillis() | ||
const exclusive = segment.getExclusiveDurationInMillis() | ||
const transaction = segment.transaction | ||
const type = transaction.isWeb() ? DB.WEB : DB.OTHER | ||
const thisTypeSlash = this.type + '/' | ||
const operation = DB.OPERATION + '/' + thisTypeSlash + this.operation | ||
// Note, an operation metric should _always_ be created even if the action was | ||
// a statement. This is part of the spec. | ||
// Rollups | ||
transaction.measure(operation, null, duration, exclusive) | ||
transaction.measure(DB.PREFIX + type, null, duration, exclusive) | ||
transaction.measure(DB.PREFIX + thisTypeSlash + type, null, duration, exclusive) | ||
transaction.measure(DB.PREFIX + thisTypeSlash + ALL, null, duration, exclusive) | ||
transaction.measure(DB.ALL, null, duration, exclusive) | ||
// If we can parse the SQL statement, create a 'statement' metric, and use it | ||
// as the scoped metric for transaction breakdowns. Otherwise, skip the | ||
// 'statement' metric and use the 'operation' metric as the scoped metric for | ||
// transaction breakdowns. | ||
let collection | ||
if (this.collection) { | ||
collection = DB.STATEMENT + '/' + thisTypeSlash + this.collection + '/' + this.operation | ||
transaction.measure(collection, null, duration, exclusive) | ||
if (scope) { | ||
transaction.measure(collection, scope, duration, exclusive) | ||
} | ||
} else if (scope) { | ||
transaction.measure(operation, scope, duration, exclusive) | ||
} | ||
// This recorder is side-effectful Because we are depending on the recorder | ||
// setting the transaction name, recorders must always be run before generating | ||
// the final transaction trace | ||
segment.name = collection || operation | ||
// Datastore instance metrics. | ||
const attributes = segment.attributes.get(DESTINATIONS.TRANS_SEGMENT) | ||
if (attributes.host && attributes.port_path_or_id) { | ||
const instanceName = | ||
DB.INSTANCE + '/' + thisTypeSlash + attributes.host + '/' + attributes.port_path_or_id | ||
transaction.measure(instanceName, null, duration, exclusive) | ||
} | ||
if (this.raw) { | ||
transaction.agent.queries.add(segment, this.type.toLowerCase(), this.raw, this.trace) | ||
} | ||
} | ||
module.exports = ParsedStatement |
@@ -18,3 +18,5 @@ /* | ||
const specs = require('./specs') | ||
const recordOperationMetrics = require('../../lib/metrics/recorders/database-operation') | ||
const { DatastoreParameters } = specs.params | ||
const recordQueryMetrics = require('../../lib/metrics/recorders/database') | ||
@@ -288,3 +290,3 @@ /** | ||
} | ||
segDesc.recorder = _recordOperationMetrics.bind(shim) | ||
segDesc.recorder = recordOperationMetrics.bind(shim) | ||
} | ||
@@ -572,3 +574,3 @@ | ||
segDesc.name = shim._metrics.STATEMENT + name | ||
segDesc.recorder = _recordQueryMetrics.bind(null, parsed) | ||
segDesc.recorder = recordQueryMetrics.bind(parsed) | ||
} | ||
@@ -605,68 +607,2 @@ | ||
/** | ||
* Records all query metrics when a segment is active | ||
* | ||
* @private | ||
* @param {ParsedStatement} parsed instance of ParsedStatement | ||
* @param {TraceSegment} segment active segment | ||
* @param {string} scope scope of metrics if it exists | ||
*/ | ||
function _recordQueryMetrics(parsed, segment, scope) { | ||
if (segment) { | ||
parsed.recordMetrics(segment, scope) | ||
} | ||
} | ||
/** | ||
* Records all the metrics required for database operations. | ||
* | ||
* - `_recordOperationMetrics(segment [, scope])` | ||
* | ||
* @private | ||
* @this DatastoreShim | ||
* @implements {MetricFunction} | ||
* @param {TraceSegment} segment - The segment being recorded. | ||
* @param {string} [scope] - The scope of the segment. | ||
* @see DatastoreShim#recordOperation | ||
* @see MetricFunction | ||
*/ | ||
function _recordOperationMetrics(segment, scope) { | ||
if (!segment) { | ||
return | ||
} | ||
const duration = segment.getDurationInMillis() | ||
const exclusive = segment.getExclusiveDurationInMillis() | ||
const transaction = segment.transaction | ||
const type = transaction.isWeb() ? 'allWeb' : 'allOther' | ||
const operation = segment.name | ||
if (scope) { | ||
transaction.measure(operation, scope, duration, exclusive) | ||
} | ||
transaction.measure(operation, null, duration, exclusive) | ||
transaction.measure(metrics.DB.PREFIX + type, null, duration, exclusive) | ||
transaction.measure(metrics.DB.ALL, null, duration, exclusive) | ||
transaction.measure(this._metrics.ALL, null, duration, exclusive) | ||
transaction.measure( | ||
metrics.DB.PREFIX + this._metrics.PREFIX + '/' + type, | ||
null, | ||
duration, | ||
exclusive | ||
) | ||
const attributes = segment.getAttributes() | ||
if (attributes.host && attributes.port_path_or_id) { | ||
const instanceName = [ | ||
metrics.DB.INSTANCE, | ||
this._metrics.PREFIX, | ||
attributes.host, | ||
attributes.port_path_or_id | ||
].join('/') | ||
transaction.measure(instanceName, null, duration, exclusive) | ||
} | ||
} | ||
/** | ||
* Extracts the query string from the arguments according to the given spec. | ||
@@ -673,0 +609,0 @@ * |
@@ -16,2 +16,3 @@ /* | ||
const { RecorderSpec } = require('../specs') | ||
const makeMiddlewareRecorder = require('../../metrics/recorders/middleware') | ||
@@ -92,3 +93,3 @@ const MIDDLEWARE_TYPE_DETAILS = { | ||
const stackPath = txInfo.transaction.nameState.getPath() || '' | ||
recorder = _makeMiddlewareRecorder(shim, metricName + '/' + stackPath) | ||
recorder = makeMiddlewareRecorder(shim, metricName + '/' + stackPath) | ||
} | ||
@@ -331,23 +332,2 @@ return recorder | ||
/** | ||
* Creates a recorder for middleware metrics. | ||
* | ||
* @private | ||
* @param {object} _shim instance of shim | ||
* @param {string} metricName name of metric | ||
* @returns {Function} recorder for middleware | ||
*/ | ||
function _makeMiddlewareRecorder(_shim, metricName) { | ||
return function middlewareMetricRecorder(segment, scope) { | ||
const duration = segment.getDurationInMillis() | ||
const exclusive = segment.getExclusiveDurationInMillis() | ||
const transaction = segment.transaction | ||
if (scope) { | ||
transaction.measure(metricName, scope, duration, exclusive) | ||
} | ||
transaction.measure(metricName, null, duration, exclusive) | ||
} | ||
} | ||
/** | ||
* Wrap the `next` middleware function and push on our name state if we find it. We only want to | ||
@@ -354,0 +334,0 @@ * push the name state if there is a next so that we can safely remove it |
@@ -119,7 +119,23 @@ /* | ||
) | ||
findCGroupsV1(callback) | ||
findCGroupsV1(callback, logger) | ||
return | ||
} | ||
parseCGroupsV2(data, callback) | ||
parseCGroupsV2( | ||
data, | ||
(_, v2Data) => { | ||
if (v2Data !== null) { | ||
// We found a valid Docker identifier in the v2 file, so we are going | ||
// to prioritize it. | ||
return callback(null, v2Data) | ||
} | ||
// For some reason, we have a /proc/self/mountinfo but it does not have | ||
// any Docker information in it (that we have detected). So we will | ||
// fall back to trying the cgroups v1 file. | ||
logger.debug(`Attempting to fall back to cgroups v1 parsing.`) | ||
findCGroupsV1(callback, logger) | ||
}, | ||
logger | ||
) | ||
}) | ||
@@ -140,2 +156,3 @@ } | ||
if (line) { | ||
logger.debug(`Found docker id from cgroups v2: ${line[1]}`) | ||
callback(null, { id: line[1] }) | ||
@@ -174,3 +191,4 @@ } else { | ||
if (id) { | ||
vendorInfo = { id: id } | ||
vendorInfo = { id } | ||
logger.debug(`Found docker id from cgroups v1: ${id}`) | ||
callback(null, vendorInfo) | ||
@@ -177,0 +195,0 @@ } else { |
{ | ||
"name": "newrelic", | ||
"version": "12.6.0", | ||
"version": "12.6.1", | ||
"author": "New Relic Node.js agent team <nodejs@newrelic.com>", | ||
@@ -5,0 +5,0 @@ "license": "Apache-2.0", |
Sorry, the diff of this file is too big to display
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
2085563
305
40921