Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@opentelemetry/sdk-trace-base

Package Overview
Dependencies
Maintainers
2
Versions
56
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@opentelemetry/sdk-trace-base - npm Package Compare versions

Comparing version 1.9.1 to 1.10.0

4

build/esm/BasicTracerProvider.d.ts
import { TextMapPropagator, TracerProvider } from '@opentelemetry/api';
import { Resource } from '@opentelemetry/resources';
import { IResource } from '@opentelemetry/resources';
import { SpanProcessor, Tracer } from '.';

@@ -24,3 +24,3 @@ import { SDKRegistrationConfig, TracerConfig } from './types';

activeSpanProcessor: SpanProcessor;
readonly resource: Resource;
readonly resource: IResource;
constructor(config?: TracerConfig);

@@ -27,0 +27,0 @@ getTracer(name: string, version?: string, options?: {

@@ -21,2 +21,4 @@ import { ENVIRONMENT } from '@opentelemetry/core';

eventCountLimit: number;
attributePerEventCountLimit: number;
attributePerLinkCountLimit: number;
};

@@ -23,0 +25,0 @@ };

@@ -46,2 +46,4 @@ /*

eventCountLimit: getEnv().OTEL_SPAN_EVENT_COUNT_LIMIT,
attributePerEventCountLimit: getEnv().OTEL_SPAN_ATTRIBUTE_PER_EVENT_COUNT_LIMIT,
attributePerLinkCountLimit: getEnv().OTEL_SPAN_ATTRIBUTE_PER_LINK_COUNT_LIMIT,
},

@@ -48,0 +50,0 @@ };

@@ -20,2 +20,3 @@ import { Context } from '@opentelemetry/api';

private _shutdownOnce;
private _droppedSpansCount;
constructor(_exporter: SpanExporter, config?: T);

@@ -22,0 +23,0 @@ forceFlush(): Promise<void>;

@@ -26,2 +26,3 @@ /*

this._finishedSpans = [];
this._droppedSpansCount = 0;
var env = getEnv();

@@ -87,4 +88,13 @@ this._maxExportBatchSize =

// limit reached, drop span
if (this._droppedSpansCount === 0) {
diag.debug('maxQueueSize reached, dropping spans');
}
this._droppedSpansCount++;
return;
}
if (this._droppedSpansCount > 0) {
// some spans were dropped, log once with count of spans dropped
diag.warn("Dropped " + this._droppedSpansCount + " spans because maxQueueSize reached");
this._droppedSpansCount = 0;
}
this._finishedSpans.push(span);

@@ -129,13 +139,29 @@ this._maybeStartTimer();

// could pass the same finished spans to the exporter if the buffer is cleared
// outside of the execution of this callback.
_this._exporter.export(_this._finishedSpans.splice(0, _this._maxExportBatchSize), function (result) {
var _a;
clearTimeout(timer);
if (result.code === ExportResultCode.SUCCESS) {
resolve();
}
else {
reject((_a = result.error) !== null && _a !== void 0 ? _a : new Error('BatchSpanProcessor: span export failed'));
}
});
// outside the execution of this callback.
var spans = _this._finishedSpans.splice(0, _this._maxExportBatchSize);
var doExport = function () {
return _this._exporter.export(spans, function (result) {
var _a;
clearTimeout(timer);
if (result.code === ExportResultCode.SUCCESS) {
resolve();
}
else {
reject((_a = result.error) !== null && _a !== void 0 ? _a : new Error('BatchSpanProcessor: span export failed'));
}
});
};
var pendingResources = spans
.map(function (span) { return span.resource; })
.filter(function (resource) { return resource.asyncAttributesPending; });
// Avoid scheduling a promise to make the behavior more predictable and easier to test
if (pendingResources.length === 0) {
doExport();
}
else {
Promise.all(pendingResources.map(function (resource) { var _a; return (_a = resource.waitForAsyncAttributes) === null || _a === void 0 ? void 0 : _a.call(resource); })).then(doExport, function (err) {
globalErrorHandler(err);
reject(err);
});
}
});

@@ -142,0 +168,0 @@ });

import { SpanKind, SpanStatus, SpanAttributes, HrTime, Link, SpanContext } from '@opentelemetry/api';
import { Resource } from '@opentelemetry/resources';
import { IResource } from '@opentelemetry/resources';
import { InstrumentationLibrary } from '@opentelemetry/core';

@@ -18,5 +18,8 @@ import { TimedEvent } from '../TimedEvent';

readonly ended: boolean;
readonly resource: Resource;
readonly resource: IResource;
readonly instrumentationLibrary: InstrumentationLibrary;
readonly droppedAttributesCount: number;
readonly droppedEventsCount: number;
readonly droppedLinksCount: number;
}
//# sourceMappingURL=ReadableSpan.d.ts.map

@@ -15,2 +15,3 @@ import { Context } from '@opentelemetry/api';

private _shutdownOnce;
private _unresolvedExports;
constructor(_exporter: SpanExporter);

@@ -17,0 +18,0 @@ forceFlush(): Promise<void>;

@@ -16,2 +16,38 @@ /*

*/
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
var __generator = (this && this.__generator) || function (thisArg, body) {
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
function verb(n) { return function (v) { return step([n, v]); }; }
function step(op) {
if (f) throw new TypeError("Generator is already executing.");
while (_) try {
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
if (y = 0, t) op = [op[0] & 2, t.value];
switch (op[0]) {
case 0: case 1: t = op; break;
case 4: _.label++; return { value: op[1], done: false };
case 5: _.label++; y = op[1]; op = [0]; continue;
case 7: op = _.ops.pop(); _.trys.pop(); continue;
default:
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
if (t[2]) _.ops.pop();
_.trys.pop(); continue;
}
op = body.call(thisArg, _);
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
}
};
import { TraceFlags } from '@opentelemetry/api';

@@ -29,10 +65,22 @@ import { internal, ExportResultCode, globalErrorHandler, BindOnceFuture, } from '@opentelemetry/core';

this._shutdownOnce = new BindOnceFuture(this._shutdown, this);
this._unresolvedExports = new Set();
}
SimpleSpanProcessor.prototype.forceFlush = function () {
// do nothing as all spans are being exported without waiting
return Promise.resolve();
return __awaiter(this, void 0, void 0, function () {
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
// await unresolved resources before resolving
return [4 /*yield*/, Promise.all(Array.from(this._unresolvedExports))];
case 1:
// await unresolved resources before resolving
_a.sent();
return [2 /*return*/];
}
});
});
};
// does nothing.
SimpleSpanProcessor.prototype.onStart = function (_span, _parentContext) { };
SimpleSpanProcessor.prototype.onEnd = function (span) {
var _this = this;
if (this._shutdownOnce.isCalled) {

@@ -44,13 +92,29 @@ return;

}
internal
._export(this._exporter, [span])
.then(function (result) {
var _a;
if (result.code !== ExportResultCode.SUCCESS) {
globalErrorHandler((_a = result.error) !== null && _a !== void 0 ? _a : new Error("SimpleSpanProcessor: span export failed (status " + result + ")"));
}
})
.catch(function (error) {
globalErrorHandler(error);
});
var doExport = function () {
return internal
._export(_this._exporter, [span])
.then(function (result) {
var _a;
if (result.code !== ExportResultCode.SUCCESS) {
globalErrorHandler((_a = result.error) !== null && _a !== void 0 ? _a : new Error("SimpleSpanProcessor: span export failed (status " + result + ")"));
}
})
.catch(function (error) {
globalErrorHandler(error);
});
};
// Avoid scheduling a promise to make the behavior more predictable and easier to test
if (span.resource.asyncAttributesPending) {
var exportPromise_1 = span.resource
.waitForAsyncAttributes()
.then(function () {
_this._unresolvedExports.delete(exportPromise_1);
return doExport();
}, function (err) { return globalErrorHandler(err); });
// store the unresolved exports
this._unresolvedExports.add(exportPromise_1);
}
else {
void doExport();
}
};

@@ -57,0 +121,0 @@ SimpleSpanProcessor.prototype.shutdown = function () {

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

import { Context, Link, SpanAttributes, SpanKind } from '@opentelemetry/api';
import { Context, Link, SpanAttributes, SpanKind, TraceState } from '@opentelemetry/api';
/**

@@ -38,2 +38,9 @@ * A sampling decision that determines how a {@link Span} will be recorded

attributes?: Readonly<SpanAttributes>;
/**
* A {@link TraceState} that will be associated with the {@link Span} through
* the new {@link SpanContext}. Samplers SHOULD return the TraceState from
* the passed-in {@link Context} if they do not intend to change it. Leaving
* the value undefined will also leave the TraceState unchanged.
*/
traceState?: TraceState;
}

@@ -40,0 +47,0 @@ /**

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';
import { IResource } from '@opentelemetry/resources';
import { ReadableSpan } from './export/ReadableSpan';

@@ -18,4 +18,7 @@ import { TimedEvent } from './TimedEvent';

readonly startTime: HrTime;
readonly resource: Resource;
readonly resource: IResource;
readonly instrumentationLibrary: InstrumentationLibrary;
private _droppedAttributesCount;
private _droppedEventsCount;
private _droppedLinksCount;
name: string;

@@ -57,2 +60,5 @@ status: SpanStatus;

get ended(): boolean;
get droppedAttributesCount(): number;
get droppedEventsCount(): number;
get droppedLinksCount(): number;
private _isSpanEnded;

@@ -59,0 +65,0 @@ private _truncateToLimitUtil;

@@ -62,2 +62,5 @@ /*

this.events = [];
this._droppedAttributesCount = 0;
this._droppedEventsCount = 0;
this._droppedLinksCount = 0;
this.status = {

@@ -105,2 +108,3 @@ code: SpanStatusCode.UNSET,

!Object.prototype.hasOwnProperty.call(this.attributes, key)) {
this._droppedAttributesCount++;
return this;

@@ -140,2 +144,3 @@ }

diag.warn('No events allowed.');
this._droppedEventsCount++;
return this;

@@ -146,2 +151,3 @@ }

this.events.shift();
this._droppedEventsCount++;
}

@@ -159,2 +165,3 @@ if (isTimeInput(attributesOrStartTime)) {

time: this._getTime(timeStamp),
droppedAttributesCount: 0,
});

@@ -259,2 +266,23 @@ return this;

});
Object.defineProperty(Span.prototype, "droppedAttributesCount", {
get: function () {
return this._droppedAttributesCount;
},
enumerable: false,
configurable: true
});
Object.defineProperty(Span.prototype, "droppedEventsCount", {
get: function () {
return this._droppedEventsCount;
},
enumerable: false,
configurable: true
});
Object.defineProperty(Span.prototype, "droppedLinksCount", {
get: function () {
return this._droppedLinksCount;
},
enumerable: false,
configurable: true
});
Span.prototype._isSpanEnded = function () {

@@ -261,0 +289,0 @@ if (this._ended) {

@@ -12,3 +12,5 @@ import { HrTime, SpanAttributes } from '@opentelemetry/api';

attributes?: SpanAttributes;
/** Count of attributes of the event that were dropped due to collection limits */
droppedAttributesCount?: number;
}
//# sourceMappingURL=TimedEvent.d.ts.map
import * as api from '@opentelemetry/api';
import { InstrumentationLibrary } from '@opentelemetry/core';
import { Resource } from '@opentelemetry/resources';
import { IResource } from '@opentelemetry/resources';
import { BasicTracerProvider } from './BasicTracerProvider';

