Comparing version 0.10.2 to 0.11.0-beta.0
@@ -1,1 +0,1 @@ | ||
module.exports = '0.10.2' | ||
module.exports = '0.11.0-beta.0' |
{ | ||
"name": "dd-trace", | ||
"version": "0.10.2", | ||
"version": "0.11.0-beta.0", | ||
"description": "Datadog APM tracing client for JavaScript", | ||
"main": "index.js", | ||
"typings": "docs/index.d.ts", | ||
"typings": "index.d.ts", | ||
"scripts": { | ||
"rebuild": "node-gyp rebuild", | ||
"prebuild": "node scripts/prebuild.js", | ||
"install": "node scripts/post_install.js", | ||
"install:rebuild": "node-gyp-build", | ||
"bench": "node benchmark", | ||
@@ -43,2 +47,3 @@ "type:doc": "cd docs && yarn && yarn build", | ||
"async-hook-jl": "^1.7.6", | ||
"hot-shots": "^5.0.0", | ||
"int64-buffer": "^0.1.9", | ||
@@ -55,2 +60,4 @@ "koalas": "^1.0.2", | ||
"msgpack-lite": "^0.1.26", | ||
"nan": "^2.12.1", | ||
"node-gyp-build": "^3.8.0", | ||
"opentracing": ">=0.12.1", | ||
@@ -65,2 +72,3 @@ "parent-module": "^0.1.0", | ||
"shimmer": "^1.2.0", | ||
"tar": "^4.4.8", | ||
"url-parse": "^1.4.3" | ||
@@ -85,2 +93,4 @@ }, | ||
"nock": "^9.6.1", | ||
"node-abi": "^2.7.1", | ||
"prebuildify": "^2.11.0", | ||
"proxyquire": "^1.8.0", | ||
@@ -87,0 +97,0 @@ "require-dir": "^1.0.0", |
@@ -8,4 +8,4 @@ 'use strict' | ||
class Config { | ||
constructor (service, options) { | ||
options = typeof service === 'object' ? service : options || {} | ||
constructor (service, runtimeId, options) { | ||
options = options || {} | ||
@@ -21,4 +21,3 @@ const enabled = coalesce(options.enabled, platform.env('DD_TRACE_ENABLED'), true) | ||
platform.env('DD_AGENT_HOST'), | ||
platform.env('DD_TRACE_AGENT_HOSTNAME'), | ||
'localhost' | ||
platform.env('DD_TRACE_AGENT_HOSTNAME') | ||
) | ||
@@ -35,6 +34,5 @@ const port = coalesce(options.port, platform.env('DD_TRACE_AGENT_PORT'), 8126) | ||
this.env = env | ||
this.url = url ? new URL(url) : new URL(`${protocol}://${hostname}:${port}`) | ||
this.tags = Object.assign({}, options.tags) | ||
this.url = url ? new URL(url) : new URL(`${protocol}://${hostname || 'localhost'}:${port}`) | ||
this.hostname = hostname || this.url.hostname | ||
this.flushInterval = flushInterval | ||
this.bufferSize = 100000 | ||
this.sampleRate = sampleRate | ||
@@ -45,5 +43,14 @@ this.logger = options.logger | ||
this.analytics = String(analytics) === 'true' | ||
this.runtimeId = coalesce(runtimeId, '') | ||
this.tags = Object.assign({ 'runtime-id': this.runtimeId }, options.tags) | ||
this.experimental = { | ||
runtimeMetrics: isFlagEnabled(options.experimental, 'runtimeMetrics') | ||
} | ||
} | ||
} | ||
function isFlagEnabled (obj, prop) { | ||
return obj === true || (typeof obj === 'object' && obj !== null && obj[prop]) | ||
} | ||
module.exports = Config |
@@ -79,5 +79,5 @@ 'use strict' | ||
function extractError (trace, span) { | ||
const error = span._error | ||
const error = span.context()._tags['error'] | ||
if (error) { | ||
if (error instanceof Error) { | ||
trace.meta['error.msg'] = error.message | ||
@@ -84,0 +84,0 @@ trace.meta['error.type'] = error.name |
@@ -108,3 +108,3 @@ 'use strict' | ||
Object.keys(keyValuePairs).forEach(key => { | ||
this._spanContext._tags[key] = String(keyValuePairs[key]) | ||
this._spanContext._tags[key] = keyValuePairs[key] | ||
}) | ||
@@ -111,0 +111,0 @@ } catch (e) { |
@@ -33,3 +33,3 @@ 'use strict' | ||
this._prioritySampler = new PrioritySampler(config.env) | ||
this._writer = new Writer(this._prioritySampler, config.url, config.bufferSize) | ||
this._writer = new Writer(this._prioritySampler, config.url) | ||
this._recorder = new Recorder(this._writer, config.flushInterval) | ||
@@ -36,0 +36,0 @@ this._recorder.init() |
@@ -5,2 +5,3 @@ 'use strict' | ||
const id = require('./id') | ||
const uuid = require('./uuid') | ||
const now = require('./now') | ||
@@ -12,2 +13,3 @@ const env = require('./env') | ||
const msgpack = require('./msgpack') | ||
const metrics = require('./metrics') | ||
const Uint64BE = require('./uint64be') | ||
@@ -26,2 +28,3 @@ | ||
id, | ||
uuid, | ||
now, | ||
@@ -33,2 +36,3 @@ env, | ||
msgpack, | ||
metrics, | ||
Uint64BE, | ||
@@ -35,0 +39,0 @@ on: emitter.on.bind(emitter), |
@@ -29,3 +29,4 @@ 'use strict' | ||
const service = platform.service() | ||
const config = new Config(service, options) | ||
const runtimeId = platform.uuid() | ||
const config = new Config(service, runtimeId, options) | ||
@@ -36,2 +37,6 @@ if (config.enabled) { | ||
if (config.experimental.runtimeMetrics) { | ||
platform.metrics().start() | ||
} | ||
this._tracer = new DatadogTracer(config) | ||
@@ -38,0 +43,0 @@ this._instrumenter.enable() |
'use strict' | ||
const asyncWrap = process.binding('async_wrap') | ||
let asyncHook | ||
@@ -15,2 +17,8 @@ | ||
const providers = Object.keys(asyncWrap.Providers) | ||
.reduce((prev, next) => { | ||
prev[asyncWrap.Providers[next]] = next | ||
return prev | ||
}, {}) | ||
module.exports = { | ||
@@ -22,3 +30,3 @@ createHook (callbacks) { | ||
hooks.init = (uid, handle, provider, parentUid, parentHandle) => { | ||
callbacks.init(uid) | ||
callbacks.init(uid, providers[provider]) | ||
} | ||
@@ -25,0 +33,0 @@ } |
@@ -6,2 +6,3 @@ 'use strict' | ||
const Base = require('./base') | ||
const platform = require('../../platform') | ||
@@ -11,3 +12,3 @@ let singleton = null | ||
class Scope extends Base { | ||
constructor () { | ||
constructor (options) { | ||
if (singleton) return singleton | ||
@@ -27,2 +28,6 @@ | ||
this._hook.enable() | ||
if (options && options.debug) { | ||
this._debug() | ||
} | ||
} | ||
@@ -67,2 +72,4 @@ | ||
} | ||
platform.metrics().increment('async.resources') | ||
} | ||
@@ -72,5 +79,33 @@ | ||
delete this._spans[asyncId] | ||
platform.metrics().decrement('async.resources') | ||
} | ||
_debug () { | ||
asyncHooks.createHook({ | ||
init: this._debugInit.bind(this), | ||
destroy: this._debugDestroy.bind(this), | ||
promiseResolve: this._debugDestroy.bind(this) | ||
}).enable() | ||
this._types = Object.create(null) | ||
} | ||
_debugInit (asyncId, type) { | ||
this._types[asyncId] = type | ||
platform.metrics().increment(`async.resources.${type}`) | ||
} | ||
_debugDestroy (asyncId) { | ||
const type = this._types[asyncId] | ||
if (type) { | ||
platform.metrics().decrement(`async.resources.${type}`) | ||
} | ||
delete this._types[asyncId] | ||
} | ||
} | ||
module.exports = Scope |
@@ -27,3 +27,5 @@ 'use strict' | ||
this._scopeManager = new ScopeManager() | ||
this._scope = new Scope() | ||
this._scope = new Scope({ | ||
debug: config.debug | ||
}) | ||
} | ||
@@ -30,0 +32,0 @@ |
@@ -9,8 +9,10 @@ 'use strict' | ||
const MAX_SIZE = 8 * 1024 * 1024 // 8MB | ||
class Writer { | ||
constructor (prioritySampler, url, size) { | ||
constructor (prioritySampler, url) { | ||
this._queue = [] | ||
this._prioritySampler = prioritySampler | ||
this._url = url | ||
this._size = size | ||
this._size = 0 | ||
} | ||
@@ -40,7 +42,8 @@ | ||
if (this.length < this._size) { | ||
this._queue.push(buffer) | ||
} else { | ||
this._squeeze(buffer) | ||
if (buffer.length + this._size > MAX_SIZE) { | ||
this.flush() | ||
} | ||
this._size += buffer.length | ||
this._queue.push(buffer) | ||
} | ||
@@ -56,2 +59,3 @@ } | ||
this._queue = [] | ||
this._size = 0 | ||
} | ||
@@ -88,9 +92,4 @@ } | ||
} | ||
_squeeze (buffer) { | ||
const index = Math.floor(Math.random() * this.length) | ||
this._queue[index] = buffer | ||
} | ||
} | ||
module.exports = Writer |
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
Install scripts
Supply chain riskInstall scripts are run when the package is installed. The majority of malware in npm is hidden in install scripts.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
Debug access
Supply chain riskUses debug, reflection and dynamic code execution features.
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
Install scripts
Supply chain riskInstall scripts are run when the package is installed. The majority of malware in npm is hidden in install scripts.
Found 1 instance in 1 package
Shell access
Supply chain riskThis module accesses the system shell. Accessing the system shell increases the risk of executing arbitrary code.
Found 1 instance in 1 package
Uses eval
Supply chain riskPackage uses dynamic code execution (e.g., eval()), which is a dangerous practice. This can prevent the code from running in certain environments and increases the risk that the code may contain exploits or malicious behavior.
Found 2 instances 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
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 12 instances in 1 package
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 3 instances in 1 package
Minified code
QualityThis package contains minified code. This may be harmless in some cases where minified code is included in packaged libraries, however packages on npm should not minify code.
Found 1 instance in 1 package
Mixed license
License(Experimental) Package contains multiple licenses.
Found 1 instance in 1 package
1
1
10
5
198433
27
25
112
5658
+ Addedhot-shots@^5.0.0
+ Addednan@^2.12.1
+ Addednode-gyp-build@^3.8.0
+ Addedtar@^4.4.8
+ Addedchownr@1.1.4(transitive)
+ Addedfs-minipass@1.2.7(transitive)
+ Addedhot-shots@5.9.2(transitive)
+ Addedminimist@1.2.8(transitive)
+ Addedminipass@2.9.0(transitive)
+ Addedminizlib@1.3.3(transitive)
+ Addedmkdirp@0.5.6(transitive)
+ Addednan@2.20.0(transitive)
+ Addednode-gyp-build@3.9.0(transitive)
+ Addedtar@4.4.19(transitive)
+ Addedyallist@3.1.1(transitive)