@opentelemetry/tracing
Advanced tools
Comparing version 0.11.1-alpha.48 to 0.11.1-alpha.53
@@ -13,3 +13,2 @@ import * as api from '@opentelemetry/api'; | ||
private readonly _tracers; | ||
private _cleanNotifyOnGlobalShutdown; | ||
activeSpanProcessor: NoopSpanProcessor; | ||
@@ -34,5 +33,4 @@ readonly logger: api.Logger; | ||
register(config?: SDKRegistrationConfig): void; | ||
shutdown(cb?: () => void): void; | ||
private _shutdownActiveProcessor; | ||
shutdown(): Promise<void>; | ||
} | ||
//# sourceMappingURL=BasicTracerProvider.d.ts.map |
@@ -41,5 +41,2 @@ "use strict"; | ||
}); | ||
if (this._config.gracefulShutdown) { | ||
this._cleanNotifyOnGlobalShutdown = core_1.notifyOnGlobalShutdown(this._shutdownActiveProcessor.bind(this)); | ||
} | ||
} | ||
@@ -85,14 +82,7 @@ getTracer(name, version = '*', config) { | ||
} | ||
shutdown(cb = () => { }) { | ||
this.activeSpanProcessor.shutdown(cb); | ||
if (this._cleanNotifyOnGlobalShutdown) { | ||
this._cleanNotifyOnGlobalShutdown(); | ||
this._cleanNotifyOnGlobalShutdown = undefined; | ||
} | ||
shutdown() { | ||
return this.activeSpanProcessor.shutdown(); | ||
} | ||
_shutdownActiveProcessor() { | ||
this.activeSpanProcessor.shutdown(); | ||
} | ||
} | ||
exports.BasicTracerProvider = BasicTracerProvider; | ||
//# sourceMappingURL=BasicTracerProvider.js.map |
@@ -16,7 +16,8 @@ import { SpanProcessor } from '../SpanProcessor'; | ||
private _isShutdown; | ||
private _shuttingDownPromise; | ||
constructor(_exporter: SpanExporter, config?: BufferConfig); | ||
forceFlush(cb?: () => void): void; | ||
forceFlush(): Promise<void>; | ||
onStart(span: ReadableSpan): void; | ||
onEnd(span: ReadableSpan): void; | ||
shutdown(cb?: () => void): void; | ||
shutdown(): Promise<void>; | ||
/** Add a span in the buffer. */ | ||
@@ -23,0 +24,0 @@ private _addToBuffer; |
@@ -32,2 +32,3 @@ "use strict"; | ||
this._isShutdown = false; | ||
this._shuttingDownPromise = Promise.resolve(); | ||
this._bufferSize = | ||
@@ -40,8 +41,7 @@ config && config.bufferSize ? config.bufferSize : DEFAULT_BUFFER_SIZE; | ||
} | ||
forceFlush(cb = () => { }) { | ||
forceFlush() { | ||
if (this._isShutdown) { | ||
setTimeout(cb, 0); | ||
return; | ||
return this._shuttingDownPromise; | ||
} | ||
this._flush(cb); | ||
return this._flush(); | ||
} | ||
@@ -56,10 +56,21 @@ // does nothing. | ||
} | ||
shutdown(cb = () => { }) { | ||
shutdown() { | ||
if (this._isShutdown) { | ||
setTimeout(cb, 0); | ||
return; | ||
return this._shuttingDownPromise; | ||
} | ||
this.forceFlush(cb); | ||
this._isShutdown = true; | ||
this._exporter.shutdown(); | ||
this._shuttingDownPromise = new Promise((resolve, reject) => { | ||
Promise.resolve() | ||
.then(() => { | ||
return this._flush(); | ||
}) | ||
.then(() => { | ||
return this._exporter.shutdown(); | ||
}) | ||
.then(resolve) | ||
.catch(e => { | ||
reject(e); | ||
}); | ||
}); | ||
return this._shuttingDownPromise; | ||
} | ||
@@ -75,13 +86,21 @@ /** Add a span in the buffer. */ | ||
/** Send the span data list to exporter */ | ||
_flush(cb = () => { }) { | ||
_flush() { | ||
this._clearTimer(); | ||
if (this._finishedSpans.length === 0) { | ||
setTimeout(cb, 0); | ||
return; | ||
return Promise.resolve(); | ||
} | ||
// prevent downstream exporter calls from generating spans | ||
api_1.context.with(core_1.suppressInstrumentation(api_1.context.active()), () => { | ||
this._exporter.export(this._finishedSpans, cb); | ||
return new Promise((resolve, reject) => { | ||
// prevent downstream exporter calls from generating spans | ||
api_1.context.with(api_1.suppressInstrumentation(api_1.context.active()), () => { | ||
this._exporter.export(this._finishedSpans, result => { | ||
this._finishedSpans = []; | ||
if (result === core_1.ExportResult.SUCCESS) { | ||
resolve(); | ||
} | ||
else { | ||
reject(result); | ||
} | ||
}); | ||
}); | ||
}); | ||
this._finishedSpans = []; | ||
} | ||
@@ -92,3 +111,3 @@ _maybeStartTimer() { | ||
this._timer = setTimeout(() => { | ||
this._flush(); | ||
this._flush().catch(); | ||
}, this._bufferTimeout); | ||
@@ -95,0 +114,0 @@ core_1.unrefTimer(this._timer); |
@@ -18,3 +18,3 @@ import { SpanExporter } from './SpanExporter'; | ||
*/ | ||
shutdown(): void; | ||
shutdown(): Promise<void>; | ||
/** | ||
@@ -21,0 +21,0 @@ * converts span info into more readable format |
@@ -37,3 +37,4 @@ "use strict"; | ||
shutdown() { | ||
return this._sendSpans([]); | ||
this._sendSpans([]); | ||
return Promise.resolve(); | ||
} | ||
@@ -40,0 +41,0 @@ /** |
@@ -17,3 +17,3 @@ import { SpanExporter } from './SpanExporter'; | ||
export(spans: ReadableSpan[], resultCallback: (result: ExportResult) => void): void; | ||
shutdown(): void; | ||
shutdown(): Promise<void>; | ||
reset(): void; | ||
@@ -20,0 +20,0 @@ getFinishedSpans(): ReadableSpan[]; |
@@ -43,2 +43,3 @@ "use strict"; | ||
this._finishedSpans = []; | ||
return Promise.resolve(); | ||
} | ||
@@ -45,0 +46,0 @@ reset() { |
@@ -14,7 +14,8 @@ import { SpanProcessor } from '../SpanProcessor'; | ||
private _isShutdown; | ||
forceFlush(cb?: () => void): void; | ||
private _shuttingDownPromise; | ||
forceFlush(): Promise<void>; | ||
onStart(span: ReadableSpan): void; | ||
onEnd(span: ReadableSpan): void; | ||
shutdown(cb?: () => void): void; | ||
shutdown(): Promise<void>; | ||
} | ||
//# sourceMappingURL=SimpleSpanProcessor.d.ts.map |
@@ -20,3 +20,2 @@ "use strict"; | ||
const api_1 = require("@opentelemetry/api"); | ||
const core_1 = require("@opentelemetry/core"); | ||
/** | ||
@@ -32,6 +31,7 @@ * An implementation of the {@link SpanProcessor} that converts the {@link Span} | ||
this._isShutdown = false; | ||
this._shuttingDownPromise = Promise.resolve(); | ||
} | ||
forceFlush(cb = () => { }) { | ||
forceFlush() { | ||
// do nothing as all spans are being exported without waiting | ||
setTimeout(cb, 0); | ||
return Promise.resolve(); | ||
} | ||
@@ -45,14 +45,22 @@ // does nothing. | ||
// prevent downstream exporter calls from generating spans | ||
api_1.context.with(core_1.suppressInstrumentation(api_1.context.active()), () => { | ||
api_1.context.with(api_1.suppressInstrumentation(api_1.context.active()), () => { | ||
this._exporter.export([span], () => { }); | ||
}); | ||
} | ||
shutdown(cb = () => { }) { | ||
shutdown() { | ||
if (this._isShutdown) { | ||
setTimeout(cb, 0); | ||
return; | ||
return this._shuttingDownPromise; | ||
} | ||
this._isShutdown = true; | ||
this._exporter.shutdown(); | ||
setTimeout(cb, 0); | ||
this._shuttingDownPromise = new Promise((resolve, reject) => { | ||
Promise.resolve() | ||
.then(() => { | ||
return this._exporter.shutdown(); | ||
}) | ||
.then(resolve) | ||
.catch(e => { | ||
reject(e); | ||
}); | ||
}); | ||
return this._shuttingDownPromise; | ||
} | ||
@@ -59,0 +67,0 @@ } |
@@ -17,4 +17,4 @@ import { ExportResult } from '@opentelemetry/core'; | ||
/** Stops the exporter. */ | ||
shutdown(): void; | ||
shutdown(): Promise<void>; | ||
} | ||
//# sourceMappingURL=SpanExporter.d.ts.map |
@@ -10,7 +10,7 @@ import { SpanProcessor } from './SpanProcessor'; | ||
constructor(_spanProcessors: SpanProcessor[]); | ||
forceFlush(cb?: () => void): void; | ||
forceFlush(): Promise<void>; | ||
onStart(span: ReadableSpan): void; | ||
onEnd(span: ReadableSpan): void; | ||
shutdown(cb?: () => void): void; | ||
shutdown(): Promise<void>; | ||
} | ||
//# sourceMappingURL=MultiSpanProcessor.d.ts.map |
@@ -19,2 +19,3 @@ "use strict"; | ||
exports.MultiSpanProcessor = void 0; | ||
const core_1 = require("@opentelemetry/core"); | ||
/** | ||
@@ -28,12 +29,17 @@ * Implementation of the {@link SpanProcessor} that simply forwards all | ||
} | ||
forceFlush(cb = () => { }) { | ||
let finished = 0; | ||
const total = this._spanProcessors.length; | ||
forceFlush() { | ||
const promises = []; | ||
for (const spanProcessor of this._spanProcessors) { | ||
spanProcessor.forceFlush(() => { | ||
if (++finished === total) { | ||
cb(); | ||
} | ||
promises.push(spanProcessor.forceFlush()); | ||
} | ||
return new Promise(resolve => { | ||
Promise.all(promises) | ||
.then(() => { | ||
resolve(); | ||
}) | ||
.catch(error => { | ||
core_1.globalErrorHandler(error || new Error('MultiSpanProcessor: forceFlush failed')); | ||
resolve(); | ||
}); | ||
} | ||
}); | ||
} | ||
@@ -50,12 +56,12 @@ onStart(span) { | ||
} | ||
shutdown(cb = () => { }) { | ||
let finished = 0; | ||
const total = this._spanProcessors.length; | ||
shutdown() { | ||
const promises = []; | ||
for (const spanProcessor of this._spanProcessors) { | ||
spanProcessor.shutdown(() => { | ||
if (++finished === total) { | ||
cb(); | ||
} | ||
}); | ||
promises.push(spanProcessor.shutdown()); | ||
} | ||
return new Promise((resolve, reject) => { | ||
Promise.all(promises).then(() => { | ||
resolve(); | ||
}, reject); | ||
}); | ||
} | ||
@@ -62,0 +68,0 @@ } |
@@ -7,5 +7,5 @@ import { SpanProcessor } from './SpanProcessor'; | ||
onEnd(span: ReadableSpan): void; | ||
shutdown(cb?: () => unknown): void; | ||
forceFlush(cb?: () => unknown): void; | ||
shutdown(): Promise<void>; | ||
forceFlush(): Promise<void>; | ||
} | ||
//# sourceMappingURL=NoopSpanProcessor.d.ts.map |
@@ -23,7 +23,7 @@ "use strict"; | ||
onEnd(span) { } | ||
shutdown(cb = () => { }) { | ||
setTimeout(cb, 0); | ||
shutdown() { | ||
return Promise.resolve(); | ||
} | ||
forceFlush(cb = () => { }) { | ||
setTimeout(cb, 0); | ||
forceFlush() { | ||
return Promise.resolve(); | ||
} | ||
@@ -30,0 +30,0 @@ } |
@@ -6,2 +6,3 @@ import * as api from '@opentelemetry/api'; | ||
import { Tracer } from './Tracer'; | ||
import { AttributeValue } from '@opentelemetry/api'; | ||
/** | ||
@@ -31,3 +32,3 @@ * This class represents a span. | ||
context(): api.SpanContext; | ||
setAttribute(key: string, value: unknown): this; | ||
setAttribute(key: string, value?: AttributeValue): this; | ||
setAttributes(attributes: api.Attributes): this; | ||
@@ -34,0 +35,0 @@ /** |
@@ -54,4 +54,12 @@ "use strict"; | ||
setAttribute(key, value) { | ||
if (this._isSpanEnded()) | ||
if (value == null || this._isSpanEnded()) | ||
return this; | ||
if (key.length === 0) { | ||
this._logger.warn(`Invalid attribute key: ${key}`); | ||
return this; | ||
} | ||
if (!core_1.isAttributeValue(value)) { | ||
this._logger.warn(`Invalid attribute value set for key: ${key}`); | ||
return this; | ||
} | ||
if (Object.keys(this.attributes).length >= | ||
@@ -69,5 +77,5 @@ this._traceParams.numberOfAttributesPerSpan) { | ||
setAttributes(attributes) { | ||
Object.keys(attributes).forEach(key => { | ||
this.setAttribute(key, attributes[key]); | ||
}); | ||
for (const [k, v] of Object.entries(attributes)) { | ||
this.setAttribute(k, v); | ||
} | ||
return this; | ||
@@ -74,0 +82,0 @@ } |
@@ -10,3 +10,3 @@ import { ReadableSpan } from './export/ReadableSpan'; | ||
*/ | ||
forceFlush(callback: () => void): void; | ||
forceFlush(): Promise<void>; | ||
/** | ||
@@ -28,4 +28,4 @@ * Called when a {@link ReadableSpan} is started, if the `span.isRecording()` | ||
*/ | ||
shutdown(callback: () => void): void; | ||
shutdown(): Promise<void>; | ||
} | ||
//# sourceMappingURL=SpanProcessor.d.ts.map |
@@ -45,4 +45,4 @@ "use strict"; | ||
startSpan(name, options = {}, context = api.context.active()) { | ||
var _a, _b, _c; | ||
if (core_1.isInstrumentationSuppressed(context)) { | ||
var _a, _b; | ||
if (api.isInstrumentationSuppressed(context)) { | ||
this.logger.debug('Instrumentation suppressed, returning Noop Span'); | ||
@@ -66,3 +66,3 @@ return api.NOOP_SPAN; | ||
const links = (_b = options.links) !== null && _b !== void 0 ? _b : []; | ||
const attributes = (_c = options.attributes) !== null && _c !== void 0 ? _c : {}; | ||
const attributes = core_1.sanitizeAttributes(options.attributes); | ||
// make sampling decision | ||
@@ -91,3 +91,3 @@ const samplingResult = this._sampler.shouldSample(parentContext, traceId, name, spanKind, attributes, links); | ||
// Get the current Span from the context or null if none found. | ||
return core_1.getActiveSpan(ctx); | ||
return api.getActiveSpan(ctx); | ||
} | ||
@@ -99,3 +99,3 @@ /** | ||
// Set given span to context. | ||
return api.context.with(core_1.setActiveSpan(api.context.active(), span), fn); | ||
return api.context.with(api.setActiveSpan(api.context.active(), span), fn); | ||
} | ||
@@ -106,3 +106,5 @@ /** | ||
bind(target, span) { | ||
return api.context.bind(target, span ? core_1.setActiveSpan(api.context.active(), span) : api.context.active()); | ||
return api.context.bind(target, span | ||
? api.setActiveSpan(api.context.active(), span) | ||
: api.context.active()); | ||
} | ||
@@ -130,3 +132,3 @@ /** Returns the active {@link TraceParams}. */ | ||
return getContext(options.parent); | ||
return core_1.getParentSpanContext(context); | ||
return api.getParentSpanContext(context); | ||
} | ||
@@ -133,0 +135,0 @@ function getContext(span) { |
import { TracerConfig } from './types'; | ||
import { ParentOrElseSampler } from '@opentelemetry/core'; | ||
import { ParentBasedSampler } from '@opentelemetry/core'; | ||
/** | ||
@@ -17,4 +17,4 @@ * Function to merge Default configuration (as specified in './config') with | ||
} & { | ||
sampler: ParentOrElseSampler; | ||
sampler: ParentBasedSampler; | ||
} & TracerConfig; | ||
//# sourceMappingURL=utility.d.ts.map |
@@ -32,3 +32,5 @@ "use strict"; | ||
? { | ||
sampler: new core_1.ParentOrElseSampler(new core_1.ProbabilitySampler(otelSamplingProbability)), | ||
sampler: new core_1.ParentBasedSampler({ | ||
root: new core_1.TraceIdRatioBasedSampler(otelSamplingProbability), | ||
}), | ||
} | ||
@@ -35,0 +37,0 @@ : {}, userConfig); |
@@ -1,2 +0,2 @@ | ||
export declare const VERSION = "0.11.1-alpha.48+15174c6"; | ||
export declare const VERSION = "0.11.1-alpha.53+00a8ce7f"; | ||
//# sourceMappingURL=version.d.ts.map |
@@ -20,3 +20,3 @@ "use strict"; | ||
// this is autogenerated file, see scripts/version-update.js | ||
exports.VERSION = '0.11.1-alpha.48+15174c6'; | ||
exports.VERSION = '0.11.1-alpha.53+00a8ce7f'; | ||
//# sourceMappingURL=version.js.map |
{ | ||
"name": "@opentelemetry/tracing", | ||
"version": "0.11.1-alpha.48+15174c6", | ||
"version": "0.11.1-alpha.53+00a8ce7f", | ||
"description": "OpenTelemetry Tracing", | ||
@@ -72,3 +72,3 @@ "main": "build/src/index.js", | ||
"ts-mocha": "7.0.0", | ||
"ts-node": "8.10.2", | ||
"ts-node": "9.0.0", | ||
"typescript": "3.9.7", | ||
@@ -78,9 +78,9 @@ "webpack": "4.44.1" | ||
"dependencies": { | ||
"@opentelemetry/api": "^0.11.1-alpha.48+15174c6", | ||
"@opentelemetry/context-base": "^0.11.1-alpha.48+15174c6", | ||
"@opentelemetry/core": "^0.11.1-alpha.48+15174c6", | ||
"@opentelemetry/resources": "^0.11.1-alpha.48+15174c6", | ||
"@opentelemetry/semantic-conventions": "^0.11.1-alpha.48+15174c6" | ||
"@opentelemetry/api": "^0.11.1-alpha.53+00a8ce7f", | ||
"@opentelemetry/context-base": "^0.11.0", | ||
"@opentelemetry/core": "^0.11.1-alpha.53+00a8ce7f", | ||
"@opentelemetry/resources": "^0.11.1-alpha.53+00a8ce7f", | ||
"@opentelemetry/semantic-conventions": "^0.11.0" | ||
}, | ||
"gitHead": "15174c6647ab9863dfc1424412fa60f2fddb3351" | ||
"gitHead": "00a8ce7f982ea24bcd4bc398477112894078ab29" | ||
} |
@@ -51,3 +51,3 @@ # OpenTelemetry Tracing SDK | ||
environmentally configurable (via `OTEL_SAMPLING_PROBABILITY`) probability | ||
sampler delegate of a [ParentOrElse](https://github.com/open-telemetry/opentelemetry-specification/blob/master/specification/trace/sdk.md#parentorelse) sampler. | ||
sampler delegate of a [ParentBased](https://github.com/open-telemetry/opentelemetry-specification/blob/master/specification/trace/sdk.md#parentbased) sampler. | ||
@@ -54,0 +54,0 @@ ## Example |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
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
Manifest confusion
Supply chain riskThis package has inconsistent metadata. This could be malicious or caused by an error when publishing the package.
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
Manifest confusion
Supply chain riskThis package has inconsistent metadata. This could be malicious or caused by an error when publishing the package.
Found 1 instance in 1 package
92474
1437
+ Added@opentelemetry/semantic-conventions@0.11.0(transitive)
- Removed@opentelemetry/context-base@0.11.1-alpha.48(transitive)
- Removed@opentelemetry/semantic-conventions@0.11.1-alpha.48(transitive)