@@ -16,3 +16,3 @@ import { GeneralLimits, SpanLimits, TracerConfig } from './types';

private readonly _idGenerator;
readonly resource: Resource;
readonly resource: IResource;
readonly instrumentationLibrary: InstrumentationLibrary;

@@ -19,0 +19,0 @@ /**

@@ -43,3 +43,3 @@ /*

Tracer.prototype.startSpan = function (name, options, context) {
var _a, _b;
var _a, _b, _c;
if (options === void 0) { options = {}; }

@@ -83,2 +83,3 @@ if (context === void 0) { context = api.context.active(); }

var samplingResult = this._sampler.shouldSample(context, traceId, name, spanKind, attributes, links);
traceState = (_c = samplingResult.traceState) !== null && _c !== void 0 ? _c : traceState;
var traceFlags = samplingResult.decision === api.SamplingDecision.RECORD_AND_SAMPLED

@@ -85,0 +86,0 @@ ? api.TraceFlags.SAMPLED

import { ContextManager, TextMapPropagator } from '@opentelemetry/api';
import { Resource } from '@opentelemetry/resources';
import { IResource } from '@opentelemetry/resources';
import { IdGenerator } from './IdGenerator';

@@ -18,3 +18,3 @@ import { Sampler } from './Sampler';

/** Resource associated with trace telemetry */
resource?: Resource;
resource?: IResource;
/**

@@ -59,2 +59,6 @@ * Generator of trace and span IDs

eventCountLimit?: number;
/** attributePerEventCountLimit is the maximum number of attributes allowed per span event */
attributePerEventCountLimit?: number;
/** attributePerLinkCountLimit is the maximum number of attributes allowed per span link */
attributePerLinkCountLimit?: number;
}

@@ -61,0 +65,0 @@ /** Interface configuration for a buffer. */

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

export declare const VERSION = "1.9.1";
export declare const VERSION = "1.10.0";
//# sourceMappingURL=version.d.ts.map

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

