Socket
Socket
Sign inDemoInstall

@opentelemetry/sdk-trace-base

Package Overview
Dependencies
4
Maintainers
2
Versions
54
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 1.8.0 to 1.9.0

6

build/esm/BasicTracerProvider.js

@@ -155,7 +155,7 @@ /*

var _a;
return (_a = (this.constructor._registeredPropagators).get(name)) === null || _a === void 0 ? void 0 : _a();
return (_a = this.constructor._registeredPropagators.get(name)) === null || _a === void 0 ? void 0 : _a();
};
BasicTracerProvider.prototype._getSpanExporter = function (name) {
var _a;
return (_a = (this.constructor._registeredExporters).get(name)) === null || _a === void 0 ? void 0 : _a();
return (_a = this.constructor._registeredExporters.get(name)) === null || _a === void 0 ? void 0 : _a();
};

@@ -193,3 +193,3 @@ BasicTracerProvider.prototype._buildPropagatorFromEnv = function () {

var exporterName = getEnv().OTEL_TRACES_EXPORTER;
if (exporterName === 'none')
if (exporterName === 'none' || exporterName === '')
return;

@@ -196,0 +196,0 @@ var exporter = this._getSpanExporter(exporterName);

@@ -17,3 +17,3 @@ /*

import { diag } from '@opentelemetry/api';
import { getEnv, TracesSamplerValues, } from '@opentelemetry/core';
import { getEnv, TracesSamplerValues } from '@opentelemetry/core';
import { AlwaysOffSampler } from './sampler/AlwaysOffSampler';

@@ -20,0 +20,0 @@ import { AlwaysOnSampler } from './sampler/AlwaysOnSampler';

@@ -17,3 +17,3 @@ /*

import { context, diag, TraceFlags } from '@opentelemetry/api';
import { BindOnceFuture, ExportResultCode, getEnv, globalErrorHandler, suppressTracing, unrefTimer } from '@opentelemetry/core';
import { BindOnceFuture, ExportResultCode, getEnv, globalErrorHandler, suppressTracing, unrefTimer, } from '@opentelemetry/core';
/**

@@ -20,0 +20,0 @@ * Implementation of the {@link SpanProcessor} that batches spans exported by

@@ -67,3 +67,3 @@ /*

events: span.events,
links: span.links
links: span.links,
};

@@ -70,0 +70,0 @@ };

@@ -17,3 +17,3 @@ /*

import { TraceFlags } from '@opentelemetry/api';
import { internal, ExportResultCode, globalErrorHandler, BindOnceFuture } from '@opentelemetry/core';
import { internal, ExportResultCode, globalErrorHandler, BindOnceFuture, } from '@opentelemetry/core';
/**

@@ -43,3 +43,5 @@ * An implementation of the {@link SpanProcessor} that converts the {@link Span}

}
internal._export(this._exporter, [span]).then(function (result) {
internal
._export(this._exporter, [span])
.then(function (result) {
var _a;

@@ -49,3 +51,4 @@ if (result.code !== ExportResultCode.SUCCESS) {

}
}).catch(function (error) {
})
.catch(function (error) {
globalErrorHandler(error);

@@ -52,0 +55,0 @@ });

@@ -41,3 +41,4 @@ /*

var _this = this;
if ((config === null || config === void 0 ? void 0 : config.disableAutoFlushOnDocumentHide) !== true && typeof document !== 'undefined') {
if ((config === null || config === void 0 ? void 0 : config.disableAutoFlushOnDocumentHide) !== true &&
typeof document !== 'undefined') {
this._visibilityChangeListener = function () {

@@ -44,0 +45,0 @@ if (document.visibilityState === 'hidden') {

@@ -1,4 +0,3 @@

import * as api from '@opentelemetry/api';
import { Context, SpanAttributeValue } from '@opentelemetry/api';
import { Clock, InstrumentationLibrary } from '@opentelemetry/core';
import { Context, Exception, HrTime, Link, Span as APISpan, SpanAttributes, SpanAttributeValue, SpanContext, SpanKind, SpanStatus, TimeInput } from '@opentelemetry/api';
import { InstrumentationLibrary } from '@opentelemetry/core';
import { Resource } from '@opentelemetry/resources';

@@ -11,15 +10,15 @@ import { ReadableSpan } from './export/ReadableSpan';

*/
export declare class Span implements api.Span, ReadableSpan {
export declare class Span implements APISpan, ReadableSpan {
private readonly _spanContext;
readonly kind: api.SpanKind;
readonly kind: SpanKind;
readonly parentSpanId?: string;
readonly attributes: api.SpanAttributes;
readonly links: api.Link[];
readonly attributes: SpanAttributes;
readonly links: Link[];
readonly events: TimedEvent[];
readonly startTime: api.HrTime;
readonly startTime: HrTime;
readonly resource: Resource;
readonly instrumentationLibrary: InstrumentationLibrary;
name: string;
status: api.SpanStatus;
endTime: api.HrTime;
status: SpanStatus;
endTime: HrTime;
private _ended;

@@ -30,3 +29,5 @@ private _duration;

private readonly _attributeValueLengthLimit;
private readonly _clock;
private readonly _performanceStartTime;
private readonly _performanceOffset;
private readonly _startTimeProvided;
/**

@@ -37,6 +38,6 @@ * Constructs a new Span instance.

* */
constructor(parentTracer: Tracer, context: Context, spanName: string, spanContext: api.SpanContext, kind: api.SpanKind, parentSpanId?: string, links?: api.Link[], startTime?: api.TimeInput, clock?: Clock);
spanContext(): api.SpanContext;
constructor(parentTracer: Tracer, context: Context, spanName: string, spanContext: SpanContext, kind: SpanKind, parentSpanId?: string, links?: Link[], startTime?: TimeInput, _deprecatedClock?: unknown);
spanContext(): SpanContext;
setAttribute(key: string, value?: SpanAttributeValue): this;
setAttributes(attributes: api.SpanAttributes): this;
setAttributes(attributes: SpanAttributes): this;
/**

@@ -47,11 +48,12 @@ *

* if type is {@type TimeInput} and 3rd param is undefined
* @param [startTime] Specified start time for the event
* @param [timeStamp] Specified time stamp for the event
*/
addEvent(name: string, attributesOrStartTime?: api.SpanAttributes | api.TimeInput, startTime?: api.TimeInput): this;
setStatus(status: api.SpanStatus): this;
addEvent(name: string, attributesOrStartTime?: SpanAttributes | TimeInput, timeStamp?: TimeInput): this;
setStatus(status: SpanStatus): this;
updateName(name: string): this;
end(endTime?: api.TimeInput): void;
end(endTime?: TimeInput): void;
private _getTime;
isRecording(): boolean;
recordException(exception: api.Exception, time?: api.TimeInput): void;
get duration(): api.HrTime;
recordException(exception: Exception, time?: TimeInput): void;
get duration(): HrTime;
get ended(): boolean;

@@ -58,0 +60,0 @@ private _isSpanEnded;

@@ -43,4 +43,4 @@ /*

};
import * as api from '@opentelemetry/api';
import { hrTimeDuration, isAttributeValue, isTimeInput, otperformance, sanitizeAttributes, timeInputToHrTime } from '@opentelemetry/core';
import { diag, SpanStatusCode, } from '@opentelemetry/api';
import { addHrTimes, millisToHrTime, getTimeOrigin, hrTime, hrTimeDuration, isAttributeValue, isTimeInput, isTimeInputHrTime, otperformance, sanitizeAttributes, } from '@opentelemetry/core';
import { SemanticAttributes } from '@opentelemetry/semantic-conventions';

@@ -57,5 +57,5 @@ import { ExceptionEventName } from './enums';

* */
function Span(parentTracer, context, spanName, spanContext, kind, parentSpanId, links, startTime, clock) {
function Span(parentTracer, context, spanName, spanContext, kind, parentSpanId, links, startTime, _deprecatedClock // keeping this argument even though it is unused to ensure backwards compatibility
) {
if (links === void 0) { links = []; }
if (clock === void 0) { clock = otperformance; }
this.attributes = {};

@@ -65,3 +65,3 @@ this.links = [];

this.status = {
code: api.SpanStatusCode.UNSET,
code: SpanStatusCode.UNSET,
};

@@ -71,3 +71,2 @@ this.endTime = [0, 0];

this._duration = [-1, -1];
this._clock = clock;
this.name = spanName;

@@ -78,3 +77,8 @@ this._spanContext = spanContext;

this.links = links;
this.startTime = timeInputToHrTime(startTime !== null && startTime !== void 0 ? startTime : clock.now());
var now = Date.now();
this._performanceStartTime = otperformance.now();
this._performanceOffset =
now - (this._performanceStartTime + getTimeOrigin());
this._startTimeProvided = startTime != null;
this.startTime = this._getTime(startTime !== null && startTime !== void 0 ? startTime : now);
this.resource = parentTracer.resource;

@@ -85,3 +89,4 @@ this.instrumentationLibrary = parentTracer.instrumentationLibrary;

this._spanProcessor.onStart(this, context);
this._attributeValueLengthLimit = this._spanLimits.attributeValueLengthLimit || 0;
this._attributeValueLengthLimit =
this._spanLimits.attributeValueLengthLimit || 0;
}

@@ -95,7 +100,7 @@ Span.prototype.spanContext = function () {

if (key.length === 0) {
api.diag.warn("Invalid attribute key: " + key);
diag.warn("Invalid attribute key: " + key);
return this;
}
if (!isAttributeValue(value)) {
api.diag.warn("Invalid attribute value set for key: " + key);
diag.warn("Invalid attribute value set for key: " + key);
return this;

@@ -133,24 +138,21 @@ }

* if type is {@type TimeInput} and 3rd param is undefined
* @param [startTime] Specified start time for the event
* @param [timeStamp] Specified time stamp for the event
*/
Span.prototype.addEvent = function (name, attributesOrStartTime, startTime) {
Span.prototype.addEvent = function (name, attributesOrStartTime, timeStamp) {
if (this._isSpanEnded())
return this;
if (this._spanLimits.eventCountLimit === 0) {
api.diag.warn('No events allowed.');
diag.warn('No events allowed.');
return this;
}
if (this.events.length >= this._spanLimits.eventCountLimit) {
api.diag.warn('Dropping extra events.');
diag.warn('Dropping extra events.');
this.events.shift();
}
if (isTimeInput(attributesOrStartTime)) {
if (typeof startTime === 'undefined') {
startTime = attributesOrStartTime;
if (!isTimeInput(timeStamp)) {
timeStamp = attributesOrStartTime;
}
attributesOrStartTime = undefined;
}
if (typeof startTime === 'undefined') {
startTime = this._clock.now();
}
var attributes = sanitizeAttributes(attributesOrStartTime);

@@ -160,3 +162,3 @@ this.events.push({

attributes: attributes,
time: timeInputToHrTime(startTime),
time: this._getTime(timeStamp),
});

@@ -179,10 +181,10 @@ return this;

if (this._isSpanEnded()) {
api.diag.error('You can only call end() on a span once.');
diag.error('You can only call end() on a span once.');
return;
}
this._ended = true;
this.endTime = timeInputToHrTime(endTime !== null && endTime !== void 0 ? endTime : this._clock.now());
this.endTime = this._getTime(endTime);
this._duration = hrTimeDuration(this.startTime, this.endTime);
if (this._duration[0] < 0) {
api.diag.warn('Inconsistent start and end time, startTime > endTime. Setting span duration to 0ms.', this.startTime, this.endTime);
diag.warn('Inconsistent start and end time, startTime > endTime. Setting span duration to 0ms.', this.startTime, this.endTime);
this.endTime = this.startTime.slice();

@@ -193,2 +195,25 @@ this._duration = [0, 0];

};
Span.prototype._getTime = function (inp) {
if (typeof inp === 'number' && inp < otperformance.now()) {
// must be a performance timestamp
// apply correction and convert to hrtime
return hrTime(inp + this._performanceOffset);
}
if (typeof inp === 'number') {
return millisToHrTime(inp);
}
if (inp instanceof Date) {
return millisToHrTime(inp.getTime());
}
if (isTimeInputHrTime(inp)) {
return inp;
}
if (this._startTimeProvided) {
// if user provided a time for the start manually
// we can't use duration to calculate event/end times
return millisToHrTime(Date.now());
}
var msDuration = otperformance.now() - this._performanceStartTime;
return addHrTimes(this.startTime, millisToHrTime(msDuration));
};
Span.prototype.isRecording = function () {

@@ -198,3 +223,2 @@ return this._ended === false;

Span.prototype.recordException = function (exception, time) {
if (time === void 0) { time = this._clock.now(); }
var attributes = {};

@@ -206,3 +230,4 @@ if (typeof exception === 'string') {

if (exception.code) {
attributes[SemanticAttributes.EXCEPTION_TYPE] = exception.code.toString();
attributes[SemanticAttributes.EXCEPTION_TYPE] =
exception.code.toString();
}

@@ -225,3 +250,3 @@ else if (exception.name) {

else {
api.diag.warn("Failed to record an exception " + exception);
diag.warn("Failed to record an exception " + exception);
}

@@ -245,3 +270,3 @@ };

if (this._ended) {
api.diag.warn("Can not execute the operation on ended Span {traceId: " + this._spanContext.traceId + ", spanId: " + this._spanContext.spanId + "}");
diag.warn("Can not execute the operation on ended Span {traceId: " + this._spanContext.traceId + ", spanId: " + this._spanContext.spanId + "}");
}

@@ -277,3 +302,3 @@ return this._ended;

// Negative values are invalid, so do not truncate
api.diag.warn("Attribute value limit must be positive, got " + limit);
diag.warn("Attribute value limit must be positive, got " + limit);
return value;

@@ -287,3 +312,5 @@ }

if (Array.isArray(value)) {
return value.map(function (val) { return typeof val === 'string' ? _this._truncateToLimitUtil(val, limit) : val; });
return value.map(function (val) {
return typeof val === 'string' ? _this._truncateToLimitUtil(val, limit) : val;
});
}

@@ -290,0 +317,0 @@ // Other types, no need to apply value length limit

@@ -61,3 +61,4 @@ /*

var parentSpanId;
if (!parentSpanContext || !api.trace.isSpanContextValid(parentSpanContext)) {
if (!parentSpanContext ||
!api.trace.isSpanContextValid(parentSpanContext)) {
// New root span.

@@ -64,0 +65,0 @@ traceId = this._idGenerator.generateTraceId();

@@ -1,2 +0,2 @@

export declare const VERSION = "1.8.0";
export declare const VERSION = "1.9.0";
//# sourceMappingURL=version.d.ts.map

@@ -17,3 +17,3 @@ /*

// this is autogenerated file, see scripts/version-update.js
export var VERSION = '1.8.0';
export var VERSION = '1.9.0';
//# sourceMappingURL=version.js.map

@@ -151,7 +151,7 @@ /*

var _a;
return (_a = (this.constructor._registeredPropagators).get(name)) === null || _a === void 0 ? void 0 : _a();
return (_a = this.constructor._registeredPropagators.get(name)) === null || _a === void 0 ? void 0 : _a();
}
_getSpanExporter(name) {
var _a;
return (_a = (this.constructor._registeredExporters).get(name)) === null || _a === void 0 ? void 0 : _a();
return (_a = this.constructor._registeredExporters.get(name)) === null || _a === void 0 ? void 0 : _a();
}

@@ -188,3 +188,3 @@ _buildPropagatorFromEnv() {

const exporterName = getEnv().OTEL_TRACES_EXPORTER;
if (exporterName === 'none')
if (exporterName === 'none' || exporterName === '')
return;

@@ -191,0 +191,0 @@ const exporter = this._getSpanExporter(exporterName);

@@ -17,3 +17,3 @@ /*

import { diag } from '@opentelemetry/api';
import { getEnv, TracesSamplerValues, } from '@opentelemetry/core';
import { getEnv, TracesSamplerValues } from '@opentelemetry/core';
import { AlwaysOffSampler } from './sampler/AlwaysOffSampler';

@@ -20,0 +20,0 @@ import { AlwaysOnSampler } from './sampler/AlwaysOnSampler';

@@ -17,3 +17,3 @@ /*

import { context, diag, TraceFlags } from '@opentelemetry/api';
import { BindOnceFuture, ExportResultCode, getEnv, globalErrorHandler, suppressTracing, unrefTimer } from '@opentelemetry/core';
import { BindOnceFuture, ExportResultCode, getEnv, globalErrorHandler, suppressTracing, unrefTimer, } from '@opentelemetry/core';
/**

@@ -20,0 +20,0 @@ * Implementation of the {@link SpanProcessor} that batches spans exported by

@@ -54,3 +54,3 @@ /*

events: span.events,
links: span.links
links: span.links,
};

@@ -57,0 +57,0 @@ }

@@ -17,3 +17,3 @@ /*

import { TraceFlags } from '@opentelemetry/api';
import { internal, ExportResultCode, globalErrorHandler, BindOnceFuture } from '@opentelemetry/core';
import { internal, ExportResultCode, globalErrorHandler, BindOnceFuture, } from '@opentelemetry/core';
/**

@@ -43,3 +43,5 @@ * An implementation of the {@link SpanProcessor} that converts the {@link Span}

}
internal._export(this._exporter, [span]).then((result) => {
internal
._export(this._exporter, [span])
.then((result) => {
var _a;

@@ -49,3 +51,4 @@ if (result.code !== ExportResultCode.SUCCESS) {

}
}).catch(error => {
})
.catch(error => {
globalErrorHandler(error);

@@ -52,0 +55,0 @@ });

@@ -23,3 +23,4 @@ /*

onInit(config) {
if ((config === null || config === void 0 ? void 0 : config.disableAutoFlushOnDocumentHide) !== true && typeof document !== 'undefined') {
if ((config === null || config === void 0 ? void 0 : config.disableAutoFlushOnDocumentHide) !== true &&
typeof document !== 'undefined') {
this._visibilityChangeListener = () => {

@@ -26,0 +27,0 @@ if (document.visibilityState === 'hidden') {

@@ -1,4 +0,3 @@

import * as api from '@opentelemetry/api';
import { Context, SpanAttributeValue } from '@opentelemetry/api';
import { Clock, InstrumentationLibrary } from '@opentelemetry/core';
import { Context, Exception, HrTime, Link, Span as APISpan, SpanAttributes, SpanAttributeValue, SpanContext, SpanKind, SpanStatus, TimeInput } from '@opentelemetry/api';
import { InstrumentationLibrary } from '@opentelemetry/core';
import { Resource } from '@opentelemetry/resources';

@@ -11,15 +10,15 @@ import { ReadableSpan } from './export/ReadableSpan';

*/
export declare class Span implements api.Span, ReadableSpan {
export declare class Span implements APISpan, ReadableSpan {
private readonly _spanContext;
readonly kind: api.SpanKind;
readonly kind: SpanKind;
readonly parentSpanId?: string;
readonly attributes: api.SpanAttributes;
readonly links: api.Link[];
readonly attributes: SpanAttributes;
readonly links: Link[];
readonly events: TimedEvent[];
readonly startTime: api.HrTime;
readonly startTime: HrTime;
readonly resource: Resource;
readonly instrumentationLibrary: InstrumentationLibrary;
name: string;
status: api.SpanStatus;
endTime: api.HrTime;
status: SpanStatus;
endTime: HrTime;
private _ended;

@@ -30,3 +29,5 @@ private _duration;

private readonly _attributeValueLengthLimit;
private readonly _clock;
private readonly _performanceStartTime;
private readonly _performanceOffset;
private readonly _startTimeProvided;
/**

@@ -37,6 +38,6 @@ * Constructs a new Span instance.

* */
constructor(parentTracer: Tracer, context: Context, spanName: string, spanContext: api.SpanContext, kind: api.SpanKind, parentSpanId?: string, links?: api.Link[], startTime?: api.TimeInput, clock?: Clock);
spanContext(): api.SpanContext;
constructor(parentTracer: Tracer, context: Context, spanName: string, spanContext: SpanContext, kind: SpanKind, parentSpanId?: string, links?: Link[], startTime?: TimeInput, _deprecatedClock?: unknown);
spanContext(): SpanContext;
setAttribute(key: string, value?: SpanAttributeValue): this;
setAttributes(attributes: api.SpanAttributes): this;
setAttributes(attributes: SpanAttributes): this;
/**

@@ -47,11 +48,12 @@ *

* if type is {@type TimeInput} and 3rd param is undefined
* @param [startTime] Specified start time for the event
* @param [timeStamp] Specified time stamp for the event
*/
addEvent(name: string, attributesOrStartTime?: api.SpanAttributes | api.TimeInput, startTime?: api.TimeInput): this;
setStatus(status: api.SpanStatus): this;
addEvent(name: string, attributesOrStartTime?: SpanAttributes | TimeInput, timeStamp?: TimeInput): this;
setStatus(status: SpanStatus): this;
updateName(name: string): this;
end(endTime?: api.TimeInput): void;
end(endTime?: TimeInput): void;
private _getTime;
isRecording(): boolean;
recordException(exception: api.Exception, time?: api.TimeInput): void;
get duration(): api.HrTime;
recordException(exception: Exception, time?: TimeInput): void;
get duration(): HrTime;
get ended(): boolean;

@@ -58,0 +60,0 @@ private _isSpanEnded;

@@ -16,4 +16,4 @@ /*

*/
import * as api from '@opentelemetry/api';
import { hrTimeDuration, isAttributeValue, isTimeInput, otperformance, sanitizeAttributes, timeInputToHrTime } from '@opentelemetry/core';
import { diag, SpanStatusCode, } from '@opentelemetry/api';
import { addHrTimes, millisToHrTime, getTimeOrigin, hrTime, hrTimeDuration, isAttributeValue, isTimeInput, isTimeInputHrTime, otperformance, sanitizeAttributes, } from '@opentelemetry/core';
import { SemanticAttributes } from '@opentelemetry/semantic-conventions';

@@ -30,3 +30,4 @@ import { ExceptionEventName } from './enums';

* */
constructor(parentTracer, context, spanName, spanContext, kind, parentSpanId, links = [], startTime, clock = otperformance) {
constructor(parentTracer, context, spanName, spanContext, kind, parentSpanId, links = [], startTime, _deprecatedClock // keeping this argument even though it is unused to ensure backwards compatibility
) {
this.attributes = {};

@@ -36,3 +37,3 @@ this.links = [];

this.status = {
code: api.SpanStatusCode.UNSET,
code: SpanStatusCode.UNSET,
};

@@ -42,3 +43,2 @@ this.endTime = [0, 0];

this._duration = [-1, -1];
this._clock = clock;
this.name = spanName;

@@ -49,3 +49,8 @@ this._spanContext = spanContext;

this.links = links;
this.startTime = timeInputToHrTime(startTime !== null && startTime !== void 0 ? startTime : clock.now());
const now = Date.now();
this._performanceStartTime = otperformance.now();
this._performanceOffset =
now - (this._performanceStartTime + getTimeOrigin());
this._startTimeProvided = startTime != null;
this.startTime = this._getTime(startTime !== null && startTime !== void 0 ? startTime : now);
this.resource = parentTracer.resource;

@@ -56,3 +61,4 @@ this.instrumentationLibrary = parentTracer.instrumentationLibrary;

this._spanProcessor.onStart(this, context);
this._attributeValueLengthLimit = this._spanLimits.attributeValueLengthLimit || 0;
this._attributeValueLengthLimit =
this._spanLimits.attributeValueLengthLimit || 0;
}

@@ -66,7 +72,7 @@ spanContext() {

if (key.length === 0) {
api.diag.warn(`Invalid attribute key: ${key}`);
diag.warn(`Invalid attribute key: ${key}`);
return this;
}
if (!isAttributeValue(value)) {
api.diag.warn(`Invalid attribute value set for key: ${key}`);
diag.warn(`Invalid attribute value set for key: ${key}`);
return this;

@@ -93,24 +99,21 @@ }

* if type is {@type TimeInput} and 3rd param is undefined
* @param [startTime] Specified start time for the event
* @param [timeStamp] Specified time stamp for the event
*/
addEvent(name, attributesOrStartTime, startTime) {
addEvent(name, attributesOrStartTime, timeStamp) {
if (this._isSpanEnded())
return this;
if (this._spanLimits.eventCountLimit === 0) {
api.diag.warn('No events allowed.');
diag.warn('No events allowed.');
return this;
}
if (this.events.length >= this._spanLimits.eventCountLimit) {
api.diag.warn('Dropping extra events.');
diag.warn('Dropping extra events.');
this.events.shift();
}
if (isTimeInput(attributesOrStartTime)) {
if (typeof startTime === 'undefined') {
startTime = attributesOrStartTime;
if (!isTimeInput(timeStamp)) {
timeStamp = attributesOrStartTime;
}
attributesOrStartTime = undefined;
}
if (typeof startTime === 'undefined') {
startTime = this._clock.now();
}
const attributes = sanitizeAttributes(attributesOrStartTime);

@@ -120,3 +123,3 @@ this.events.push({

attributes,
time: timeInputToHrTime(startTime),
time: this._getTime(timeStamp),
});

@@ -139,10 +142,10 @@ return this;

if (this._isSpanEnded()) {
api.diag.error('You can only call end() on a span once.');
diag.error('You can only call end() on a span once.');
return;
}
this._ended = true;
this.endTime = timeInputToHrTime(endTime !== null && endTime !== void 0 ? endTime : this._clock.now());
this.endTime = this._getTime(endTime);
this._duration = hrTimeDuration(this.startTime, this.endTime);
if (this._duration[0] < 0) {
api.diag.warn('Inconsistent start and end time, startTime > endTime. Setting span duration to 0ms.', this.startTime, this.endTime);
diag.warn('Inconsistent start and end time, startTime > endTime. Setting span duration to 0ms.', this.startTime, this.endTime);
this.endTime = this.startTime.slice();

@@ -153,6 +156,29 @@ this._duration = [0, 0];

}
_getTime(inp) {
if (typeof inp === 'number' && inp < otperformance.now()) {
// must be a performance timestamp
// apply correction and convert to hrtime
return hrTime(inp + this._performanceOffset);
}
if (typeof inp === 'number') {
return millisToHrTime(inp);
}
if (inp instanceof Date) {
return millisToHrTime(inp.getTime());
}
if (isTimeInputHrTime(inp)) {
return inp;
}
if (this._startTimeProvided) {
// if user provided a time for the start manually
// we can't use duration to calculate event/end times
return millisToHrTime(Date.now());
}
const msDuration = otperformance.now() - this._performanceStartTime;
return addHrTimes(this.startTime, millisToHrTime(msDuration));
}
isRecording() {
return this._ended === false;
}
recordException(exception, time = this._clock.now()) {
recordException(exception, time) {
const attributes = {};

@@ -164,3 +190,4 @@ if (typeof exception === 'string') {

if (exception.code) {
attributes[SemanticAttributes.EXCEPTION_TYPE] = exception.code.toString();
attributes[SemanticAttributes.EXCEPTION_TYPE] =
exception.code.toString();
}

@@ -183,3 +210,3 @@ else if (exception.name) {

else {
api.diag.warn(`Failed to record an exception ${exception}`);
diag.warn(`Failed to record an exception ${exception}`);
}

@@ -195,3 +222,3 @@ }

if (this._ended) {
api.diag.warn(`Can not execute the operation on ended Span {traceId: ${this._spanContext.traceId}, spanId: ${this._spanContext.spanId}}`);
diag.warn(`Can not execute the operation on ended Span {traceId: ${this._spanContext.traceId}, spanId: ${this._spanContext.spanId}}`);
}

@@ -226,3 +253,3 @@ return this._ended;

// Negative values are invalid, so do not truncate
api.diag.warn(`Attribute value limit must be positive, got ${limit}`);
diag.warn(`Attribute value limit must be positive, got ${limit}`);
return value;

@@ -229,0 +256,0 @@ }

@@ -59,3 +59,4 @@ /*

let parentSpanId;
if (!parentSpanContext || !api.trace.isSpanContextValid(parentSpanContext)) {
if (!parentSpanContext ||
!api.trace.isSpanContextValid(parentSpanContext)) {
// New root span.

@@ -62,0 +63,0 @@ traceId = this._idGenerator.generateTraceId();

@@ -1,2 +0,2 @@

export declare const VERSION = "1.8.0";
export declare const VERSION = "1.9.0";
//# sourceMappingURL=version.d.ts.map

@@ -17,3 +17,3 @@ /*

// this is autogenerated file, see scripts/version-update.js
export const VERSION = '1.8.0';
export const VERSION = '1.9.0';
//# sourceMappingURL=version.js.map

@@ -154,7 +154,7 @@ "use strict";

var _a;
return (_a = (this.constructor._registeredPropagators).get(name)) === null || _a === void 0 ? void 0 : _a();
return (_a = this.constructor._registeredPropagators.get(name)) === null || _a === void 0 ? void 0 : _a();
}
_getSpanExporter(name) {
var _a;
return (_a = (this.constructor._registeredExporters).get(name)) === null || _a === void 0 ? void 0 : _a();
return (_a = this.constructor._registeredExporters.get(name)) === null || _a === void 0 ? void 0 : _a();
}

@@ -191,3 +191,3 @@ _buildPropagatorFromEnv() {

const exporterName = (0, core_1.getEnv)().OTEL_TRACES_EXPORTER;
if (exporterName === 'none')
if (exporterName === 'none' || exporterName === '')
return;

@@ -194,0 +194,0 @@ const exporter = this._getSpanExporter(exporterName);

@@ -57,3 +57,3 @@ "use strict";

events: span.events,
links: span.links
links: span.links,
};

@@ -60,0 +60,0 @@ }

@@ -45,3 +45,5 @@ "use strict";

}
core_1.internal._export(this._exporter, [span]).then((result) => {
core_1.internal
._export(this._exporter, [span])
.then((result) => {
var _a;

@@ -51,3 +53,4 @@ if (result.code !== core_1.ExportResultCode.SUCCESS) {

}
}).catch(error => {
})
.catch(error => {
(0, core_1.globalErrorHandler)(error);

@@ -54,0 +57,0 @@ });

@@ -26,3 +26,4 @@ "use strict";

onInit(config) {
if ((config === null || config === void 0 ? void 0 : config.disableAutoFlushOnDocumentHide) !== true && typeof document !== 'undefined') {
if ((config === null || config === void 0 ? void 0 : config.disableAutoFlushOnDocumentHide) !== true &&
typeof document !== 'undefined') {
this._visibilityChangeListener = () => {

@@ -29,0 +30,0 @@ if (document.visibilityState === 'hidden') {

@@ -1,4 +0,3 @@

import * as api from '@opentelemetry/api';
import { Context, SpanAttributeValue } from '@opentelemetry/api';
import { Clock, InstrumentationLibrary } from '@opentelemetry/core';
import { Context, Exception, HrTime, Link, Span as APISpan, SpanAttributes, SpanAttributeValue, SpanContext, SpanKind, SpanStatus, TimeInput } from '@opentelemetry/api';
import { InstrumentationLibrary } from '@opentelemetry/core';
import { Resource } from '@opentelemetry/resources';

@@ -11,15 +10,15 @@ import { ReadableSpan } from './export/ReadableSpan';

*/
export declare class Span implements api.Span, ReadableSpan {
export declare class Span implements APISpan, ReadableSpan {
private readonly _spanContext;
readonly kind: api.SpanKind;
readonly kind: SpanKind;
readonly parentSpanId?: string;
readonly attributes: api.SpanAttributes;
readonly links: api.Link[];
readonly attributes: SpanAttributes;
readonly links: Link[];
readonly events: TimedEvent[];
readonly startTime: api.HrTime;
readonly startTime: HrTime;
readonly resource: Resource;
readonly instrumentationLibrary: InstrumentationLibrary;
name: string;
status: api.SpanStatus;
endTime: api.HrTime;
status: SpanStatus;
endTime: HrTime;
private _ended;

@@ -30,3 +29,5 @@ private _duration;

private readonly _attributeValueLengthLimit;
private readonly _clock;
private readonly _performanceStartTime;
private readonly _performanceOffset;
private readonly _startTimeProvided;
/**

@@ -37,6 +38,6 @@ * Constructs a new Span instance.

* */
constructor(parentTracer: Tracer, context: Context, spanName: string, spanContext: api.SpanContext, kind: api.SpanKind, parentSpanId?: string, links?: api.Link[], startTime?: api.TimeInput, clock?: Clock);
spanContext(): api.SpanContext;
constructor(parentTracer: Tracer, context: Context, spanName: string, spanContext: SpanContext, kind: SpanKind, parentSpanId?: string, links?: Link[], startTime?: TimeInput, _deprecatedClock?: unknown);
spanContext(): SpanContext;
setAttribute(key: string, value?: SpanAttributeValue): this;
setAttributes(attributes: api.SpanAttributes): this;
setAttributes(attributes: SpanAttributes): this;
/**

@@ -47,11 +48,12 @@ *

* if type is {@type TimeInput} and 3rd param is undefined
* @param [startTime] Specified start time for the event
* @param [timeStamp] Specified time stamp for the event
*/
addEvent(name: string, attributesOrStartTime?: api.SpanAttributes | api.TimeInput, startTime?: api.TimeInput): this;
setStatus(status: api.SpanStatus): this;
addEvent(name: string, attributesOrStartTime?: SpanAttributes | TimeInput, timeStamp?: TimeInput): this;
setStatus(status: SpanStatus): this;
updateName(name: string): this;
end(endTime?: api.TimeInput): void;
end(endTime?: TimeInput): void;
private _getTime;
isRecording(): boolean;
recordException(exception: api.Exception, time?: api.TimeInput): void;
get duration(): api.HrTime;
recordException(exception: Exception, time?: TimeInput): void;
get duration(): HrTime;
get ended(): boolean;

@@ -58,0 +60,0 @@ private _isSpanEnded;

@@ -19,3 +19,3 @@ "use strict";

exports.Span = void 0;
const api = require("@opentelemetry/api");
const api_1 = require("@opentelemetry/api");
const core_1 = require("@opentelemetry/core");

@@ -33,3 +33,4 @@ const semantic_conventions_1 = require("@opentelemetry/semantic-conventions");

* */
constructor(parentTracer, context, spanName, spanContext, kind, parentSpanId, links = [], startTime, clock = core_1.otperformance) {
constructor(parentTracer, context, spanName, spanContext, kind, parentSpanId, links = [], startTime, _deprecatedClock // keeping this argument even though it is unused to ensure backwards compatibility
) {
this.attributes = {};

@@ -39,3 +40,3 @@ this.links = [];

this.status = {
code: api.SpanStatusCode.UNSET,
code: api_1.SpanStatusCode.UNSET,
};

@@ -45,3 +46,2 @@ this.endTime = [0, 0];

this._duration = [-1, -1];
this._clock = clock;
this.name = spanName;

@@ -52,3 +52,8 @@ this._spanContext = spanContext;

this.links = links;
this.startTime = (0, core_1.timeInputToHrTime)(startTime !== null && startTime !== void 0 ? startTime : clock.now());
const now = Date.now();
this._performanceStartTime = core_1.otperformance.now();
this._performanceOffset =
now - (this._performanceStartTime + (0, core_1.getTimeOrigin)());
this._startTimeProvided = startTime != null;
this.startTime = this._getTime(startTime !== null && startTime !== void 0 ? startTime : now);
this.resource = parentTracer.resource;

@@ -59,3 +64,4 @@ this.instrumentationLibrary = parentTracer.instrumentationLibrary;

this._spanProcessor.onStart(this, context);
this._attributeValueLengthLimit = this._spanLimits.attributeValueLengthLimit || 0;
this._attributeValueLengthLimit =
this._spanLimits.attributeValueLengthLimit || 0;
}

@@ -69,7 +75,7 @@ spanContext() {

if (key.length === 0) {
api.diag.warn(`Invalid attribute key: ${key}`);
api_1.diag.warn(`Invalid attribute key: ${key}`);
return this;
}
if (!(0, core_1.isAttributeValue)(value)) {
api.diag.warn(`Invalid attribute value set for key: ${key}`);
api_1.diag.warn(`Invalid attribute value set for key: ${key}`);
return this;

@@ -96,24 +102,21 @@ }

* if type is {@type TimeInput} and 3rd param is undefined
* @param [startTime] Specified start time for the event
* @param [timeStamp] Specified time stamp for the event
*/
addEvent(name, attributesOrStartTime, startTime) {
addEvent(name, attributesOrStartTime, timeStamp) {
if (this._isSpanEnded())
return this;
if (this._spanLimits.eventCountLimit === 0) {
api.diag.warn('No events allowed.');
api_1.diag.warn('No events allowed.');
return this;
}
if (this.events.length >= this._spanLimits.eventCountLimit) {
api.diag.warn('Dropping extra events.');
api_1.diag.warn('Dropping extra events.');
this.events.shift();
}
if ((0, core_1.isTimeInput)(attributesOrStartTime)) {
if (typeof startTime === 'undefined') {
startTime = attributesOrStartTime;
if (!(0, core_1.isTimeInput)(timeStamp)) {
timeStamp = attributesOrStartTime;
}
attributesOrStartTime = undefined;
}
if (typeof startTime === 'undefined') {
startTime = this._clock.now();
}
const attributes = (0, core_1.sanitizeAttributes)(attributesOrStartTime);

@@ -123,3 +126,3 @@ this.events.push({

attributes,
time: (0, core_1.timeInputToHrTime)(startTime),
time: this._getTime(timeStamp),
});

@@ -142,10 +145,10 @@ return this;

if (this._isSpanEnded()) {
api.diag.error('You can only call end() on a span once.');
api_1.diag.error('You can only call end() on a span once.');
return;
}
this._ended = true;
this.endTime = (0, core_1.timeInputToHrTime)(endTime !== null && endTime !== void 0 ? endTime : this._clock.now());
this.endTime = this._getTime(endTime);
this._duration = (0, core_1.hrTimeDuration)(this.startTime, this.endTime);
if (this._duration[0] < 0) {
api.diag.warn('Inconsistent start and end time, startTime > endTime. Setting span duration to 0ms.', this.startTime, this.endTime);
api_1.diag.warn('Inconsistent start and end time, startTime > endTime. Setting span duration to 0ms.', this.startTime, this.endTime);
this.endTime = this.startTime.slice();

@@ -156,6 +159,29 @@ this._duration = [0, 0];

}
_getTime(inp) {
if (typeof inp === 'number' && inp < core_1.otperformance.now()) {
// must be a performance timestamp
// apply correction and convert to hrtime
return (0, core_1.hrTime)(inp + this._performanceOffset);
}
if (typeof inp === 'number') {
return (0, core_1.millisToHrTime)(inp);
}
if (inp instanceof Date) {
return (0, core_1.millisToHrTime)(inp.getTime());
}
if ((0, core_1.isTimeInputHrTime)(inp)) {
return inp;
}
if (this._startTimeProvided) {
// if user provided a time for the start manually
// we can't use duration to calculate event/end times
return (0, core_1.millisToHrTime)(Date.now());
}
const msDuration = core_1.otperformance.now() - this._performanceStartTime;
return (0, core_1.addHrTimes)(this.startTime, (0, core_1.millisToHrTime)(msDuration));
}
isRecording() {
return this._ended === false;
}
recordException(exception, time = this._clock.now()) {
recordException(exception, time) {
const attributes = {};

@@ -167,3 +193,4 @@ if (typeof exception === 'string') {

if (exception.code) {
attributes[semantic_conventions_1.SemanticAttributes.EXCEPTION_TYPE] = exception.code.toString();
attributes[semantic_conventions_1.SemanticAttributes.EXCEPTION_TYPE] =
exception.code.toString();
}

@@ -186,3 +213,3 @@ else if (exception.name) {

else {
api.diag.warn(`Failed to record an exception ${exception}`);
api_1.diag.warn(`Failed to record an exception ${exception}`);
}

@@ -198,3 +225,3 @@ }

if (this._ended) {
api.diag.warn(`Can not execute the operation on ended Span {traceId: ${this._spanContext.traceId}, spanId: ${this._spanContext.spanId}}`);
api_1.diag.warn(`Can not execute the operation on ended Span {traceId: ${this._spanContext.traceId}, spanId: ${this._spanContext.spanId}}`);
}

@@ -229,3 +256,3 @@ return this._ended;

// Negative values are invalid, so do not truncate
api.diag.warn(`Attribute value limit must be positive, got ${limit}`);
api_1.diag.warn(`Attribute value limit must be positive, got ${limit}`);
return value;

@@ -232,0 +259,0 @@ }

@@ -62,3 +62,4 @@ "use strict";

let parentSpanId;
if (!parentSpanContext || !api.trace.isSpanContextValid(parentSpanContext)) {
if (!parentSpanContext ||
!api.trace.isSpanContextValid(parentSpanContext)) {
// New root span.

@@ -65,0 +66,0 @@ traceId = this._idGenerator.generateTraceId();

@@ -1,2 +0,2 @@

export declare const VERSION = "1.8.0";
export declare const VERSION = "1.9.0";
//# sourceMappingURL=version.d.ts.map

@@ -20,3 +20,3 @@ "use strict";

// this is autogenerated file, see scripts/version-update.js
exports.VERSION = '1.8.0';
exports.VERSION = '1.9.0';
//# sourceMappingURL=version.js.map
{
"name": "@opentelemetry/sdk-trace-base",
"version": "1.8.0",
"version": "1.9.0",
"description": "OpenTelemetry Tracing",

@@ -18,4 +18,4 @@ "main": "build/src/index.js",

"prepublishOnly": "npm run compile",
"compile": "tsc --build tsconfig.all.json",
"clean": "tsc --build --clean tsconfig.all.json",
"compile": "tsc --build tsconfig.json tsconfig.esm.json tsconfig.esnext.json",
"clean": "tsc --build --clean tsconfig.json tsconfig.esm.json tsconfig.esnext.json",
"test": "nyc ts-mocha -p tsconfig.json 'test/**/*.test.ts' --exclude 'test/browser/**/*.ts'",

@@ -32,3 +32,3 @@ "test:browser": "nyc karma start --single-run",

"version": "node ../../scripts/version-update.js",
"watch": "tsc --build --watch tsconfig.all.json",
"watch": "tsc --build --watch tsconfig.json tsconfig.esm.json tsconfig.esnext.json",
"precompile": "lerna run version --scope $(npm pkg get name) --include-dependencies",

@@ -69,3 +69,3 @@ "prewatch": "npm run precompile",

"devDependencies": {
"@opentelemetry/api": ">=1.0.0 <1.4.0",
"@opentelemetry/api": ">=1.0.0 <1.5.0",
"@types/mocha": "10.0.0",

@@ -87,3 +87,3 @@ "@types/node": "18.6.5",

"rimraf": "3.0.2",
"sinon": "14.0.0",
"sinon": "15.0.0",
"ts-loader": "8.4.0",

@@ -95,12 +95,12 @@ "ts-mocha": "10.0.0",

"peerDependencies": {
"@opentelemetry/api": ">=1.0.0 <1.4.0"
"@opentelemetry/api": ">=1.0.0 <1.5.0"
},
"dependencies": {
"@opentelemetry/core": "1.8.0",
"@opentelemetry/resources": "1.8.0",
"@opentelemetry/semantic-conventions": "1.8.0"
"@opentelemetry/core": "1.9.0",
"@opentelemetry/resources": "1.9.0",
"@opentelemetry/semantic-conventions": "1.9.0"
},
"homepage": "https://github.com/open-telemetry/opentelemetry-js/tree/main/packages/opentelemetry-sdk-trace-base",
"sideEffects": false,
"gitHead": "7972edf6659fb6e0d5928a5cf7a35f26683e168f"
"gitHead": "08f597f3a3d71a4852b0afbba120af15ca038121"
}

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

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

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc