elastic-apm-node
Advanced tools
Comparing version 3.5.0 to 3.6.0
@@ -9,2 +9,3 @@ 'use strict' | ||
var { parseUrl } = require('../parsers') | ||
var { getHTTPDestination } = require('./context') | ||
@@ -212,2 +213,4 @@ const transactionForResponse = new WeakMap() | ||
span.setDestinationContext(getHTTPDestination(url, span.type)) | ||
span.end() | ||
@@ -214,0 +217,0 @@ } |
@@ -82,3 +82,3 @@ 'use strict' | ||
// https://github.com/elastic/apm-agent-nodejs/pull/957 | ||
return require(`./modules/${pathName}`)(...args) | ||
return require(`./modules/${pathName}.js`)(...args) | ||
}) | ||
@@ -85,0 +85,0 @@ } |
'use strict' | ||
var shimmer = require('../shimmer') | ||
var { getDBDestination } = require('../context') | ||
@@ -40,2 +41,9 @@ var queryRegexp = /_((search|msearch)(\/template)?|count)$/ | ||
} | ||
// get the remote host information from elasticsearch Transport options | ||
const transportConfig = this._config | ||
let host, port | ||
if (typeof transportConfig === 'object' && transportConfig.host) { | ||
[host, port] = transportConfig.host.split(':') | ||
} | ||
span.setDestinationContext(getDBDestination(span, host, port)) | ||
} | ||
@@ -42,0 +50,0 @@ |
@@ -8,2 +8,3 @@ 'use strict' | ||
var { parseUrl } = require('../../parsers') | ||
var { getHTTPDestination } = require('../context') | ||
@@ -182,2 +183,4 @@ module.exports = function (http2, agent, { enabled }) { | ||
span.setDestinationContext(getHTTPDestination(url, span.type)) | ||
span.end() | ||
@@ -184,0 +187,0 @@ }) |
@@ -6,2 +6,3 @@ 'use strict' | ||
var shimmer = require('../shimmer') | ||
var { getDBDestination } = require('../context') | ||
@@ -18,4 +19,19 @@ module.exports = function (memcached, agent, { version, enabled }) { | ||
shimmer.wrap(memcached.prototype, 'command', wrapCommand) | ||
shimmer.wrap(memcached.prototype, 'connect', wrapConnect) | ||
return memcached | ||
function wrapConnect (original) { | ||
return function wrappedConnect () { | ||
const currentSpan = agent._instrumentation.currentSpan | ||
const server = arguments[0] | ||
agent.logger.debug('intercepted call to memcached.prototype.connect %o', { server }) | ||
if (currentSpan) { | ||
const [host, port = 11211] = server.split(':') | ||
currentSpan.setDestinationContext(getDBDestination(currentSpan, host, port)) | ||
} | ||
return original.apply(this, arguments) | ||
} | ||
} | ||
// Wrap the generic command that is used to build touch, get, gets etc | ||
@@ -28,3 +44,3 @@ function wrapCommand (original) { | ||
if (query && typeof query.callback === 'function') { | ||
var span = agent.startSpan(`memcached.${query.type}`, `db.memcached.${query.type}`) | ||
var span = agent.startSpan(`memcached.${query.type}`, 'db', 'memcached', query.type) | ||
agent.logger.debug('intercepted call to memcached.prototype.command %o', { id: span && span.id, type: query.type }) | ||
@@ -31,0 +47,0 @@ if (span) { |
@@ -8,2 +8,3 @@ 'use strict' | ||
var symbols = require('../../symbols') | ||
var { getDBDestination } = require('../context') | ||
@@ -86,6 +87,11 @@ module.exports = function (mysql, agent, { version, enabled }) { | ||
function wrapQueryable (obj, objType, agent) { | ||
function wrapQueryable (connection, objType, agent) { | ||
agent.logger.debug('shimming mysql %s.query', objType) | ||
shimmer.wrap(obj, 'query', wrapQuery) | ||
shimmer.wrap(connection, 'query', wrapQuery) | ||
let host, port | ||
if (typeof connection.config === 'object') { | ||
({ host, port } = connection.config) | ||
} | ||
function wrapQuery (original) { | ||
@@ -126,2 +132,3 @@ return function wrappedQuery (sql, values, cb) { | ||
} | ||
span.setDestinationContext(getDBDestination(span, host, port)) | ||
@@ -128,0 +135,0 @@ if (typeof values === 'function') { |
@@ -8,2 +8,3 @@ 'use strict' | ||
var symbols = require('../../symbols') | ||
var { getDBDestination } = require('../context') | ||
@@ -34,2 +35,8 @@ module.exports = function (mysql2, agent, { version, enabled }) { | ||
} | ||
// get connection parameters from mysql config | ||
let host, port | ||
if (typeof this.config === 'object') { | ||
({ host, port } = this.config) | ||
} | ||
span.setDestinationContext(getDBDestination(span, host, port)) | ||
} | ||
@@ -36,0 +43,0 @@ |
@@ -8,5 +8,6 @@ 'use strict' | ||
var symbols = require('../../symbols') | ||
var { getDBDestination } = require('../context') | ||
module.exports = function (pg, agent, { version, enabled }) { | ||
if (!semver.satisfies(version, '>=4.0.0 <8.0.0')) { | ||
if (!semver.satisfies(version, '>=4.0.0 <9.0.0')) { | ||
agent.logger.debug('pg version %s not supported - aborting...', version) | ||
@@ -56,2 +57,9 @@ return pg | ||
if (span) { | ||
// get connection parameters from Client | ||
let host, port | ||
if (typeof this.connectionParameters === 'object') { | ||
({ host, port } = this.connectionParameters) | ||
} | ||
span.setDestinationContext(getDBDestination(span, host, port)) | ||
var args = arguments | ||
@@ -58,0 +66,0 @@ var index = args.length - 1 |
@@ -6,2 +6,3 @@ 'use strict' | ||
var shimmer = require('../shimmer') | ||
var { getDBDestination } = require('../context') | ||
@@ -42,5 +43,14 @@ module.exports = function (redis, agent, { version, enabled }) { | ||
if (span) { | ||
let host, port | ||
if (typeof this.connection_options === 'object') { | ||
({ host, port } = this.connection_options) | ||
} | ||
span.setDestinationContext(getDBDestination(span, host, port)) | ||
} | ||
if (commandObj) { | ||
commandObj.callback = makeWrappedCallback(span, commandObj.callback) | ||
if (span) span.name = String(command).toUpperCase() | ||
if (span) { | ||
span.name = String(command).toUpperCase() | ||
} | ||
} | ||
@@ -60,2 +70,9 @@ | ||
if (span) { | ||
let host, port | ||
if (typeof this.connectionOption === 'object') { | ||
({ host, port } = this.connectionOption) | ||
} | ||
span.setDestinationContext(getDBDestination(span, host, port)) | ||
} | ||
if (args.length > 0) { | ||
@@ -76,3 +93,5 @@ var index = args.length - 1 | ||
} | ||
if (span) span.name = String(command).toUpperCase() | ||
if (span) { | ||
span.name = String(command).toUpperCase() | ||
} | ||
} | ||
@@ -79,0 +98,0 @@ |
@@ -7,2 +7,4 @@ 'use strict' | ||
var { getDBDestination } = require('../context') | ||
module.exports = function (tedious, agent, { version, enabled }) { | ||
@@ -77,2 +79,9 @@ if (!enabled) return tedious | ||
span.setDbContext({ statement: sql, type: 'sql' }) | ||
// extract hostname and port from connection config | ||
let host, port | ||
if (typeof this.config === 'object') { | ||
host = this.config.server | ||
port = this.config.options && this.config.options.port | ||
} | ||
span.setDestinationContext(getDBDestination(span, host, port)) | ||
@@ -79,0 +88,0 @@ request.userCallback = wrapCallback(request.userCallback) |
@@ -34,2 +34,3 @@ 'use strict' | ||
this._http = null | ||
this._destination = null | ||
this._stackObj = null | ||
@@ -91,2 +92,6 @@ | ||
Span.prototype.setDestinationContext = function (context) { | ||
this._destination = Object.assign(this._destination || {}, context) | ||
} | ||
Span.prototype._recordStackTrace = function (obj) { | ||
@@ -156,7 +161,8 @@ if (!obj) { | ||
if (self._db || self._http || self._labels) { | ||
if (self._db || self._http || self._labels || self._destination) { | ||
payload.context = { | ||
db: self._db || undefined, | ||
http: self._http || undefined, | ||
tags: self._labels || undefined | ||
tags: self._labels || undefined, | ||
destination: self._destination || undefined | ||
} | ||
@@ -163,0 +169,0 @@ } |
'use strict' | ||
const v8 = require('v8') | ||
const eventLoopMonitor = require('monitor-event-loop-delay') | ||
@@ -24,3 +22,5 @@ | ||
'nodejs.memory.heap.allocated.bytes': 0, | ||
'nodejs.memory.heap.used.bytes': 0 | ||
'nodejs.memory.heap.used.bytes': 0, | ||
'nodejs.memory.external.bytes': 0, | ||
'nodejs.memory.arrayBuffers.bytes': 0 | ||
} | ||
@@ -47,7 +47,10 @@ | ||
// Heap | ||
const heap = v8.getHeapStatistics() | ||
this.stats['nodejs.memory.heap.allocated.bytes'] = heap.total_heap_size | ||
this.stats['nodejs.memory.heap.used.bytes'] = heap.used_heap_size | ||
// Memory / Heap | ||
const memoryUsage = process.memoryUsage() | ||
this.stats['nodejs.memory.heap.allocated.bytes'] = memoryUsage.heapTotal | ||
this.stats['nodejs.memory.heap.used.bytes'] = memoryUsage.heapUsed | ||
this.stats['nodejs.memory.external.bytes'] = memoryUsage.external | ||
this.stats['nodejs.memory.arrayBuffers.bytes'] = memoryUsage.arrayBuffers || 0 // Only available in NodeJS +13.0 | ||
if (cb) process.nextTick(cb) | ||
@@ -54,0 +57,0 @@ } |
{ | ||
"name": "elastic-apm-node", | ||
"version": "3.5.0", | ||
"version": "3.6.0", | ||
"description": "The official Elastic APM agent for Node.js", | ||
@@ -42,3 +42,3 @@ "main": "index.js", | ||
"engines": { | ||
"node": "^8.6.0 || 10 || 12 || 13" | ||
"node": "^8.6.0 || 10 || 12 || 13 || 14" | ||
}, | ||
@@ -107,3 +107,3 @@ "keywords": [ | ||
"sql-summary": "^1.0.1", | ||
"stackman": "^4.0.0", | ||
"stackman": "^4.0.1", | ||
"traceparent": "^1.0.0", | ||
@@ -113,2 +113,3 @@ "unicode-byte-truncate": "^1.0.0" | ||
"devDependencies": { | ||
"@apidevtools/json-schema-ref-parser": "^8.0.0", | ||
"@babel/cli": "^7.8.4", | ||
@@ -125,3 +126,3 @@ "@babel/core": "^7.8.4", | ||
"aws-sdk": "^2.622.0", | ||
"backport": "^4.9.0", | ||
"backport": "^5.1.2", | ||
"benchmark": "^2.1.4", | ||
@@ -152,3 +153,2 @@ "bluebird": "^3.7.2", | ||
"jade": "^1.11.0", | ||
"json-schema-ref-parser": "^7.1.3", | ||
"knex": "^0.20.10", | ||
@@ -170,3 +170,3 @@ "koa": "^2.11.0", | ||
"p-finally": "^2.0.1", | ||
"pg": "^7.18.1", | ||
"pg": "^8.1.0", | ||
"pug": "^2.0.4", | ||
@@ -179,3 +179,3 @@ "redis": "^2.8.0", | ||
"send": "^0.17.1", | ||
"standard": "^14.3.1", | ||
"standard": "^14.3.3", | ||
"tape": "^4.13.0", | ||
@@ -207,5 +207,5 @@ "tedious": "^8.0.1", | ||
"coordinates": [ | ||
56.043902, | ||
12.609232 | ||
56.038233, | ||
12.620072 | ||
] | ||
} |
@@ -59,3 +59,3 @@ # Elastic APM Node.js Agent | ||
To see what data is being sent to the APM Server, | ||
use the environment variable `ELASTIC_APM_PAYLOAD_LOG_FILE` (or the config option `payloadLogFile`) to speicfy a log file, | ||
use the environment variable `ELASTIC_APM_PAYLOAD_LOG_FILE` (or the config option `payloadLogFile`) to specify a log file, | ||
e.g: | ||
@@ -62,0 +62,0 @@ |
Sorry, the diff of this file is not supported yet
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
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
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
Debug access
Supply chain riskUses debug, reflection and dynamic code execution features.
Found 1 instance in 1 package
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
262369
75
6245
17
Updatedstackman@^4.0.1