// this is autogenerated file, see scripts/version-update.js
export var VERSION = '1.9.1';
export var VERSION = '1.10.0';
//# sourceMappingURL=version.js.map
import { TextMapPropagator, TracerProvider } from '@opentelemetry/api';
import { Resource } from '@opentelemetry/resources';
import { IResource } from '@opentelemetry/resources';
import { SpanProcessor, Tracer } from '.';

@@ -24,3 +24,3 @@ import { SDKRegistrationConfig, TracerConfig } from './types';

activeSpanProcessor: SpanProcessor;
readonly resource: Resource;
readonly resource: IResource;
constructor(config?: TracerConfig);

@@ -27,0 +27,0 @@ getTracer(name: string, version?: string, options?: {

@@ -21,2 +21,4 @@ import { ENVIRONMENT } from '@opentelemetry/core';

eventCountLimit: number;
attributePerEventCountLimit: number;
attributePerLinkCountLimit: number;
};

@@ -23,0 +25,0 @@ };

@@ -46,2 +46,4 @@ /*

eventCountLimit: getEnv().OTEL_SPAN_EVENT_COUNT_LIMIT,
attributePerEventCountLimit: getEnv().OTEL_SPAN_ATTRIBUTE_PER_EVENT_COUNT_LIMIT,
attributePerLinkCountLimit: getEnv().OTEL_SPAN_ATTRIBUTE_PER_LINK_COUNT_LIMIT,
},

@@ -48,0 +50,0 @@ };

@@ -20,2 +20,3 @@ import { Context } from '@opentelemetry/api';

private _shutdownOnce;
private _droppedSpansCount;
constructor(_exporter: SpanExporter, config?: T);

@@ -22,0 +23,0 @@ forceFlush(): Promise<void>;

@@ -26,2 +26,3 @@ /*

this._finishedSpans = [];
this._droppedSpansCount = 0;
const env = getEnv();

@@ -86,4 +87,13 @@ this._maxExportBatchSize =

// limit reached, drop span
if (this._droppedSpansCount === 0) {
diag.debug('maxQueueSize reached, dropping spans');
}
this._droppedSpansCount++;
return;
}
if (this._droppedSpansCount > 0) {
// some spans were dropped, log once with count of spans dropped
diag.warn(`Dropped ${this._droppedSpansCount} spans because maxQueueSize reached`);
this._droppedSpansCount = 0;
}
this._finishedSpans.push(span);

@@ -126,4 +136,5 @@ this._maybeStartTimer();

// could pass the same finished spans to the exporter if the buffer is cleared
// outside of the execution of this callback.
this._exporter.export(this._finishedSpans.splice(0, this._maxExportBatchSize), result => {
// outside the execution of this callback.
const spans = this._finishedSpans.splice(0, this._maxExportBatchSize);
const doExport = () => this._exporter.export(spans, result => {
var _a;

@@ -138,2 +149,15 @@ clearTimeout(timer);

});
const pendingResources = spans
.map(span => span.resource)
.filter(resource => resource.asyncAttributesPending);
// Avoid scheduling a promise to make the behavior more predictable and easier to test
if (pendingResources.length === 0) {
doExport();
}
else {
Promise.all(pendingResources.map(resource => { var _a; return (_a = resource.waitForAsyncAttributes) === null || _a === void 0 ? void 0 : _a.call(resource); })).then(doExport, err => {
globalErrorHandler(err);
reject(err);
});
}
});

@@ -140,0 +164,0 @@ });

import { SpanKind, SpanStatus, SpanAttributes, HrTime, Link, SpanContext } from '@opentelemetry/api';
import { Resource } from '@opentelemetry/resources';
import { IResource } from '@opentelemetry/resources';
import { InstrumentationLibrary } from '@opentelemetry/core';

@@ -18,5 +18,8 @@ import { TimedEvent } from '../TimedEvent';

readonly ended: boolean;
readonly resource: Resource;
readonly resource: IResource;
readonly instrumentationLibrary: InstrumentationLibrary;
readonly droppedAttributesCount: number;
readonly droppedEventsCount: number;
readonly droppedLinksCount: number;
}
//# sourceMappingURL=ReadableSpan.d.ts.map

@@ -15,2 +15,3 @@ import { Context } from '@opentelemetry/api';

private _shutdownOnce;
private _unresolvedExports;
constructor(_exporter: SpanExporter);

@@ -17,0 +18,0 @@ forceFlush(): Promise<void>;

@@ -28,8 +28,8 @@ /*

this._shutdownOnce = new BindOnceFuture(this._shutdown, this);
this._unresolvedExports = new Set();
}
forceFlush() {
// do nothing as all spans are being exported without waiting
return Promise.resolve();
async forceFlush() {
// await unresolved resources before resolving
await Promise.all(Array.from(this._unresolvedExports));
}
// does nothing.
onStart(_span, _parentContext) { }

@@ -43,3 +43,3 @@ onEnd(span) {

}
internal
const doExport = () => internal
._export(this._exporter, [span])

@@ -55,2 +55,16 @@ .then((result) => {

});
// Avoid scheduling a promise to make the behavior more predictable and easier to test
if (span.resource.asyncAttributesPending) {
const exportPromise = span.resource
.waitForAsyncAttributes()
.then(() => {
this._unresolvedExports.delete(exportPromise);
return doExport();
}, err => globalErrorHandler(err));
// store the unresolved exports
this._unresolvedExports.add(exportPromise);
}
else {
void doExport();
}
}

@@ -57,0 +71,0 @@ shutdown() {

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

import { Context, Link, SpanAttributes, SpanKind } from '@opentelemetry/api';
import { Context, Link, SpanAttributes, SpanKind, TraceState } from '@opentelemetry/api';
/**

@@ -38,2 +38,9 @@ * A sampling decision that determines how a {@link Span} will be recorded

attributes?: Readonly<SpanAttributes>;
/**
* A {@link TraceState} that will be associated with the {@link Span} through
* the new {@link SpanContext}. Samplers SHOULD return the TraceState from
* the passed-in {@link Context} if they do not intend to change it. Leaving
* the value undefined will also leave the TraceState unchanged.
*/
traceState?: TraceState;
}

