@opentelemetry/tracing
Advanced tools
Comparing version 0.5.1 to 0.5.2
@@ -29,3 +29,2 @@ /*! | ||
private _finishedSpans; | ||
private _lastSpanFlush; | ||
private _timer; | ||
@@ -40,5 +39,6 @@ private _isShutdown; | ||
private _addToBuffer; | ||
private _shouldFlush; | ||
/** Send the span data list to exporter */ | ||
private _flush; | ||
private _maybeStartTimer; | ||
private _clearTimer; | ||
} |
@@ -29,3 +29,2 @@ "use strict"; | ||
this._finishedSpans = []; | ||
this._lastSpanFlush = Date.now(); | ||
this._isShutdown = false; | ||
@@ -38,8 +37,2 @@ this._bufferSize = | ||
: DEFAULT_BUFFER_TIMEOUT_MS; | ||
this._timer = setInterval(() => { | ||
if (this._shouldFlush()) { | ||
this._flush(); | ||
} | ||
}, this._bufferTimeout); | ||
core_1.unrefTimer(this._timer); | ||
} | ||
@@ -64,3 +57,2 @@ forceFlush() { | ||
} | ||
clearInterval(this._timer); | ||
this.forceFlush(); | ||
@@ -73,2 +65,3 @@ this._isShutdown = true; | ||
this._finishedSpans.push(span); | ||
this._maybeStartTimer(); | ||
if (this._finishedSpans.length > this._bufferSize) { | ||
@@ -78,14 +71,26 @@ this._flush(); | ||
} | ||
_shouldFlush() { | ||
return (this._finishedSpans.length >= 0 && | ||
Date.now() - this._lastSpanFlush >= this._bufferTimeout); | ||
} | ||
/** Send the span data list to exporter */ | ||
_flush() { | ||
this._clearTimer(); | ||
if (this._finishedSpans.length === 0) | ||
return; | ||
this._exporter.export(this._finishedSpans, () => { }); | ||
this._finishedSpans = []; | ||
this._lastSpanFlush = Date.now(); | ||
} | ||
_maybeStartTimer() { | ||
if (this._timer !== undefined) | ||
return; | ||
this._timer = setTimeout(() => { | ||
this._flush(); | ||
}, this._bufferTimeout); | ||
core_1.unrefTimer(this._timer); | ||
} | ||
_clearTimer() { | ||
if (this._timer !== undefined) { | ||
clearTimeout(this._timer); | ||
this._timer = undefined; | ||
} | ||
} | ||
} | ||
exports.BatchSpanProcessor = BatchSpanProcessor; | ||
//# sourceMappingURL=BatchSpanProcessor.js.map |
@@ -44,5 +44,3 @@ "use strict"; | ||
startSpan(name, options = {}, context = api.context.active()) { | ||
const parentContext = options.parent | ||
? getContext(options.parent) | ||
: core_1.getParentSpanContext(context); | ||
const parentContext = getParent(options, context); | ||
// make sampling decision | ||
@@ -107,2 +105,16 @@ const samplingDecision = this._sampler.shouldSample(parentContext); | ||
exports.Tracer = Tracer; | ||
/** | ||
* Get the parent to assign to a started span. If options.parent is null, | ||
* do not assign a parent. | ||
* | ||
* @param options span options | ||
* @param context context to check for parent | ||
*/ | ||
function getParent(options, context) { | ||
if (options.parent === null) | ||
return undefined; | ||
if (options.parent) | ||
return getContext(options.parent); | ||
return core_1.getParentSpanContext(context); | ||
} | ||
function getContext(span) { | ||
@@ -109,0 +121,0 @@ return isSpan(span) ? span.context() : span; |
@@ -16,2 +16,2 @@ /*! | ||
*/ | ||
export declare const VERSION = "0.5.1"; | ||
export declare const VERSION = "0.5.2"; |
@@ -19,3 +19,3 @@ "use strict"; | ||
// this is autogenerated file, see scripts/version-update.js | ||
exports.VERSION = '0.5.1'; | ||
exports.VERSION = '0.5.2'; | ||
//# sourceMappingURL=version.js.map |
{ | ||
"name": "@opentelemetry/tracing", | ||
"version": "0.5.1", | ||
"version": "0.5.2", | ||
"description": "OpenTelemetry Tracing", | ||
@@ -76,8 +76,8 @@ "main": "build/src/index.js", | ||
"dependencies": { | ||
"@opentelemetry/api": "^0.5.1", | ||
"@opentelemetry/base": "^0.5.1", | ||
"@opentelemetry/context-base": "^0.5.1", | ||
"@opentelemetry/core": "^0.5.1", | ||
"@opentelemetry/resources": "^0.5.1" | ||
"@opentelemetry/api": "^0.5.2", | ||
"@opentelemetry/base": "^0.5.2", | ||
"@opentelemetry/context-base": "^0.5.2", | ||
"@opentelemetry/core": "^0.5.2", | ||
"@opentelemetry/resources": "^0.5.2" | ||
} | ||
} |
@@ -1,2 +0,2 @@ | ||
# OpenTelemetry Tracing | ||
# OpenTelemetry Tracing SDK | ||
[![Gitter chat][gitter-image]][gitter-url] | ||
@@ -8,3 +8,3 @@ [![NPM Published Version][npm-img]][npm-url] | ||
`tracing` contains the foundation for all tracing SDKs of [opentelemetry-js](https://github.com/open-telemetry/opentelemetry-js). | ||
The `tracing` module contains the foundation for all tracing SDKs of [opentelemetry-js](https://github.com/open-telemetry/opentelemetry-js). | ||
@@ -11,0 +11,0 @@ Used standalone, this module provides methods for manual instrumentation of code, offering full control over span creation for client-side JavaScript (browser) and Node.js. |
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
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
73201
1514
0