@instana/core
Advanced tools
Comparing version 1.97.0 to 1.97.1
{ | ||
"name": "@instana/core", | ||
"version": "1.97.0", | ||
"version": "1.97.1", | ||
"description": "Core library for Instana's Node.js packages", | ||
@@ -136,3 +136,3 @@ "main": "src/index.js", | ||
}, | ||
"gitHead": "a6521942194e350d2c988e1478569e72d4ebd09b" | ||
"gitHead": "c63fce5786ad8e70f1a4dc5342f2c37ee0f34b7b" | ||
} |
@@ -207,2 +207,7 @@ 'use strict'; | ||
}); | ||
Object.defineProperty(this, 'pathTplFrozen', { | ||
value: false, | ||
writable: true, | ||
enumerable: false | ||
}); | ||
Object.defineProperty(this, 'manualEndMode', { | ||
@@ -250,2 +255,6 @@ value: false, | ||
InstanaSpan.prototype.freezePathTemplate = function freezePathTemplate() { | ||
this.pathTplFrozen = true; | ||
}; | ||
InstanaSpan.prototype.disableAutoEnd = function disableAutoEnd() { | ||
@@ -252,0 +261,0 @@ this.manualEndMode = true; |
@@ -154,3 +154,3 @@ 'use strict'; | ||
var span = cls.getCurrentEntrySpan(); | ||
if (!span || span.n !== httpServer.spanName) { | ||
if (!span || span.n !== httpServer.spanName || span.pathTplFrozen) { | ||
return; | ||
@@ -157,0 +157,0 @@ } |
@@ -96,3 +96,3 @@ 'use strict'; | ||
var span = cls.getCurrentEntrySpan(); | ||
if (!span || span.n !== httpServer.spanName) { | ||
if (!span || span.n !== httpServer.spanName || span.pathTplFrozen) { | ||
return; | ||
@@ -99,0 +99,0 @@ } |
@@ -47,3 +47,3 @@ 'use strict'; | ||
var span = cls.getCurrentEntrySpan(); | ||
if (!span || span.n !== httpServer.spanName) { | ||
if (!span || span.n !== httpServer.spanName || span.pathTplFrozen) { | ||
return; | ||
@@ -50,0 +50,0 @@ } |
@@ -115,3 +115,3 @@ 'use strict'; | ||
var span = cls.getCurrentEntrySpan(); | ||
if (!span || span.n !== httpServer.spanName) { | ||
if (!span || span.n !== httpServer.spanName || span.pathTplFrozen) { | ||
return; | ||
@@ -118,0 +118,0 @@ } |
@@ -82,9 +82,58 @@ 'use strict'; | ||
SpanHandle.prototype.annotate = function annotate(key, value) { | ||
if (key == null) { | ||
SpanHandle.prototype.annotate = function annotate(path, value) { | ||
if (path == null) { | ||
return; | ||
} | ||
this.span.data[key] = value; | ||
if (typeof path === 'string') { | ||
_annotateWithString(this.span.data, path, value); | ||
if (path === 'http.path_tpl') { | ||
this.span.freezePathTemplate(); | ||
} | ||
} else if (Array.isArray(path)) { | ||
_annotateWithArray(this.span.data, path, value); | ||
if (path[0] === 'http' && path[1] === 'path_tpl') { | ||
this.span.freezePathTemplate(); | ||
} | ||
} | ||
}; | ||
function _annotateWithString(target, path, value) { | ||
// remove trailing dots first | ||
if (path.charAt(path.length - 1) === '.') { | ||
return _annotateWithString(target, path.substring(0, path.length - 1), value); | ||
} | ||
var idx = path.indexOf('.'); | ||
if (idx === 0) { | ||
// key with leading "." | ||
_annotateWithString(target, path.substring(1), value); | ||
} else if (idx >= 1) { | ||
var head = path.substring(0, idx); | ||
var tail = path.substring(idx + 1); | ||
var nestedTarget = target[head]; | ||
if (nestedTarget == null || typeof nestedTarget !== 'object') { | ||
target[head] = nestedTarget = {}; | ||
} | ||
_annotateWithString(nestedTarget, tail, value); | ||
} else { | ||
target[path] = value; | ||
} | ||
} | ||
function _annotateWithArray(target, path, value) { | ||
if (path.length === 0) { | ||
// eslint-disable-next-line no-useless-return | ||
return; | ||
} else if (path.length === 1) { | ||
_annotateWithString(target, path[0], value); | ||
} else { | ||
var head = path[0]; | ||
var tail = path.slice(1); | ||
var nestedTarget = target[head]; | ||
if (nestedTarget == null || typeof nestedTarget !== 'object') { | ||
target[head] = nestedTarget = {}; | ||
} | ||
_annotateWithArray(nestedTarget, tail, value); | ||
} | ||
} | ||
/** | ||
@@ -91,0 +140,0 @@ * Switches the span into manual-end-mode. Calls to span#transmit() as used by automatic tracing instrumentation will be |
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
336401
9104