@@ -40,0 +47,0 @@ /**

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';
import { IResource } from '@opentelemetry/resources';
import { ReadableSpan } from './export/ReadableSpan';

@@ -18,4 +18,7 @@ import { TimedEvent } from './TimedEvent';

readonly startTime: HrTime;
readonly resource: Resource;
readonly resource: IResource;
readonly instrumentationLibrary: InstrumentationLibrary;
private _droppedAttributesCount;
private _droppedEventsCount;
private _droppedLinksCount;
name: string;

@@ -57,2 +60,5 @@ status: SpanStatus;

get ended(): boolean;
get droppedAttributesCount(): number;
get droppedEventsCount(): number;
get droppedLinksCount(): number;
private _isSpanEnded;

@@ -59,0 +65,0 @@ private _truncateToLimitUtil;

@@ -34,2 +34,5 @@ /*

this.events = [];
this._droppedAttributesCount = 0;
this._droppedEventsCount = 0;
this._droppedLinksCount = 0;
this.status = {

@@ -77,2 +80,3 @@ code: SpanStatusCode.UNSET,

!Object.prototype.hasOwnProperty.call(this.attributes, key)) {
this._droppedAttributesCount++;
return this;

@@ -101,2 +105,3 @@ }

diag.warn('No events allowed.');
this._droppedEventsCount++;
return this;

@@ -107,2 +112,3 @@ }

this.events.shift();
this._droppedEventsCount++;
}

@@ -120,2 +126,3 @@ if (isTimeInput(attributesOrStartTime)) {

time: this._getTime(timeStamp),
droppedAttributesCount: 0,
});

@@ -212,2 +219,11 @@ return this;

}
get droppedAttributesCount() {
return this._droppedAttributesCount;
}
get droppedEventsCount() {
return this._droppedEventsCount;
}
get droppedLinksCount() {
return this._droppedLinksCount;
}
_isSpanEnded() {

@@ -214,0 +230,0 @@ if (this._ended) {

@@ -12,3 +12,5 @@ import { HrTime, SpanAttributes } from '@opentelemetry/api';

attributes?: SpanAttributes;
/** Count of attributes of the event that were dropped due to collection limits */
droppedAttributesCount?: number;
}
//# sourceMappingURL=TimedEvent.d.ts.map
import * as api from '@opentelemetry/api';
import { InstrumentationLibrary } from '@opentelemetry/core';
import { Resource } from '@opentelemetry/resources';
import { IResource } from '@opentelemetry/resources';
import { BasicTracerProvider } from './BasicTracerProvider';

@@ -16,3 +16,3 @@ import { GeneralLimits, SpanLimits, TracerConfig } from './types';

private readonly _idGenerator;
readonly resource: Resource;
readonly resource: IResource;
readonly instrumentationLibrary: InstrumentationLibrary;

