concurix-tracer
Advanced tools
Comparing version 1.0.2 to 1.1.0
{ | ||
"name": "concurix-tracer", | ||
"version": "1.0.2", | ||
"version": "1.1.0", | ||
"description": "Core tracer logic for the concurix instrumentation suite.", | ||
@@ -27,3 +27,3 @@ "main": "tracer.js", | ||
"devDependencies": { | ||
"tape": "^2.12.3" | ||
"tape": "^2.14.0" | ||
}, | ||
@@ -34,4 +34,4 @@ "directories": { | ||
"dependencies": { | ||
"concurix-traceaggregator": "^1.0.0", | ||
"concurix-transactionlog": "^1.0.0", | ||
"concurix-traceaggregator": "^1.0.1", | ||
"concurix-transactionlog": "^1.0.1", | ||
"concurix-upload": "^1.0.1" | ||
@@ -38,0 +38,0 @@ }, |
@@ -108,3 +108,13 @@ "use strict"; | ||
Tracer.prototype._schedule = function _schedule(id, name) { | ||
function LogEntry(type) { | ||
this.type = type | ||
} | ||
LogEntry.prototype.type = "" | ||
LogEntry.prototype.id = "" | ||
LogEntry.prototype.name = "" | ||
LogEntry.prototype.ts = [] | ||
LogEntry.prototype.fnId = "" | ||
LogEntry.prototype.isTx = false | ||
Tracer.prototype._schedule = function _schedule(id, name, isTx) { | ||
// link to function we're in on the stack | ||
@@ -114,5 +124,3 @@ if (this.stopped || !this.config.trace || !this.config.follow_links) { | ||
} | ||
// if (id % 10 !== 0) { | ||
// return | ||
// } | ||
if (this.stack.length > this.config.max_stack_length) { | ||
@@ -124,6 +132,19 @@ // This is an ugly solution but helps prevent tracing from coming | ||
var fnId = this.enterStack[this.enterStack.length - 1] | ||
this.stack.push({type: "schedule", id: id, name: name, ts: process.hrtime(), fnId: fnId}) | ||
if (fnId == null) { | ||
// TODO if we schedule/resume prior to an `enter` we have no function id | ||
// Synthetically bind it to "uninstrumented js" -- which may be problematic | ||
fnId = "1" | ||
} | ||
var entry = new LogEntry("schedule") | ||
entry.id = id.toString(32) | ||
entry.name = name | ||
entry.ts = process.hrtime() | ||
entry.fnId = fnId | ||
if (isTx) { | ||
entry.isTx = true | ||
} | ||
this.stack.push(entry) | ||
} | ||
Tracer.prototype._resume = function _resume(id, name) { | ||
Tracer.prototype._resume = function _resume(id, name, isTx) { | ||
// link to the stack (not in fn yet?) | ||
@@ -133,7 +154,13 @@ if (this.stopped || !this.config.trace || !this.config.follow_links) { | ||
} | ||
// if (id % 10 !== 0) { | ||
// return | ||
// } | ||
var fnId = this.enterStack[this.enterStack.length - 1] | ||
this.stack.push({type: "resume", id: id, name: name, ts: process.hrtime(), fnId: fnId}) | ||
var entry = new LogEntry("resume") | ||
entry.id = id.toString(32) | ||
entry.name = name | ||
entry.ts = process.hrtime() | ||
entry.fnId = fnId | ||
if (isTx) { | ||
entry.isTx = true | ||
} | ||
this.stack.push(entry) | ||
} | ||
@@ -149,3 +176,5 @@ | ||
} | ||
this.stack.push({type: "tag", tag: tagName}) | ||
var entry = new LogEntry("tag") | ||
entry.name = tagName | ||
this.stack.push(entry) | ||
} | ||
@@ -195,3 +224,6 @@ | ||
this.enterStack.push(id) | ||
this.stack.push({type: "enter", id: id, ts: process.hrtime()}) | ||
var entry = new LogEntry("enter") | ||
entry.id = id | ||
entry.ts = process.hrtime() | ||
this.stack.push(entry) | ||
this.depth++ | ||
@@ -205,2 +237,3 @@ return traceme | ||
} | ||
var entry = new LogEntry("exit") | ||
var exitedAt = process.hrtime() | ||
@@ -216,3 +249,6 @@ // exiting a function. we expect *exactly* one per enter. | ||
for (var i = unfinished.length - 1; i > 0; i--) { | ||
this.stack.push({type: "exit", id: unfinished[i], ts: exitedAt}) | ||
entry = new LogEntry("exit") | ||
entry.id = unfinished[i] | ||
entry.ts = exitedAt | ||
this.stack.push(entry) | ||
this.depth-- | ||
@@ -224,3 +260,6 @@ } | ||
} | ||
this.stack.push({type: "exit", id: id, ts: exitedAt}) | ||
entry = new LogEntry("exit") | ||
entry.id = id | ||
entry.ts = exitedAt | ||
this.stack.push(entry) | ||
this.prevFile = null | ||
@@ -421,3 +460,3 @@ this.depth-- | ||
var txId = [idgen.next(), Date.now(), transaction] | ||
this._schedule(txId[0], transaction) | ||
this._schedule(txId[0], transaction, true) | ||
return txId | ||
@@ -433,4 +472,4 @@ } | ||
} | ||
this._resume(txId[0], txId[2]) | ||
this._resume(txId[0], txId[2], true) | ||
this.tag(txId[2], extra) | ||
} |
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
14776
458