Socket
Socket
Sign inDemoInstall

@opentelemetry/sdk-trace-base

Package Overview
Dependencies
3
Maintainers
2
Versions
54
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 1.5.0 to 1.6.0

build/esm/IdGenerator.d.ts

4

build/esm/BasicTracerProvider.js

@@ -20,3 +20,3 @@ /*

import { Tracer } from '.';
import { DEFAULT_CONFIG } from './config';
import { loadDefaultConfig } from './config';
import { MultiSpanProcessor } from './MultiSpanProcessor';

@@ -42,3 +42,3 @@ import { NoopSpanProcessor } from './export/NoopSpanProcessor';

this._tracers = new Map();
var mergedConfig = merge({}, DEFAULT_CONFIG, reconfigureLimits(config));
var mergedConfig = merge({}, loadDefaultConfig(), reconfigureLimits(config));
this.resource = (_a = mergedConfig.resource) !== null && _a !== void 0 ? _a : Resource.empty();

@@ -45,0 +45,0 @@ this.resource = Resource.default().merge(this.resource);

@@ -1,5 +0,5 @@

import { Sampler } from '@opentelemetry/api';
import { ENVIRONMENT } from '@opentelemetry/core';
import { Sampler } from './Sampler';
/**
* Default configuration. For fields with primitive values, any user-provided
* Load default configuration. For fields with primitive values, any user-provided
* value will override the corresponding default value. For fields with

@@ -9,3 +9,3 @@ * non-primitive values (like `spanLimits`), the user-provided value will be

*/
export declare const DEFAULT_CONFIG: {
export declare function loadDefaultConfig(): {
sampler: Sampler;

@@ -12,0 +12,0 @@ forceFlushTimeoutMillis: number;

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

import { diag } from '@opentelemetry/api';
import { AlwaysOffSampler, AlwaysOnSampler, getEnv, TracesSamplerValues, ParentBasedSampler, TraceIdRatioBasedSampler, } from '@opentelemetry/core';
import { getEnv, TracesSamplerValues, } from '@opentelemetry/core';
import { AlwaysOffSampler } from './sampler/AlwaysOffSampler';
import { AlwaysOnSampler } from './sampler/AlwaysOnSampler';
import { ParentBasedSampler } from './sampler/ParentBasedSampler';
import { TraceIdRatioBasedSampler } from './sampler/TraceIdRatioBasedSampler';
var env = getEnv();

@@ -23,3 +27,3 @@ var FALLBACK_OTEL_TRACES_SAMPLER = TracesSamplerValues.AlwaysOn;

/**
* Default configuration. For fields with primitive values, any user-provided
* Load default configuration. For fields with primitive values, any user-provided
* value will override the corresponding default value. For fields with

@@ -29,16 +33,20 @@ * non-primitive values (like `spanLimits`), the user-provided value will be

*/
export var DEFAULT_CONFIG = {
sampler: buildSamplerFromEnv(env),
forceFlushTimeoutMillis: 30000,
generalLimits: {
attributeValueLengthLimit: getEnv().OTEL_ATTRIBUTE_VALUE_LENGTH_LIMIT,
attributeCountLimit: getEnv().OTEL_ATTRIBUTE_COUNT_LIMIT,
},
spanLimits: {
attributeValueLengthLimit: getEnv().OTEL_SPAN_ATTRIBUTE_VALUE_LENGTH_LIMIT,
attributeCountLimit: getEnv().OTEL_SPAN_ATTRIBUTE_COUNT_LIMIT,
linkCountLimit: getEnv().OTEL_SPAN_LINK_COUNT_LIMIT,
eventCountLimit: getEnv().OTEL_SPAN_EVENT_COUNT_LIMIT,
},
};
// object needs to be wrapped in this function and called when needed otherwise
// envs are parsed before tests are ran - causes tests using these envs to fail
export function loadDefaultConfig() {
return {
sampler: buildSamplerFromEnv(env),
forceFlushTimeoutMillis: 30000,
generalLimits: {
attributeValueLengthLimit: getEnv().OTEL_ATTRIBUTE_VALUE_LENGTH_LIMIT,
attributeCountLimit: getEnv().OTEL_ATTRIBUTE_COUNT_LIMIT,
},
spanLimits: {
attributeValueLengthLimit: getEnv().OTEL_SPAN_ATTRIBUTE_VALUE_LENGTH_LIMIT,
attributeCountLimit: getEnv().OTEL_SPAN_ATTRIBUTE_COUNT_LIMIT,
linkCountLimit: getEnv().OTEL_SPAN_LINK_COUNT_LIMIT,
eventCountLimit: getEnv().OTEL_SPAN_EVENT_COUNT_LIMIT,
},
};
}
/**

@@ -45,0 +53,0 @@ * Based on environment, builds a sampler, complies with specification.

@@ -10,2 +10,7 @@ export * from './Tracer';

export * from './export/NoopSpanProcessor';
export * from './sampler/AlwaysOffSampler';
export * from './sampler/AlwaysOnSampler';
export * from './sampler/ParentBasedSampler';
export * from './sampler/TraceIdRatioBasedSampler';
export * from './Sampler';
export * from './Span';

@@ -15,2 +20,3 @@ export * from './SpanProcessor';

export * from './types';
export * from './IdGenerator';
//# sourceMappingURL=index.d.ts.map

@@ -25,2 +25,7 @@ /*

export * from './export/NoopSpanProcessor';
export * from './sampler/AlwaysOffSampler';
export * from './sampler/AlwaysOnSampler';
export * from './sampler/ParentBasedSampler';
export * from './sampler/TraceIdRatioBasedSampler';
export * from './Sampler';
export * from './Span';

@@ -30,2 +35,3 @@ export * from './SpanProcessor';

export * from './types';
export * from './IdGenerator';
//# sourceMappingURL=index.js.map
export * from './export/BatchSpanProcessor';
export * from './RandomIdGenerator';
//# sourceMappingURL=index.d.ts.map

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

export * from './export/BatchSpanProcessor';
export * from './RandomIdGenerator';
//# sourceMappingURL=index.js.map
export * from './export/BatchSpanProcessor';
export * from './RandomIdGenerator';
//# sourceMappingURL=index.d.ts.map

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

export * from './export/BatchSpanProcessor';
export * from './RandomIdGenerator';
//# sourceMappingURL=index.js.map

@@ -17,5 +17,6 @@ /*

import * as api from '@opentelemetry/api';
import { RandomIdGenerator, sanitizeAttributes, isTracingSuppressed, } from '@opentelemetry/core';
import { sanitizeAttributes, isTracingSuppressed, } from '@opentelemetry/core';
import { Span } from './Span';
import { mergeConfig } from './utility';
import { RandomIdGenerator } from './platform';
/**

@@ -22,0 +23,0 @@ * This class represents a basic tracer.

@@ -1,5 +0,5 @@

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

@@ -6,0 +6,0 @@ * TracerConfig provides an interface for configuring a Basic Tracer.

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

import { Sampler } from '@opentelemetry/api';
import { Sampler } from './Sampler';
import { SpanLimits, TracerConfig, GeneralLimits } from './types';

@@ -3,0 +3,0 @@ /**

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

*/
import { buildSamplerFromEnv, DEFAULT_CONFIG } from './config';
import { buildSamplerFromEnv, loadDefaultConfig } from './config';
import { DEFAULT_ATTRIBUTE_COUNT_LIMIT, DEFAULT_ATTRIBUTE_VALUE_LENGTH_LIMIT, getEnvWithoutDefaults, } from '@opentelemetry/core';
/**

@@ -26,2 +27,3 @@ * Function to merge Default configuration (as specified in './config') with

};
var DEFAULT_CONFIG = loadDefaultConfig();
var target = Object.assign({}, DEFAULT_CONFIG, perInstanceDefaults, userConfig);

@@ -38,20 +40,17 @@ target.generalLimits = Object.assign({}, DEFAULT_CONFIG.generalLimits, userConfig.generalLimits || {});

export function reconfigureLimits(userConfig) {
var _a, _b;
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
var spanLimits = Object.assign({}, userConfig.spanLimits);
var parsedEnvConfig = getEnvWithoutDefaults();
/**
* When span attribute count limit is not defined, but general attribute count limit is defined
* Then, span attribute count limit will be same as general one
* Reassign span attribute count limit to use first non null value defined by user or use default value
*/
if (spanLimits.attributeCountLimit == null && ((_a = userConfig.generalLimits) === null || _a === void 0 ? void 0 : _a.attributeCountLimit) != null) {
spanLimits.attributeCountLimit = userConfig.generalLimits.attributeCountLimit;
}
spanLimits.attributeCountLimit =
(_f = (_e = (_d = (_b = (_a = userConfig.spanLimits) === null || _a === void 0 ? void 0 : _a.attributeCountLimit) !== null && _b !== void 0 ? _b : (_c = userConfig.generalLimits) === null || _c === void 0 ? void 0 : _c.attributeCountLimit) !== null && _d !== void 0 ? _d : parsedEnvConfig.OTEL_SPAN_ATTRIBUTE_COUNT_LIMIT) !== null && _e !== void 0 ? _e : parsedEnvConfig.OTEL_ATTRIBUTE_COUNT_LIMIT) !== null && _f !== void 0 ? _f : DEFAULT_ATTRIBUTE_COUNT_LIMIT;
/**
* When span attribute value length limit is not defined, but general attribute value length limit is defined
* Then, span attribute value length limit will be same as general one
* Reassign span attribute value length limit to use first non null value defined by user or use default value
*/
if (spanLimits.attributeValueLengthLimit == null && ((_b = userConfig.generalLimits) === null || _b === void 0 ? void 0 : _b.attributeValueLengthLimit) != null) {
spanLimits.attributeValueLengthLimit = userConfig.generalLimits.attributeValueLengthLimit;
}
spanLimits.attributeValueLengthLimit =
(_m = (_l = (_k = (_h = (_g = userConfig.spanLimits) === null || _g === void 0 ? void 0 : _g.attributeValueLengthLimit) !== null && _h !== void 0 ? _h : (_j = userConfig.generalLimits) === null || _j === void 0 ? void 0 : _j.attributeValueLengthLimit) !== null && _k !== void 0 ? _k : parsedEnvConfig.OTEL_SPAN_ATTRIBUTE_VALUE_LENGTH_LIMIT) !== null && _l !== void 0 ? _l : parsedEnvConfig.OTEL_ATTRIBUTE_VALUE_LENGTH_LIMIT) !== null && _m !== void 0 ? _m : DEFAULT_ATTRIBUTE_VALUE_LENGTH_LIMIT;
return Object.assign({}, userConfig, { spanLimits: spanLimits });
}
//# sourceMappingURL=utility.js.map

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

export declare const VERSION = "1.5.0";
export declare const VERSION = "1.6.0";
//# sourceMappingURL=version.d.ts.map

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

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

@@ -20,3 +20,3 @@ /*

import { Tracer } from '.';
import { DEFAULT_CONFIG } from './config';
import { loadDefaultConfig } from './config';
import { MultiSpanProcessor } from './MultiSpanProcessor';

@@ -41,3 +41,3 @@ import { NoopSpanProcessor } from './export/NoopSpanProcessor';

this._tracers = new Map();
const mergedConfig = merge({}, DEFAULT_CONFIG, reconfigureLimits(config));
const mergedConfig = merge({}, loadDefaultConfig(), reconfigureLimits(config));
this.resource = (_a = mergedConfig.resource) !== null && _a !== void 0 ? _a : Resource.empty();

@@ -44,0 +44,0 @@ this.resource = Resource.default().merge(this.resource);

@@ -1,5 +0,5 @@

import { Sampler } from '@opentelemetry/api';
import { ENVIRONMENT } from '@opentelemetry/core';
import { Sampler } from './Sampler';
/**
* Default configuration. For fields with primitive values, any user-provided
* Load default configuration. For fields with primitive values, any user-provided
* value will override the corresponding default value. For fields with

@@ -9,3 +9,3 @@ * non-primitive values (like `spanLimits`), the user-provided value will be

*/
export declare const DEFAULT_CONFIG: {
export declare function loadDefaultConfig(): {
sampler: Sampler;

@@ -12,0 +12,0 @@ forceFlushTimeoutMillis: number;

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

import { diag } from '@opentelemetry/api';
import { AlwaysOffSampler, AlwaysOnSampler, getEnv, TracesSamplerValues, ParentBasedSampler, TraceIdRatioBasedSampler, } from '@opentelemetry/core';
import { getEnv, TracesSamplerValues, } from '@opentelemetry/core';
import { AlwaysOffSampler } from './sampler/AlwaysOffSampler';
import { AlwaysOnSampler } from './sampler/AlwaysOnSampler';
import { ParentBasedSampler } from './sampler/ParentBasedSampler';
import { TraceIdRatioBasedSampler } from './sampler/TraceIdRatioBasedSampler';
const env = getEnv();

@@ -23,3 +27,3 @@ const FALLBACK_OTEL_TRACES_SAMPLER = TracesSamplerValues.AlwaysOn;

/**
* Default configuration. For fields with primitive values, any user-provided
* Load default configuration. For fields with primitive values, any user-provided
* value will override the corresponding default value. For fields with

@@ -29,16 +33,20 @@ * non-primitive values (like `spanLimits`), the user-provided value will be

*/
export const DEFAULT_CONFIG = {
sampler: buildSamplerFromEnv(env),
forceFlushTimeoutMillis: 30000,
generalLimits: {
attributeValueLengthLimit: getEnv().OTEL_ATTRIBUTE_VALUE_LENGTH_LIMIT,
attributeCountLimit: getEnv().OTEL_ATTRIBUTE_COUNT_LIMIT,
},
spanLimits: {
attributeValueLengthLimit: getEnv().OTEL_SPAN_ATTRIBUTE_VALUE_LENGTH_LIMIT,
attributeCountLimit: getEnv().OTEL_SPAN_ATTRIBUTE_COUNT_LIMIT,
linkCountLimit: getEnv().OTEL_SPAN_LINK_COUNT_LIMIT,
eventCountLimit: getEnv().OTEL_SPAN_EVENT_COUNT_LIMIT,
},
};
// object needs to be wrapped in this function and called when needed otherwise
// envs are parsed before tests are ran - causes tests using these envs to fail
export function loadDefaultConfig() {
return {
sampler: buildSamplerFromEnv(env),
forceFlushTimeoutMillis: 30000,
generalLimits: {
attributeValueLengthLimit: getEnv().OTEL_ATTRIBUTE_VALUE_LENGTH_LIMIT,
attributeCountLimit: getEnv().OTEL_ATTRIBUTE_COUNT_LIMIT,
},
spanLimits: {
attributeValueLengthLimit: getEnv().OTEL_SPAN_ATTRIBUTE_VALUE_LENGTH_LIMIT,
attributeCountLimit: getEnv().OTEL_SPAN_ATTRIBUTE_COUNT_LIMIT,
linkCountLimit: getEnv().OTEL_SPAN_LINK_COUNT_LIMIT,
eventCountLimit: getEnv().OTEL_SPAN_EVENT_COUNT_LIMIT,
},
};
}
/**

@@ -45,0 +53,0 @@ * Based on environment, builds a sampler, complies with specification.

@@ -10,2 +10,7 @@ export * from './Tracer';

export * from './export/NoopSpanProcessor';
export * from './sampler/AlwaysOffSampler';
export * from './sampler/AlwaysOnSampler';
export * from './sampler/ParentBasedSampler';
export * from './sampler/TraceIdRatioBasedSampler';
export * from './Sampler';
export * from './Span';

@@ -15,2 +20,3 @@ export * from './SpanProcessor';

export * from './types';
export * from './IdGenerator';
//# sourceMappingURL=index.d.ts.map

@@ -25,2 +25,7 @@ /*

export * from './export/NoopSpanProcessor';
export * from './sampler/AlwaysOffSampler';
export * from './sampler/AlwaysOnSampler';
export * from './sampler/ParentBasedSampler';
export * from './sampler/TraceIdRatioBasedSampler';
export * from './Sampler';
export * from './Span';

@@ -30,2 +35,3 @@ export * from './SpanProcessor';

export * from './types';
export * from './IdGenerator';
//# sourceMappingURL=index.js.map
export * from './export/BatchSpanProcessor';
export * from './RandomIdGenerator';
//# sourceMappingURL=index.d.ts.map

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

export * from './export/BatchSpanProcessor';
export * from './RandomIdGenerator';
//# sourceMappingURL=index.js.map
export * from './export/BatchSpanProcessor';
export * from './RandomIdGenerator';
//# sourceMappingURL=index.d.ts.map

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

export * from './export/BatchSpanProcessor';
export * from './RandomIdGenerator';
//# sourceMappingURL=index.js.map

@@ -17,5 +17,6 @@ /*

import * as api from '@opentelemetry/api';
import { RandomIdGenerator, sanitizeAttributes, isTracingSuppressed, } from '@opentelemetry/core';
import { sanitizeAttributes, isTracingSuppressed, } from '@opentelemetry/core';
import { Span } from './Span';
import { mergeConfig } from './utility';
import { RandomIdGenerator } from './platform';
/**

@@ -22,0 +23,0 @@ * This class represents a basic tracer.

@@ -1,5 +0,5 @@

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

@@ -6,0 +6,0 @@ * TracerConfig provides an interface for configuring a Basic Tracer.

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

import { Sampler } from '@opentelemetry/api';
import { Sampler } from './Sampler';
import { SpanLimits, TracerConfig, GeneralLimits } from './types';

@@ -3,0 +3,0 @@ /**

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

*/
import { buildSamplerFromEnv, DEFAULT_CONFIG } from './config';
import { buildSamplerFromEnv, loadDefaultConfig } from './config';
import { DEFAULT_ATTRIBUTE_COUNT_LIMIT, DEFAULT_ATTRIBUTE_VALUE_LENGTH_LIMIT, getEnvWithoutDefaults, } from '@opentelemetry/core';
/**

@@ -26,2 +27,3 @@ * Function to merge Default configuration (as specified in './config') with

};
const DEFAULT_CONFIG = loadDefaultConfig();
const target = Object.assign({}, DEFAULT_CONFIG, perInstanceDefaults, userConfig);

@@ -38,20 +40,17 @@ target.generalLimits = Object.assign({}, DEFAULT_CONFIG.generalLimits, userConfig.generalLimits || {});

export function reconfigureLimits(userConfig) {
var _a, _b;
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
const spanLimits = Object.assign({}, userConfig.spanLimits);
const parsedEnvConfig = getEnvWithoutDefaults();
/**
* When span attribute count limit is not defined, but general attribute count limit is defined
* Then, span attribute count limit will be same as general one
* Reassign span attribute count limit to use first non null value defined by user or use default value
*/
if (spanLimits.attributeCountLimit == null && ((_a = userConfig.generalLimits) === null || _a === void 0 ? void 0 : _a.attributeCountLimit) != null) {
spanLimits.attributeCountLimit = userConfig.generalLimits.attributeCountLimit;
}
spanLimits.attributeCountLimit =
(_f = (_e = (_d = (_b = (_a = userConfig.spanLimits) === null || _a === void 0 ? void 0 : _a.attributeCountLimit) !== null && _b !== void 0 ? _b : (_c = userConfig.generalLimits) === null || _c === void 0 ? void 0 : _c.attributeCountLimit) !== null && _d !== void 0 ? _d : parsedEnvConfig.OTEL_SPAN_ATTRIBUTE_COUNT_LIMIT) !== null && _e !== void 0 ? _e : parsedEnvConfig.OTEL_ATTRIBUTE_COUNT_LIMIT) !== null && _f !== void 0 ? _f : DEFAULT_ATTRIBUTE_COUNT_LIMIT;
/**
* When span attribute value length limit is not defined, but general attribute value length limit is defined
* Then, span attribute value length limit will be same as general one
* Reassign span attribute value length limit to use first non null value defined by user or use default value
*/
if (spanLimits.attributeValueLengthLimit == null && ((_b = userConfig.generalLimits) === null || _b === void 0 ? void 0 : _b.attributeValueLengthLimit) != null) {
spanLimits.attributeValueLengthLimit = userConfig.generalLimits.attributeValueLengthLimit;
}
spanLimits.attributeValueLengthLimit =
(_m = (_l = (_k = (_h = (_g = userConfig.spanLimits) === null || _g === void 0 ? void 0 : _g.attributeValueLengthLimit) !== null && _h !== void 0 ? _h : (_j = userConfig.generalLimits) === null || _j === void 0 ? void 0 : _j.attributeValueLengthLimit) !== null && _k !== void 0 ? _k : parsedEnvConfig.OTEL_SPAN_ATTRIBUTE_VALUE_LENGTH_LIMIT) !== null && _l !== void 0 ? _l : parsedEnvConfig.OTEL_ATTRIBUTE_VALUE_LENGTH_LIMIT) !== null && _m !== void 0 ? _m : DEFAULT_ATTRIBUTE_VALUE_LENGTH_LIMIT;
return Object.assign({}, userConfig, { spanLimits });
}
//# sourceMappingURL=utility.js.map

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

export declare const VERSION = "1.5.0";
export declare const VERSION = "1.6.0";
//# sourceMappingURL=version.d.ts.map

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

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

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

this._tracers = new Map();
const mergedConfig = (0, core_1.merge)({}, config_1.DEFAULT_CONFIG, (0, utility_1.reconfigureLimits)(config));
const mergedConfig = (0, core_1.merge)({}, (0, config_1.loadDefaultConfig)(), (0, utility_1.reconfigureLimits)(config));
this.resource = (_a = mergedConfig.resource) !== null && _a !== void 0 ? _a : resources_1.Resource.empty();

@@ -46,0 +46,0 @@ this.resource = resources_1.Resource.default().merge(this.resource);

@@ -1,5 +0,5 @@

import { Sampler } from '@opentelemetry/api';
import { ENVIRONMENT } from '@opentelemetry/core';
import { Sampler } from './Sampler';
/**
* Default configuration. For fields with primitive values, any user-provided
* Load default configuration. For fields with primitive values, any user-provided
* value will override the corresponding default value. For fields with

@@ -9,3 +9,3 @@ * non-primitive values (like `spanLimits`), the user-provided value will be

*/
export declare const DEFAULT_CONFIG: {
export declare function loadDefaultConfig(): {
sampler: Sampler;

@@ -12,0 +12,0 @@ forceFlushTimeoutMillis: number;

@@ -18,5 +18,9 @@ "use strict";

Object.defineProperty(exports, "__esModule", { value: true });
exports.buildSamplerFromEnv = exports.DEFAULT_CONFIG = void 0;
exports.buildSamplerFromEnv = exports.loadDefaultConfig = void 0;
const api_1 = require("@opentelemetry/api");
const core_1 = require("@opentelemetry/core");
const AlwaysOffSampler_1 = require("./sampler/AlwaysOffSampler");
const AlwaysOnSampler_1 = require("./sampler/AlwaysOnSampler");
const ParentBasedSampler_1 = require("./sampler/ParentBasedSampler");
const TraceIdRatioBasedSampler_1 = require("./sampler/TraceIdRatioBasedSampler");
const env = (0, core_1.getEnv)();

@@ -26,3 +30,3 @@ const FALLBACK_OTEL_TRACES_SAMPLER = core_1.TracesSamplerValues.AlwaysOn;

/**
* Default configuration. For fields with primitive values, any user-provided
* Load default configuration. For fields with primitive values, any user-provided
* value will override the corresponding default value. For fields with

@@ -32,16 +36,21 @@ * non-primitive values (like `spanLimits`), the user-provided value will be

*/
exports.DEFAULT_CONFIG = {
sampler: buildSamplerFromEnv(env),
forceFlushTimeoutMillis: 30000,
generalLimits: {
attributeValueLengthLimit: (0, core_1.getEnv)().OTEL_ATTRIBUTE_VALUE_LENGTH_LIMIT,
attributeCountLimit: (0, core_1.getEnv)().OTEL_ATTRIBUTE_COUNT_LIMIT,
},
spanLimits: {
attributeValueLengthLimit: (0, core_1.getEnv)().OTEL_SPAN_ATTRIBUTE_VALUE_LENGTH_LIMIT,
attributeCountLimit: (0, core_1.getEnv)().OTEL_SPAN_ATTRIBUTE_COUNT_LIMIT,
linkCountLimit: (0, core_1.getEnv)().OTEL_SPAN_LINK_COUNT_LIMIT,
eventCountLimit: (0, core_1.getEnv)().OTEL_SPAN_EVENT_COUNT_LIMIT,
},
};
// object needs to be wrapped in this function and called when needed otherwise
// envs are parsed before tests are ran - causes tests using these envs to fail
function loadDefaultConfig() {
return {
sampler: buildSamplerFromEnv(env),
forceFlushTimeoutMillis: 30000,
generalLimits: {
attributeValueLengthLimit: (0, core_1.getEnv)().OTEL_ATTRIBUTE_VALUE_LENGTH_LIMIT,
attributeCountLimit: (0, core_1.getEnv)().OTEL_ATTRIBUTE_COUNT_LIMIT,
},
spanLimits: {
attributeValueLengthLimit: (0, core_1.getEnv)().OTEL_SPAN_ATTRIBUTE_VALUE_LENGTH_LIMIT,
attributeCountLimit: (0, core_1.getEnv)().OTEL_SPAN_ATTRIBUTE_COUNT_LIMIT,
linkCountLimit: (0, core_1.getEnv)().OTEL_SPAN_LINK_COUNT_LIMIT,
eventCountLimit: (0, core_1.getEnv)().OTEL_SPAN_EVENT_COUNT_LIMIT,
},
};
}
exports.loadDefaultConfig = loadDefaultConfig;
/**

@@ -54,22 +63,22 @@ * Based on environment, builds a sampler, complies with specification.

case core_1.TracesSamplerValues.AlwaysOn:
return new core_1.AlwaysOnSampler();
return new AlwaysOnSampler_1.AlwaysOnSampler();
case core_1.TracesSamplerValues.AlwaysOff:
return new core_1.AlwaysOffSampler();
return new AlwaysOffSampler_1.AlwaysOffSampler();
case core_1.TracesSamplerValues.ParentBasedAlwaysOn:
return new core_1.ParentBasedSampler({
root: new core_1.AlwaysOnSampler(),
return new ParentBasedSampler_1.ParentBasedSampler({
root: new AlwaysOnSampler_1.AlwaysOnSampler(),
});
case core_1.TracesSamplerValues.ParentBasedAlwaysOff:
return new core_1.ParentBasedSampler({
root: new core_1.AlwaysOffSampler(),
return new ParentBasedSampler_1.ParentBasedSampler({
root: new AlwaysOffSampler_1.AlwaysOffSampler(),
});
case core_1.TracesSamplerValues.TraceIdRatio:
return new core_1.TraceIdRatioBasedSampler(getSamplerProbabilityFromEnv(environment));
return new TraceIdRatioBasedSampler_1.TraceIdRatioBasedSampler(getSamplerProbabilityFromEnv(environment));
case core_1.TracesSamplerValues.ParentBasedTraceIdRatio:
return new core_1.ParentBasedSampler({
root: new core_1.TraceIdRatioBasedSampler(getSamplerProbabilityFromEnv(environment)),
return new ParentBasedSampler_1.ParentBasedSampler({
root: new TraceIdRatioBasedSampler_1.TraceIdRatioBasedSampler(getSamplerProbabilityFromEnv(environment)),
});
default:
api_1.diag.error(`OTEL_TRACES_SAMPLER value "${environment.OTEL_TRACES_SAMPLER} invalid, defaulting to ${FALLBACK_OTEL_TRACES_SAMPLER}".`);
return new core_1.AlwaysOnSampler();
return new AlwaysOnSampler_1.AlwaysOnSampler();
}

@@ -76,0 +85,0 @@ }

@@ -10,2 +10,7 @@ export * from './Tracer';

export * from './export/NoopSpanProcessor';
export * from './sampler/AlwaysOffSampler';
export * from './sampler/AlwaysOnSampler';
export * from './sampler/ParentBasedSampler';
export * from './sampler/TraceIdRatioBasedSampler';
export * from './Sampler';
export * from './Span';

@@ -15,2 +20,3 @@ export * from './SpanProcessor';

export * from './types';
export * from './IdGenerator';
//# sourceMappingURL=index.d.ts.map

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

__exportStar(require("./export/NoopSpanProcessor"), exports);
__exportStar(require("./sampler/AlwaysOffSampler"), exports);
__exportStar(require("./sampler/AlwaysOnSampler"), exports);
__exportStar(require("./sampler/ParentBasedSampler"), exports);
__exportStar(require("./sampler/TraceIdRatioBasedSampler"), exports);
__exportStar(require("./Sampler"), exports);
__exportStar(require("./Span"), exports);

@@ -42,2 +47,3 @@ __exportStar(require("./SpanProcessor"), exports);

__exportStar(require("./types"), exports);
__exportStar(require("./IdGenerator"), exports);
//# sourceMappingURL=index.js.map
export * from './export/BatchSpanProcessor';
export * from './RandomIdGenerator';
//# sourceMappingURL=index.d.ts.map

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

__exportStar(require("./export/BatchSpanProcessor"), exports);
__exportStar(require("./RandomIdGenerator"), exports);
//# sourceMappingURL=index.js.map
export * from './export/BatchSpanProcessor';
export * from './RandomIdGenerator';
//# sourceMappingURL=index.d.ts.map

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

__exportStar(require("./export/BatchSpanProcessor"), exports);
__exportStar(require("./RandomIdGenerator"), exports);
//# sourceMappingURL=index.js.map

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

const utility_1 = require("./utility");
const platform_1 = require("./platform");
/**

@@ -37,3 +38,3 @@ * This class represents a basic tracer.

this._spanLimits = localConfig.spanLimits;
this._idGenerator = config.idGenerator || new core_1.RandomIdGenerator();
this._idGenerator = config.idGenerator || new platform_1.RandomIdGenerator();
this.resource = _tracerProvider.resource;

@@ -40,0 +41,0 @@ this.instrumentationLibrary = instrumentationLibrary;

@@ -1,5 +0,5 @@

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

@@ -6,0 +6,0 @@ * TracerConfig provides an interface for configuring a Basic Tracer.

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

import { Sampler } from '@opentelemetry/api';
import { Sampler } from './Sampler';
import { SpanLimits, TracerConfig, GeneralLimits } from './types';

@@ -3,0 +3,0 @@ /**

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

const config_1 = require("./config");
const core_1 = require("@opentelemetry/core");
/**

@@ -29,5 +30,6 @@ * Function to merge Default configuration (as specified in './config') with

};
const target = Object.assign({}, config_1.DEFAULT_CONFIG, perInstanceDefaults, userConfig);
target.generalLimits = Object.assign({}, config_1.DEFAULT_CONFIG.generalLimits, userConfig.generalLimits || {});
target.spanLimits = Object.assign({}, config_1.DEFAULT_CONFIG.spanLimits, userConfig.spanLimits || {});
const DEFAULT_CONFIG = (0, config_1.loadDefaultConfig)();
const target = Object.assign({}, DEFAULT_CONFIG, perInstanceDefaults, userConfig);
target.generalLimits = Object.assign({}, DEFAULT_CONFIG.generalLimits, userConfig.generalLimits || {});
target.spanLimits = Object.assign({}, DEFAULT_CONFIG.spanLimits, userConfig.spanLimits || {});
return target;

@@ -42,18 +44,15 @@ }

function reconfigureLimits(userConfig) {
var _a, _b;
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
const spanLimits = Object.assign({}, userConfig.spanLimits);
const parsedEnvConfig = (0, core_1.getEnvWithoutDefaults)();
/**
* When span attribute count limit is not defined, but general attribute count limit is defined
* Then, span attribute count limit will be same as general one
* Reassign span attribute count limit to use first non null value defined by user or use default value
*/
if (spanLimits.attributeCountLimit == null && ((_a = userConfig.generalLimits) === null || _a === void 0 ? void 0 : _a.attributeCountLimit) != null) {
spanLimits.attributeCountLimit = userConfig.generalLimits.attributeCountLimit;
}
spanLimits.attributeCountLimit =
(_f = (_e = (_d = (_b = (_a = userConfig.spanLimits) === null || _a === void 0 ? void 0 : _a.attributeCountLimit) !== null && _b !== void 0 ? _b : (_c = userConfig.generalLimits) === null || _c === void 0 ? void 0 : _c.attributeCountLimit) !== null && _d !== void 0 ? _d : parsedEnvConfig.OTEL_SPAN_ATTRIBUTE_COUNT_LIMIT) !== null && _e !== void 0 ? _e : parsedEnvConfig.OTEL_ATTRIBUTE_COUNT_LIMIT) !== null && _f !== void 0 ? _f : core_1.DEFAULT_ATTRIBUTE_COUNT_LIMIT;
/**
* When span attribute value length limit is not defined, but general attribute value length limit is defined
* Then, span attribute value length limit will be same as general one
* Reassign span attribute value length limit to use first non null value defined by user or use default value
*/
if (spanLimits.attributeValueLengthLimit == null && ((_b = userConfig.generalLimits) === null || _b === void 0 ? void 0 : _b.attributeValueLengthLimit) != null) {
spanLimits.attributeValueLengthLimit = userConfig.generalLimits.attributeValueLengthLimit;
}
spanLimits.attributeValueLengthLimit =
(_m = (_l = (_k = (_h = (_g = userConfig.spanLimits) === null || _g === void 0 ? void 0 : _g.attributeValueLengthLimit) !== null && _h !== void 0 ? _h : (_j = userConfig.generalLimits) === null || _j === void 0 ? void 0 : _j.attributeValueLengthLimit) !== null && _k !== void 0 ? _k : parsedEnvConfig.OTEL_SPAN_ATTRIBUTE_VALUE_LENGTH_LIMIT) !== null && _l !== void 0 ? _l : parsedEnvConfig.OTEL_ATTRIBUTE_VALUE_LENGTH_LIMIT) !== null && _m !== void 0 ? _m : core_1.DEFAULT_ATTRIBUTE_VALUE_LENGTH_LIMIT;
return Object.assign({}, userConfig, { spanLimits });

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

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

export declare const VERSION = "1.5.0";
export declare const VERSION = "1.6.0";
//# sourceMappingURL=version.d.ts.map

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

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

@@ -67,6 +67,6 @@ "main": "build/src/index.js",

"devDependencies": {
"@opentelemetry/api": ">=1.0.0 <1.2.0",
"@types/mocha": "8.2.3",
"@types/node": "14.17.33",
"@types/sinon": "10.0.6",
"@opentelemetry/api": ">=1.0.0 <1.3.0",
"@types/mocha": "9.1.1",
"@types/node": "18.6.5",
"@types/sinon": "10.0.13",
"@types/webpack-env": "1.16.3",

@@ -82,8 +82,8 @@ "codecov": "3.8.3",

"karma-webpack": "4.0.2",
"mocha": "7.2.0",
"mocha": "10.0.0",
"nyc": "15.1.0",
"rimraf": "3.0.2",
"sinon": "12.0.1",
"ts-loader": "8.3.0",
"ts-mocha": "9.0.2",
"sinon": "14.0.0",
"ts-loader": "8.4.0",
"ts-mocha": "10.0.0",
"typescript": "4.4.4",

@@ -93,11 +93,11 @@ "webpack": "4.46.0"

"peerDependencies": {
"@opentelemetry/api": ">=1.0.0 <1.2.0"
"@opentelemetry/api": ">=1.0.0 <1.3.0"
},
"dependencies": {
"@opentelemetry/core": "1.5.0",
"@opentelemetry/resources": "1.5.0",
"@opentelemetry/semantic-conventions": "1.5.0"
"@opentelemetry/core": "1.6.0",
"@opentelemetry/resources": "1.6.0",
"@opentelemetry/semantic-conventions": "1.6.0"
},
"homepage": "https://github.com/open-telemetry/opentelemetry-js/tree/main/packages/opentelemetry-sdk-trace-base",
"gitHead": "776656b6e0cd0fc49a52b734702bc77110e483f1"
"gitHead": "a5abee69119cc41d9d34f6beb5c1826eef1ac0dd"
}

@@ -49,2 +49,103 @@ # OpenTelemetry Tracing SDK

## Built-in Samplers
Sampler is used to make decisions on `Span` sampling.
### AlwaysOn Sampler
Samples every trace regardless of upstream sampling decisions.
> This is used as a default Sampler
```js
const { NodeTracerProvider } = require("@opentelemetry/sdk-trace-node");
const { AlwaysOnSampler } = require("@opentelemetry/core");
const tracerProvider = new NodeTracerProvider({
sampler: new AlwaysOnSampler()
});
```
### AlwaysOff Sampler
Doesn't sample any trace, regardless of upstream sampling decisions.
```js
const { NodeTracerProvider } = require("@opentelemetry/sdk-trace-node");
const { AlwaysOffSampler } = require("@opentelemetry/core");
const tracerProvider = new NodeTracerProvider({
sampler: new AlwaysOffSampler()
});
```
### TraceIdRatioBased Sampler
Samples some percentage of traces, calculated deterministically using the trace ID.
Any trace that would be sampled at a given percentage will also be sampled at any higher percentage.
The `TraceIDRatioSampler` may be used with the `ParentBasedSampler` to respect the sampled flag of an incoming trace.
```js
const { NodeTracerProvider } = require("@opentelemetry/sdk-trace-node");
const { TraceIdRatioBasedSampler } = require("@opentelemetry/core");
const tracerProvider = new NodeTracerProvider({
// See details of ParentBasedSampler below
sampler: new ParentBasedSampler({
// Trace ID Ratio Sampler accepts a positional argument
// which represents the percentage of traces which should
// be sampled.
root: new TraceIdRatioBasedSampler(0.5)
});
});
```
### ParentBased Sampler
- This is a composite sampler. `ParentBased` helps distinguished between the
following cases:
- No parent (root span).
- Remote parent with `sampled` flag `true`
- Remote parent with `sampled` flag `false`
- Local parent with `sampled` flag `true`
- Local parent with `sampled` flag `false`
Required parameters:
- `root(Sampler)` - Sampler called for spans with no parent (root spans)
Optional parameters:
- `remoteParentSampled(Sampler)` (default: `AlwaysOn`)
- `remoteParentNotSampled(Sampler)` (default: `AlwaysOff`)
- `localParentSampled(Sampler)` (default: `AlwaysOn`)
- `localParentNotSampled(Sampler)` (default: `AlwaysOff`)
|Parent| parent.isRemote() | parent.isSampled()| Invoke sampler|
|--|--|--|--|
|absent| n/a | n/a |`root()`|
|present|true|true|`remoteParentSampled()`|
|present|true|false|`remoteParentNotSampled()`|
|present|false|true|`localParentSampled()`|
|present|false|false|`localParentNotSampled()`|
```js
const { NodeTracerProvider } = require("@opentelemetry/sdk-trace-node");
const { ParentBasedSampler, AlwaysOffSampler, TraceIdRatioBasedSampler } = require("@opentelemetry/core");
const tracerProvider = new NodeTracerProvider({
sampler: new ParentBasedSampler({
// By default, the ParentBasedSampler will respect the parent span's sampling
// decision. This is configurable by providing a different sampler to use
// based on the situation. See configuration details above.
//
// This will delegate the sampling decision of all root traces (no parent)
// to the TraceIdRatioBasedSampler.
// See details of TraceIdRatioBasedSampler above.
root: new TraceIdRatioBasedSampler(0.5)
})
});
```
## Example

@@ -51,0 +152,0 @@

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