@@ -19,0 +19,0 @@ /**

@@ -43,3 +43,3 @@ /*

startSpan(name, options = {}, context = api.context.active()) {
var _a, _b;
var _a, _b, _c;
// remove span from context in case a root span is requested via options

@@ -81,2 +81,3 @@ if (options.root) {

const samplingResult = this._sampler.shouldSample(context, traceId, name, spanKind, attributes, links);
traceState = (_c = samplingResult.traceState) !== null && _c !== void 0 ? _c : traceState;
const traceFlags = samplingResult.decision === api.SamplingDecision.RECORD_AND_SAMPLED

@@ -83,0 +84,0 @@ ? api.TraceFlags.SAMPLED

import { ContextManager, TextMapPropagator } from '@opentelemetry/api';
import { Resource } from '@opentelemetry/resources';
import { IResource } from '@opentelemetry/resources';
import { IdGenerator } from './IdGenerator';

@@ -18,3 +18,3 @@ import { Sampler } from './Sampler';

/** Resource associated with trace telemetry */
resource?: Resource;
resource?: IResource;
/**

@@ -59,2 +59,6 @@ * Generator of trace and span IDs

eventCountLimit?: number;
/** attributePerEventCountLimit is the maximum number of attributes allowed per span event */
attributePerEventCountLimit?: number;
/** attributePerLinkCountLimit is the maximum number of attributes allowed per span link */
attributePerLinkCountLimit?: number;
}

@@ -61,0 +65,0 @@ /** Interface configuration for a buffer. */

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

export declare const VERSION = "1.9.1";
export declare const VERSION = "1.10.0";
//# sourceMappingURL=version.d.ts.map

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

// this is autogenerated file, see scripts/version-update.js
export const VERSION = '1.9.1';
export const VERSION = '1.10.0';
//# sourceMappingURL=version.js.map
import { TextMapPropagator, TracerProvider } from '@opentelemetry/api';
import { Resource } from '@opentelemetry/resources';
import { IResource } from '@opentelemetry/resources';
import { SpanProcessor, Tracer } from '.';

@@ -24,3 +24,3 @@ import { SDKRegistrationConfig, TracerConfig } from './types';

activeSpanProcessor: SpanProcessor;
readonly resource: Resource;
readonly resource: IResource;
constructor(config?: TracerConfig);

@@ -27,0 +27,0 @@ getTracer(name: string, version?: string, options?: {

@@ -21,2 +21,4 @@ import { ENVIRONMENT } from '@opentelemetry/core';

eventCountLimit: number;
attributePerEventCountLimit: number;
attributePerLinkCountLimit: number;
};

@@ -23,0 +25,0 @@ };

@@ -49,2 +49,4 @@ "use strict";

eventCountLimit: (0, core_1.getEnv)().OTEL_SPAN_EVENT_COUNT_LIMIT,
attributePerEventCountLimit: (0, core_1.getEnv)().OTEL_SPAN_ATTRIBUTE_PER_EVENT_COUNT_LIMIT,
attributePerLinkCountLimit: (0, core_1.getEnv)().OTEL_SPAN_ATTRIBUTE_PER_LINK_COUNT_LIMIT,
},

@@ -51,0 +53,0 @@ };

@@ -20,2 +20,3 @@ import { Context } from '@opentelemetry/api';

private _shutdownOnce;
private _droppedSpansCount;
constructor(_exporter: SpanExporter, config?: T);

@@ -22,0 +23,0 @@ forceFlush(): Promise<void>;

@@ -29,2 +29,3 @@ "use strict";

this._finishedSpans = [];
this._droppedSpansCount = 0;
const env = (0, core_1.getEnv)();

@@ -89,4 +90,13 @@ this._maxExportBatchSize =

// limit reached, drop span
if (this._droppedSpansCount === 0) {
api_1.diag.debug('maxQueueSize reached, dropping spans');
}
this._droppedSpansCount++;
return;
}
if (this._droppedSpansCount > 0) {
// some spans were dropped, log once with count of spans dropped
api_1.diag.warn(`Dropped ${this._droppedSpansCount} spans because maxQueueSize reached`);
this._droppedSpansCount = 0;
}
this._finishedSpans.push(span);

@@ -129,4 +139,5 @@ this._maybeStartTimer();

// could pass the same finished spans to the exporter if the buffer is cleared
// outside of the execution of this callback.
this._exporter.export(this._finishedSpans.splice(0, this._maxExportBatchSize), result => {
// outside the execution of this callback.
const spans = this._finishedSpans.splice(0, this._maxExportBatchSize);
const doExport = () => this._exporter.export(spans, result => {
var _a;

@@ -141,2 +152,15 @@ clearTimeout(timer);

});
const pendingResources = spans
.map(span => span.resource)
.filter(resource => resource.asyncAttributesPending);
// Avoid scheduling a promise to make the behavior more predictable and easier to test
if (pendingResources.length === 0) {
doExport();
}
else {
Promise.all(pendingResources.map(resource => { var _a; return (_a = resource.waitForAsyncAttributes) === null || _a === void 0 ? void 0 : _a.call(resource); })).then(doExport, err => {
(0, core_1.globalErrorHandler)(err);
reject(err);
});
}
});

@@ -143,0 +167,0 @@ });

import { SpanKind, SpanStatus, SpanAttributes, HrTime, Link, SpanContext } from '@opentelemetry/api';
import { Resource } from '@opentelemetry/resources';
import { IResource } from '@opentelemetry/resources';
import { InstrumentationLibrary } from '@opentelemetry/core';

@@ -18,5 +18,8 @@ import { TimedEvent } from '../TimedEvent';

readonly ended: boolean;
readonly resource: Resource;
readonly resource: IResource;
readonly instrumentationLibrary: InstrumentationLibrary;
readonly droppedAttributesCount: number;
readonly droppedEventsCount: number;
readonly droppedLinksCount: number;
}
//# sourceMappingURL=ReadableSpan.d.ts.map

@@ -15,2 +15,3 @@ import { Context } from '@opentelemetry/api';

private _shutdownOnce;
private _unresolvedExports;
constructor(_exporter: SpanExporter);

@@ -17,0 +18,0 @@ forceFlush(): Promise<void>;

@@ -31,8 +31,8 @@ "use strict";

this._shutdownOnce = new core_1.BindOnceFuture(this._shutdown, this);
this._unresolvedExports = new Set();
}
forceFlush() {
// do nothing as all spans are being exported without waiting
return Promise.resolve();
async forceFlush() {
// await unresolved resources before resolving
await Promise.all(Array.from(this._unresolvedExports));
}
// does nothing.
onStart(_span, _parentContext) { }

@@ -46,3 +46,3 @@ onEnd(span) {

}
core_1.internal
const doExport = () => core_1.internal
._export(this._exporter, [span])

@@ -58,2 +58,16 @@ .then((result) => {

});
// Avoid scheduling a promise to make the behavior more predictable and easier to test
if (span.resource.asyncAttributesPending) {
const exportPromise = span.resource
.waitForAsyncAttributes()
.then(() => {
this._unresolvedExports.delete(exportPromise);
return doExport();
}, err => (0, core_1.globalErrorHandler)(err));
// store the unresolved exports
this._unresolvedExports.add(exportPromise);
}
else {
void doExport();
}
}

@@ -60,0 +74,0 @@ shutdown() {

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

import { Context, Link, SpanAttributes, SpanKind } from '@opentelemetry/api';
import { Context, Link, SpanAttributes, SpanKind, TraceState } from '@opentelemetry/api';
/**

@@ -38,2 +38,9 @@ * A sampling decision that determines how a {@link Span} will be recorded

attributes?: Readonly<SpanAttributes>;
/**
* A {@link TraceState} that will be associated with the {@link Span} through
* the new {@link SpanContext}. Samplers SHOULD return the TraceState from
* the passed-in {@link Context} if they do not intend to change it. Leaving
* the value undefined will also leave the TraceState unchanged.
*/
traceState?: TraceState;
}

@@ -40,0 +47,0 @@ /**

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';
import { IResource } from '@opentelemetry/resources';
import { ReadableSpan } from './export/ReadableSpan';

@@ -18,4 +18,7 @@ import { TimedEvent } from './TimedEvent';

readonly startTime: HrTime;
readonly resource: Resource;
readonly resource: IResource;
readonly instrumentationLibrary: InstrumentationLibrary;
private _droppedAttributesCount;
private _droppedEventsCount;
private _droppedLinksCount;
name: string;

@@ -57,2 +60,5 @@ status: SpanStatus;

get ended(): boolean;
get droppedAttributesCount(): number;
get droppedEventsCount(): number;
get droppedLinksCount(): number;
private _isSpanEnded;

@@ -59,0 +65,0 @@ private _truncateToLimitUtil;

@@ -37,2 +37,5 @@ "use strict";

this.events = [];
this._droppedAttributesCount = 0;
this._droppedEventsCount = 0;
this._droppedLinksCount = 0;
this.status = {

@@ -80,2 +83,3 @@ code: api_1.SpanStatusCode.UNSET,

!Object.prototype.hasOwnProperty.call(this.attributes, key)) {
this._droppedAttributesCount++;
return this;

@@ -104,2 +108,3 @@ }

api_1.diag.warn('No events allowed.');
this._droppedEventsCount++;
return this;

@@ -110,2 +115,3 @@ }

this.events.shift();
this._droppedEventsCount++;
}

@@ -123,2 +129,3 @@ if ((0, core_1.isTimeInput)(attributesOrStartTime)) {

time: this._getTime(timeStamp),
droppedAttributesCount: 0,
});

@@ -215,2 +222,11 @@ return this;

}
get droppedAttributesCount() {
return this._droppedAttributesCount;
}
get droppedEventsCount() {
return this._droppedEventsCount;
}
get droppedLinksCount() {
return this._droppedLinksCount;
}
_isSpanEnded() {

@@ -217,0 +233,0 @@ if (this._ended) {

@@ -12,3 +12,5 @@ import { HrTime, SpanAttributes } from '@opentelemetry/api';

attributes?: SpanAttributes;
/** Count of attributes of the event that were dropped due to collection limits */
droppedAttributesCount?: number;
}
//# sourceMappingURL=TimedEvent.d.ts.map
import * as api from '@opentelemetry/api';
import { InstrumentationLibrary } from '@opentelemetry/core';
import { Resource } from '@opentelemetry/resources';
import { IResource } from '@opentelemetry/resources';
import { BasicTracerProvider } from './BasicTracerProvider';

@@ -16,3 +16,3 @@ import { GeneralLimits, SpanLimits, TracerConfig } from './types';

private readonly _idGenerator;
readonly resource: Resource;
readonly resource: IResource;
readonly instrumentationLibrary: InstrumentationLibrary;

@@ -19,0 +19,0 @@ /**

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

startSpan(name, options = {}, context = api.context.active()) {
var _a, _b;
var _a, _b, _c;
// remove span from context in case a root span is requested via options

@@ -84,2 +84,3 @@ if (options.root) {

const samplingResult = this._sampler.shouldSample(context, traceId, name, spanKind, attributes, links);
traceState = (_c = samplingResult.traceState) !== null && _c !== void 0 ? _c : traceState;
const traceFlags = samplingResult.decision === api.SamplingDecision.RECORD_AND_SAMPLED

@@ -86,0 +87,0 @@ ? api.TraceFlags.SAMPLED

import { ContextManager, TextMapPropagator } from '@opentelemetry/api';
import { Resource } from '@opentelemetry/resources';
import { IResource } from '@opentelemetry/resources';
import { IdGenerator } from './IdGenerator';

@@ -18,3 +18,3 @@ import { Sampler } from './Sampler';

/** Resource associated with trace telemetry */
resource?: Resource;
resource?: IResource;
/**

@@ -59,2 +59,6 @@ * Generator of trace and span IDs

eventCountLimit?: number;
/** attributePerEventCountLimit is the maximum number of attributes allowed per span event */
attributePerEventCountLimit?: number;
/** attributePerLinkCountLimit is the maximum number of attributes allowed per span link */
attributePerLinkCountLimit?: number;
}

@@ -61,0 +65,0 @@ /** Interface configuration for a buffer. */

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

export declare const VERSION = "1.9.1";
export declare const VERSION = "1.10.0";
//# sourceMappingURL=version.d.ts.map

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

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

@@ -68,2 +68,3 @@ "main": "build/src/index.js",

"@opentelemetry/api": ">=1.0.0 <1.5.0",
"@opentelemetry/resources_1.9.0": "npm:@opentelemetry/resources@1.9.0",
"@types/mocha": "10.0.0",

@@ -95,9 +96,9 @@ "@types/node": "18.6.5",

"dependencies": {
"@opentelemetry/core": "1.9.1",
"@opentelemetry/resources": "1.9.1",
"@opentelemetry/semantic-conventions": "1.9.1"
"@opentelemetry/core": "1.10.0",
"@opentelemetry/resources": "1.10.0",
"@opentelemetry/semantic-conventions": "1.10.0"
},
"homepage": "https://github.com/open-telemetry/opentelemetry-js/tree/main/packages/opentelemetry-sdk-trace-base",
"sideEffects": false,
"gitHead": "279458e7ddf16f7ddca5fe60c78672e05fafce66"
"gitHead": "56e6b1bb890f844b8963a146780d0b9cfa8abd0d"
}

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
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc