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

@opentelemetry/core

Package Overview
Dependencies
Maintainers
2
Versions
173
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@opentelemetry/core - npm Package Compare versions

Comparing version 1.8.0 to 1.9.0

6

build/esm/baggage/propagation/W3CBaggagePropagator.js

@@ -18,3 +18,3 @@ /*

import { isTracingSuppressed } from '../../trace/suppress-tracing';
import { BAGGAGE_HEADER, BAGGAGE_ITEMS_SEPARATOR, BAGGAGE_MAX_NAME_VALUE_PAIRS, BAGGAGE_MAX_PER_NAME_VALUE_PAIRS } from '../constants';
import { BAGGAGE_HEADER, BAGGAGE_ITEMS_SEPARATOR, BAGGAGE_MAX_NAME_VALUE_PAIRS, BAGGAGE_MAX_PER_NAME_VALUE_PAIRS, } from '../constants';
import { getKeyPairs, parsePairKeyValue, serializeKeyPairs } from '../utils';

@@ -46,3 +46,5 @@ /**

var headerValue = getter.get(carrier, BAGGAGE_HEADER);
var baggageString = Array.isArray(headerValue) ? headerValue.join(BAGGAGE_ITEMS_SEPARATOR) : headerValue;
var baggageString = Array.isArray(headerValue)
? headerValue.join(BAGGAGE_ITEMS_SEPARATOR)
: headerValue;
if (!baggageString)

@@ -49,0 +51,0 @@ return context;

@@ -32,3 +32,3 @@ var __read = (this && this.__read) || function (o, n) {

*/
import { baggageEntryMetadataFromString } from '@opentelemetry/api';
import { baggageEntryMetadataFromString, } from '@opentelemetry/api';
import { BAGGAGE_ITEMS_SEPARATOR, BAGGAGE_PROPERTIES_SEPARATOR, BAGGAGE_KEY_PAIR_SEPARATOR, BAGGAGE_MAX_TOTAL_LENGTH, } from './constants';

@@ -35,0 +35,0 @@ export function serializeKeyPairs(keyPairs) {

import * as api from '@opentelemetry/api';
/**
* Converts a number of milliseconds from epoch to HrTime([seconds, remainder in nanoseconds]).
* @param epochMillis
*/
export declare function millisToHrTime(epochMillis: number): api.HrTime;
export declare function getTimeOrigin(): number;
/**
* Returns an hrtime calculated via performance component.

@@ -49,2 +55,6 @@ * @param performanceNow

export declare function isTimeInput(value: unknown): value is api.HrTime | number | Date;
/**
* Given 2 HrTime formatted times, return their sum as an HrTime.
*/
export declare function addHrTimes(time1: api.HrTime, time2: api.HrTime): api.HrTime;
//# sourceMappingURL=time.d.ts.map

@@ -18,16 +18,10 @@ /*

var NANOSECOND_DIGITS = 9;
var NANOSECOND_DIGITS_IN_MILLIS = 6;
var MILLISECONDS_TO_NANOSECONDS = Math.pow(10, NANOSECOND_DIGITS_IN_MILLIS);
var SECOND_TO_NANOSECONDS = Math.pow(10, NANOSECOND_DIGITS);
/**
* Converts a number to HrTime, HrTime = [number, number].
* The first number is UNIX Epoch time in seconds since 00:00:00 UTC on 1 January 1970.
* The second number represents the partial second elapsed since Unix Epoch time represented by first number in nanoseconds.
* For example, 2021-01-01T12:30:10.150Z in UNIX Epoch time in milliseconds is represented as 1609504210150.
* numberToHrtime calculates the first number by converting and truncating the Epoch time in milliseconds to seconds:
* HrTime[0] = Math.trunc(1609504210150 / 1000) = 1609504210.
* numberToHrtime calculates the second number by converting the digits after the decimal point of the subtraction, (1609504210150 / 1000) - HrTime[0], to nanoseconds:
* HrTime[1] = Number((1609504210.150 - HrTime[0]).toFixed(9)) * SECOND_TO_NANOSECONDS = 150000000.
* This is represented in HrTime format as [1609504210, 150000000].
* Converts a number of milliseconds from epoch to HrTime([seconds, remainder in nanoseconds]).
* @param epochMillis
*/
function numberToHrtime(epochMillis) {
export function millisToHrTime(epochMillis) {
var epochSeconds = epochMillis / 1000;

@@ -37,7 +31,6 @@ // Decimals only.

// Round sub-nanosecond accuracy to nanosecond.
var nanos = Number((epochSeconds - seconds).toFixed(NANOSECOND_DIGITS)) *
SECOND_TO_NANOSECONDS;
var nanos = Math.round((epochMillis % 1000) * MILLISECONDS_TO_NANOSECONDS);
return [seconds, nanos];
}
function getTimeOrigin() {
export function getTimeOrigin() {
var timeOrigin = performance.timeOrigin;

@@ -55,12 +48,5 @@ if (typeof timeOrigin !== 'number') {

export function hrTime(performanceNow) {
var timeOrigin = numberToHrtime(getTimeOrigin());
var now = numberToHrtime(typeof performanceNow === 'number' ? performanceNow : performance.now());
var seconds = timeOrigin[0] + now[0];
var nanos = timeOrigin[1] + now[1];
// Nanoseconds
if (nanos > SECOND_TO_NANOSECONDS) {
nanos -= SECOND_TO_NANOSECONDS;
seconds += 1;
}
return [seconds, nanos];
var timeOrigin = millisToHrTime(getTimeOrigin());
var now = millisToHrTime(typeof performanceNow === 'number' ? performanceNow : performance.now());
return addHrTimes(timeOrigin, now);
}

@@ -84,7 +70,7 @@ /**

// epoch milliseconds or performance.timeOrigin
return numberToHrtime(time);
return millisToHrTime(time);
}
}
else if (time instanceof Date) {
return numberToHrtime(time.getTime());
return millisToHrTime(time.getTime());
}

@@ -162,2 +148,14 @@ else {

}
/**
* Given 2 HrTime formatted times, return their sum as an HrTime.
*/
export function addHrTimes(time1, time2) {
var out = [time1[0] + time2[0], time1[1] + time2[1]];
// Nanoseconds
if (out[1] >= SECOND_TO_NANOSECONDS) {
out[1] -= SECOND_TO_NANOSECONDS;
out[0] += 1;
}
return out;
}
//# sourceMappingURL=time.js.map

@@ -47,4 +47,4 @@ /*

export var internal = {
_export: _export
_export: _export,
};
//# sourceMappingURL=index.js.map

@@ -6,6 +6,6 @@ import { ExportResult } from '../ExportResult';

/**
* @internal
* Shared functionality used by Exporters while exporting data, including suppresion of Traces.
*/
* @internal
* Shared functionality used by Exporters while exporting data, including suppresion of Traces.
*/
export declare function _export<T>(exporter: Exporter<T>, arg: T): Promise<ExportResult>;
//# sourceMappingURL=exporter.d.ts.map

@@ -19,5 +19,5 @@ /*

/**
* @internal
* Shared functionality used by Exporters while exporting data, including suppresion of Traces.
*/
* @internal
* Shared functionality used by Exporters while exporting data, including suppresion of Traces.
*/
export function _export(exporter, arg) {

@@ -24,0 +24,0 @@ return new Promise(function (resolve) {

@@ -26,7 +26,11 @@ /*

// eslint-disable-next-line node/no-unsupported-features/es-builtins, no-undef
export var _globalThis = typeof globalThis === 'object' ? globalThis :
typeof self === 'object' ? self :
typeof window === 'object' ? window :
typeof global === 'object' ? global :
{};
export var _globalThis = typeof globalThis === 'object'
? globalThis
: typeof self === 'object'
? self
: typeof window === 'object'
? window
: typeof global === 'object'
? global
: {};
//# sourceMappingURL=globalThis.js.map

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

try {
Promise.resolve((_a = this._callback).call.apply(_a, __spreadArray([this._that], __read(args), false)))
.then(function (val) { return _this._deferred.resolve(val); }, function (err) { return _this._deferred.reject(err); });
Promise.resolve((_a = this._callback).call.apply(_a, __spreadArray([this._that], __read(args), false))).then(function (val) { return _this._deferred.resolve(val); }, function (err) { return _this._deferred.reject(err); });
}

@@ -80,0 +79,0 @@ catch (err) {

@@ -5,2 +5,6 @@ import { DiagLogLevel } from '@opentelemetry/api';

*/
declare const ENVIRONMENT_BOOLEAN_KEYS: readonly ["OTEL_SDK_DISABLED"];
declare type ENVIRONMENT_BOOLEANS = {
[K in typeof ENVIRONMENT_BOOLEAN_KEYS[number]]?: boolean;
};
declare const ENVIRONMENT_NUMBERS_KEYS: readonly ["OTEL_BSP_EXPORT_TIMEOUT", "OTEL_BSP_MAX_EXPORT_BATCH_SIZE", "OTEL_BSP_MAX_QUEUE_SIZE", "OTEL_BSP_SCHEDULE_DELAY", "OTEL_ATTRIBUTE_VALUE_LENGTH_LIMIT", "OTEL_ATTRIBUTE_COUNT_LIMIT", "OTEL_SPAN_ATTRIBUTE_VALUE_LENGTH_LIMIT", "OTEL_SPAN_ATTRIBUTE_COUNT_LIMIT", "OTEL_SPAN_EVENT_COUNT_LIMIT", "OTEL_SPAN_LINK_COUNT_LIMIT", "OTEL_EXPORTER_OTLP_TIMEOUT", "OTEL_EXPORTER_OTLP_TRACES_TIMEOUT", "OTEL_EXPORTER_OTLP_METRICS_TIMEOUT", "OTEL_EXPORTER_JAEGER_AGENT_PORT"];

@@ -57,3 +61,3 @@ declare type ENVIRONMENT_NUMBERS = {

OTEL_EXPORTER_OTLP_METRICS_TEMPORALITY_PREFERENCE?: string;
} & ENVIRONMENT_NUMBERS & ENVIRONMENT_LISTS;
} & ENVIRONMENT_BOOLEANS & ENVIRONMENT_NUMBERS & ENVIRONMENT_LISTS;
export declare type RAW_ENVIRONMENT = {

@@ -60,0 +64,0 @@ [key: string]: string | number | undefined | string[];

@@ -23,2 +23,6 @@ /*

*/
var ENVIRONMENT_BOOLEAN_KEYS = ['OTEL_SDK_DISABLED'];
function isEnvVarABoolean(key) {
return (ENVIRONMENT_BOOLEAN_KEYS.indexOf(key) > -1);
}
var ENVIRONMENT_NUMBERS_KEYS = [

@@ -56,2 +60,3 @@ 'OTEL_BSP_EXPORT_TIMEOUT',

export var DEFAULT_ENVIRONMENT = {
OTEL_SDK_DISABLED: false,
CONTAINER_NAME: '',

@@ -93,3 +98,3 @@ ECS_CONTAINER_METADATA_URI_V4: '',

OTEL_SPAN_LINK_COUNT_LIMIT: 128,
OTEL_TRACES_EXPORTER: 'otlp',
OTEL_TRACES_EXPORTER: '',
OTEL_TRACES_SAMPLER: TracesSamplerValues.ParentBasedAlwaysOn,

@@ -115,5 +120,18 @@ OTEL_TRACES_SAMPLER_ARG: '',

OTEL_EXPORTER_OTLP_METRICS_PROTOCOL: 'http/protobuf',
OTEL_EXPORTER_OTLP_METRICS_TEMPORALITY_PREFERENCE: 'cumulative'
OTEL_EXPORTER_OTLP_METRICS_TEMPORALITY_PREFERENCE: 'cumulative',
};
/**
* @param key
* @param environment
* @param values
*/
function parseBoolean(key, environment, values) {
if (typeof values[key] === 'undefined') {
return;
}
var value = String(values[key]);
// support case-insensitive "true"
environment[key] = value.toLowerCase() === 'true';
}
/**
* Parses a variable as number with number validation

@@ -196,3 +214,6 @@ * @param name

default:
if (isEnvVarANumber(key)) {
if (isEnvVarABoolean(key)) {
parseBoolean(key, environment, values);
}
else if (isEnvVarANumber(key)) {
parseNumber(key, environment, values);

@@ -218,6 +239,6 @@ }

export function getEnvWithoutDefaults() {
return typeof process !== 'undefined' ?
parseEnvironment(process.env) :
parseEnvironment(_globalThis);
return typeof process !== 'undefined'
? parseEnvironment(process.env)
: parseEnvironment(_globalThis);
}
//# sourceMappingURL=environment.js.map

@@ -82,4 +82,5 @@ /*

var Ctor = hasOwnProperty.call(proto, 'constructor') && proto.constructor;
return typeof Ctor == 'function' && Ctor instanceof Ctor &&
funcToString.call(Ctor) === objectCtorString;
return (typeof Ctor == 'function' &&
Ctor instanceof Ctor &&
funcToString.call(Ctor) === objectCtorString);
}

@@ -124,3 +125,3 @@ /**

}
return (symToStringTag && symToStringTag in Object(value))
return symToStringTag && symToStringTag in Object(value)
? getRawTag(value)

@@ -127,0 +128,0 @@ : objectToString(value);

@@ -143,6 +143,9 @@ /*

function isObject(value) {
return !isPrimitive(value) && !isArray(value) && !isFunction(value) && typeof value === 'object';
return (!isPrimitive(value) &&
!isArray(value) &&
!isFunction(value) &&
typeof value === 'object');
}
function isPrimitive(value) {
return typeof value === 'string' ||
return (typeof value === 'string' ||
typeof value === 'number' ||

@@ -153,3 +156,3 @@ typeof value === 'boolean' ||

value instanceof RegExp ||
value === null;
value === null);
}

@@ -156,0 +159,0 @@ function shouldMerge(one, two) {

@@ -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

@@ -18,3 +18,3 @@ /*

import { isTracingSuppressed } from '../../trace/suppress-tracing';
import { BAGGAGE_HEADER, BAGGAGE_ITEMS_SEPARATOR, BAGGAGE_MAX_NAME_VALUE_PAIRS, BAGGAGE_MAX_PER_NAME_VALUE_PAIRS } from '../constants';
import { BAGGAGE_HEADER, BAGGAGE_ITEMS_SEPARATOR, BAGGAGE_MAX_NAME_VALUE_PAIRS, BAGGAGE_MAX_PER_NAME_VALUE_PAIRS, } from '../constants';
import { getKeyPairs, parsePairKeyValue, serializeKeyPairs } from '../utils';

@@ -44,3 +44,5 @@ /**

const headerValue = getter.get(carrier, BAGGAGE_HEADER);
const baggageString = Array.isArray(headerValue) ? headerValue.join(BAGGAGE_ITEMS_SEPARATOR) : headerValue;
const baggageString = Array.isArray(headerValue)
? headerValue.join(BAGGAGE_ITEMS_SEPARATOR)
: headerValue;
if (!baggageString)

@@ -47,0 +49,0 @@ return context;

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

*/
import { baggageEntryMetadataFromString } from '@opentelemetry/api';
import { baggageEntryMetadataFromString, } from '@opentelemetry/api';
import { BAGGAGE_ITEMS_SEPARATOR, BAGGAGE_PROPERTIES_SEPARATOR, BAGGAGE_KEY_PAIR_SEPARATOR, BAGGAGE_MAX_TOTAL_LENGTH, } from './constants';

@@ -19,0 +19,0 @@ export function serializeKeyPairs(keyPairs) {

import * as api from '@opentelemetry/api';
/**
* Converts a number of milliseconds from epoch to HrTime([seconds, remainder in nanoseconds]).
* @param epochMillis
*/
export declare function millisToHrTime(epochMillis: number): api.HrTime;
export declare function getTimeOrigin(): number;
/**
* Returns an hrtime calculated via performance component.

@@ -49,2 +55,6 @@ * @param performanceNow

export declare function isTimeInput(value: unknown): value is api.HrTime | number | Date;
/**
* Given 2 HrTime formatted times, return their sum as an HrTime.
*/
export declare function addHrTimes(time1: api.HrTime, time2: api.HrTime): api.HrTime;
//# sourceMappingURL=time.d.ts.map

@@ -18,16 +18,10 @@ /*

const NANOSECOND_DIGITS = 9;
const NANOSECOND_DIGITS_IN_MILLIS = 6;
const MILLISECONDS_TO_NANOSECONDS = Math.pow(10, NANOSECOND_DIGITS_IN_MILLIS);
const SECOND_TO_NANOSECONDS = Math.pow(10, NANOSECOND_DIGITS);
/**
* Converts a number to HrTime, HrTime = [number, number].
* The first number is UNIX Epoch time in seconds since 00:00:00 UTC on 1 January 1970.
* The second number represents the partial second elapsed since Unix Epoch time represented by first number in nanoseconds.
* For example, 2021-01-01T12:30:10.150Z in UNIX Epoch time in milliseconds is represented as 1609504210150.
* numberToHrtime calculates the first number by converting and truncating the Epoch time in milliseconds to seconds:
* HrTime[0] = Math.trunc(1609504210150 / 1000) = 1609504210.
* numberToHrtime calculates the second number by converting the digits after the decimal point of the subtraction, (1609504210150 / 1000) - HrTime[0], to nanoseconds:
* HrTime[1] = Number((1609504210.150 - HrTime[0]).toFixed(9)) * SECOND_TO_NANOSECONDS = 150000000.
* This is represented in HrTime format as [1609504210, 150000000].
* Converts a number of milliseconds from epoch to HrTime([seconds, remainder in nanoseconds]).
* @param epochMillis
*/
function numberToHrtime(epochMillis) {
export function millisToHrTime(epochMillis) {
const epochSeconds = epochMillis / 1000;

@@ -37,7 +31,6 @@ // Decimals only.

// Round sub-nanosecond accuracy to nanosecond.
const nanos = Number((epochSeconds - seconds).toFixed(NANOSECOND_DIGITS)) *
SECOND_TO_NANOSECONDS;
const nanos = Math.round((epochMillis % 1000) * MILLISECONDS_TO_NANOSECONDS);
return [seconds, nanos];
}
function getTimeOrigin() {
export function getTimeOrigin() {
let timeOrigin = performance.timeOrigin;

@@ -55,12 +48,5 @@ if (typeof timeOrigin !== 'number') {

export function hrTime(performanceNow) {
const timeOrigin = numberToHrtime(getTimeOrigin());
const now = numberToHrtime(typeof performanceNow === 'number' ? performanceNow : performance.now());
let seconds = timeOrigin[0] + now[0];
let nanos = timeOrigin[1] + now[1];
// Nanoseconds
if (nanos > SECOND_TO_NANOSECONDS) {
nanos -= SECOND_TO_NANOSECONDS;
seconds += 1;
}
return [seconds, nanos];
const timeOrigin = millisToHrTime(getTimeOrigin());
const now = millisToHrTime(typeof performanceNow === 'number' ? performanceNow : performance.now());
return addHrTimes(timeOrigin, now);
}

@@ -84,7 +70,7 @@ /**

// epoch milliseconds or performance.timeOrigin
return numberToHrtime(time);
return millisToHrTime(time);
}
}
else if (time instanceof Date) {
return numberToHrtime(time.getTime());
return millisToHrTime(time.getTime());
}

@@ -162,2 +148,14 @@ else {

}
/**
* Given 2 HrTime formatted times, return their sum as an HrTime.
*/
export function addHrTimes(time1, time2) {
const out = [time1[0] + time2[0], time1[1] + time2[1]];
// Nanoseconds
if (out[1] >= SECOND_TO_NANOSECONDS) {
out[1] -= SECOND_TO_NANOSECONDS;
out[0] += 1;
}
return out;
}
//# sourceMappingURL=time.js.map

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

export const internal = {
_export
_export,
};
//# sourceMappingURL=index.js.map

@@ -6,6 +6,6 @@ import { ExportResult } from '../ExportResult';

/**
* @internal
* Shared functionality used by Exporters while exporting data, including suppresion of Traces.
*/
* @internal
* Shared functionality used by Exporters while exporting data, including suppresion of Traces.
*/
export declare function _export<T>(exporter: Exporter<T>, arg: T): Promise<ExportResult>;
//# sourceMappingURL=exporter.d.ts.map

@@ -19,5 +19,5 @@ /*

/**
* @internal
* Shared functionality used by Exporters while exporting data, including suppresion of Traces.
*/
* @internal
* Shared functionality used by Exporters while exporting data, including suppresion of Traces.
*/
export function _export(exporter, arg) {

@@ -24,0 +24,0 @@ return new Promise(resolve => {

@@ -26,7 +26,11 @@ /*

// eslint-disable-next-line node/no-unsupported-features/es-builtins, no-undef
export const _globalThis = typeof globalThis === 'object' ? globalThis :
typeof self === 'object' ? self :
typeof window === 'object' ? window :
typeof global === 'object' ? global :
{};
export const _globalThis = typeof globalThis === 'object'
? globalThis
: typeof self === 'object'
? self
: typeof window === 'object'
? window
: typeof global === 'object'
? global
: {};
//# sourceMappingURL=globalThis.js.map

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

try {
Promise.resolve(this._callback.call(this._that, ...args))
.then(val => this._deferred.resolve(val), err => this._deferred.reject(err));
Promise.resolve(this._callback.call(this._that, ...args)).then(val => this._deferred.resolve(val), err => this._deferred.reject(err));
}

@@ -41,0 +40,0 @@ catch (err) {

@@ -5,2 +5,6 @@ import { DiagLogLevel } from '@opentelemetry/api';

*/
declare const ENVIRONMENT_BOOLEAN_KEYS: readonly ["OTEL_SDK_DISABLED"];
declare type ENVIRONMENT_BOOLEANS = {
[K in typeof ENVIRONMENT_BOOLEAN_KEYS[number]]?: boolean;
};
declare const ENVIRONMENT_NUMBERS_KEYS: readonly ["OTEL_BSP_EXPORT_TIMEOUT", "OTEL_BSP_MAX_EXPORT_BATCH_SIZE", "OTEL_BSP_MAX_QUEUE_SIZE", "OTEL_BSP_SCHEDULE_DELAY", "OTEL_ATTRIBUTE_VALUE_LENGTH_LIMIT", "OTEL_ATTRIBUTE_COUNT_LIMIT", "OTEL_SPAN_ATTRIBUTE_VALUE_LENGTH_LIMIT", "OTEL_SPAN_ATTRIBUTE_COUNT_LIMIT", "OTEL_SPAN_EVENT_COUNT_LIMIT", "OTEL_SPAN_LINK_COUNT_LIMIT", "OTEL_EXPORTER_OTLP_TIMEOUT", "OTEL_EXPORTER_OTLP_TRACES_TIMEOUT", "OTEL_EXPORTER_OTLP_METRICS_TIMEOUT", "OTEL_EXPORTER_JAEGER_AGENT_PORT"];

@@ -57,3 +61,3 @@ declare type ENVIRONMENT_NUMBERS = {

OTEL_EXPORTER_OTLP_METRICS_TEMPORALITY_PREFERENCE?: string;
} & ENVIRONMENT_NUMBERS & ENVIRONMENT_LISTS;
} & ENVIRONMENT_BOOLEANS & ENVIRONMENT_NUMBERS & ENVIRONMENT_LISTS;
export declare type RAW_ENVIRONMENT = {

@@ -60,0 +64,0 @@ [key: string]: string | number | undefined | string[];

@@ -23,2 +23,6 @@ /*

*/
const ENVIRONMENT_BOOLEAN_KEYS = ['OTEL_SDK_DISABLED'];
function isEnvVarABoolean(key) {
return (ENVIRONMENT_BOOLEAN_KEYS.indexOf(key) > -1);
}
const ENVIRONMENT_NUMBERS_KEYS = [

@@ -56,2 +60,3 @@ 'OTEL_BSP_EXPORT_TIMEOUT',

export const DEFAULT_ENVIRONMENT = {
OTEL_SDK_DISABLED: false,
CONTAINER_NAME: '',

@@ -93,3 +98,3 @@ ECS_CONTAINER_METADATA_URI_V4: '',

OTEL_SPAN_LINK_COUNT_LIMIT: 128,
OTEL_TRACES_EXPORTER: 'otlp',
OTEL_TRACES_EXPORTER: '',
OTEL_TRACES_SAMPLER: TracesSamplerValues.ParentBasedAlwaysOn,

@@ -115,5 +120,18 @@ OTEL_TRACES_SAMPLER_ARG: '',

OTEL_EXPORTER_OTLP_METRICS_PROTOCOL: 'http/protobuf',
OTEL_EXPORTER_OTLP_METRICS_TEMPORALITY_PREFERENCE: 'cumulative'
OTEL_EXPORTER_OTLP_METRICS_TEMPORALITY_PREFERENCE: 'cumulative',
};
/**
* @param key
* @param environment
* @param values
*/
function parseBoolean(key, environment, values) {
if (typeof values[key] === 'undefined') {
return;
}
const value = String(values[key]);
// support case-insensitive "true"
environment[key] = value.toLowerCase() === 'true';
}
/**
* Parses a variable as number with number validation

@@ -193,3 +211,6 @@ * @param name

default:
if (isEnvVarANumber(key)) {
if (isEnvVarABoolean(key)) {
parseBoolean(key, environment, values);
}
else if (isEnvVarANumber(key)) {
parseNumber(key, environment, values);

@@ -215,6 +236,6 @@ }

export function getEnvWithoutDefaults() {
return typeof process !== 'undefined' ?
parseEnvironment(process.env) :
parseEnvironment(_globalThis);
return typeof process !== 'undefined'
? parseEnvironment(process.env)
: parseEnvironment(_globalThis);
}
//# sourceMappingURL=environment.js.map

@@ -82,4 +82,5 @@ /*

const Ctor = hasOwnProperty.call(proto, 'constructor') && proto.constructor;
return typeof Ctor == 'function' && Ctor instanceof Ctor &&
funcToString.call(Ctor) === objectCtorString;
return (typeof Ctor == 'function' &&
Ctor instanceof Ctor &&
funcToString.call(Ctor) === objectCtorString);
}

@@ -124,3 +125,3 @@ /**

}
return (symToStringTag && symToStringTag in Object(value))
return symToStringTag && symToStringTag in Object(value)
? getRawTag(value)

@@ -127,0 +128,0 @@ : objectToString(value);

@@ -138,6 +138,9 @@ /*

function isObject(value) {
return !isPrimitive(value) && !isArray(value) && !isFunction(value) && typeof value === 'object';
return (!isPrimitive(value) &&
!isArray(value) &&
!isFunction(value) &&
typeof value === 'object');
}
function isPrimitive(value) {
return typeof value === 'string' ||
return (typeof value === 'string' ||
typeof value === 'number' ||

@@ -148,3 +151,3 @@ typeof value === 'boolean' ||

value instanceof RegExp ||
value === null;
value === null);
}

@@ -151,0 +154,0 @@ function shouldMerge(one, two) {

@@ -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

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

const headerValue = getter.get(carrier, constants_1.BAGGAGE_HEADER);
const baggageString = Array.isArray(headerValue) ? headerValue.join(constants_1.BAGGAGE_ITEMS_SEPARATOR) : headerValue;
const baggageString = Array.isArray(headerValue)
? headerValue.join(constants_1.BAGGAGE_ITEMS_SEPARATOR)
: headerValue;
if (!baggageString)

@@ -49,0 +51,0 @@ return context;

import * as api from '@opentelemetry/api';
/**
* Converts a number of milliseconds from epoch to HrTime([seconds, remainder in nanoseconds]).
* @param epochMillis
*/
export declare function millisToHrTime(epochMillis: number): api.HrTime;
export declare function getTimeOrigin(): number;
/**
* Returns an hrtime calculated via performance component.

@@ -49,2 +55,6 @@ * @param performanceNow

export declare function isTimeInput(value: unknown): value is api.HrTime | number | Date;
/**
* Given 2 HrTime formatted times, return their sum as an HrTime.
*/
export declare function addHrTimes(time1: api.HrTime, time2: api.HrTime): api.HrTime;
//# sourceMappingURL=time.d.ts.map

@@ -18,19 +18,13 @@ "use strict";

Object.defineProperty(exports, "__esModule", { value: true });
exports.isTimeInput = exports.isTimeInputHrTime = exports.hrTimeToMicroseconds = exports.hrTimeToMilliseconds = exports.hrTimeToNanoseconds = exports.hrTimeToTimeStamp = exports.hrTimeDuration = exports.timeInputToHrTime = exports.hrTime = void 0;
exports.addHrTimes = exports.isTimeInput = exports.isTimeInputHrTime = exports.hrTimeToMicroseconds = exports.hrTimeToMilliseconds = exports.hrTimeToNanoseconds = exports.hrTimeToTimeStamp = exports.hrTimeDuration = exports.timeInputToHrTime = exports.hrTime = exports.getTimeOrigin = exports.millisToHrTime = void 0;
const platform_1 = require("../platform");
const NANOSECOND_DIGITS = 9;
const NANOSECOND_DIGITS_IN_MILLIS = 6;
const MILLISECONDS_TO_NANOSECONDS = Math.pow(10, NANOSECOND_DIGITS_IN_MILLIS);
const SECOND_TO_NANOSECONDS = Math.pow(10, NANOSECOND_DIGITS);
/**
* Converts a number to HrTime, HrTime = [number, number].
* The first number is UNIX Epoch time in seconds since 00:00:00 UTC on 1 January 1970.
* The second number represents the partial second elapsed since Unix Epoch time represented by first number in nanoseconds.
* For example, 2021-01-01T12:30:10.150Z in UNIX Epoch time in milliseconds is represented as 1609504210150.
* numberToHrtime calculates the first number by converting and truncating the Epoch time in milliseconds to seconds:
* HrTime[0] = Math.trunc(1609504210150 / 1000) = 1609504210.
* numberToHrtime calculates the second number by converting the digits after the decimal point of the subtraction, (1609504210150 / 1000) - HrTime[0], to nanoseconds:
* HrTime[1] = Number((1609504210.150 - HrTime[0]).toFixed(9)) * SECOND_TO_NANOSECONDS = 150000000.
* This is represented in HrTime format as [1609504210, 150000000].
* Converts a number of milliseconds from epoch to HrTime([seconds, remainder in nanoseconds]).
* @param epochMillis
*/
function numberToHrtime(epochMillis) {
function millisToHrTime(epochMillis) {
const epochSeconds = epochMillis / 1000;

@@ -40,6 +34,6 @@ // Decimals only.

// Round sub-nanosecond accuracy to nanosecond.
const nanos = Number((epochSeconds - seconds).toFixed(NANOSECOND_DIGITS)) *
SECOND_TO_NANOSECONDS;
const nanos = Math.round((epochMillis % 1000) * MILLISECONDS_TO_NANOSECONDS);
return [seconds, nanos];
}
exports.millisToHrTime = millisToHrTime;
function getTimeOrigin() {

@@ -53,2 +47,3 @@ let timeOrigin = platform_1.otperformance.timeOrigin;

}
exports.getTimeOrigin = getTimeOrigin;
/**

@@ -59,12 +54,5 @@ * Returns an hrtime calculated via performance component.

function hrTime(performanceNow) {
const timeOrigin = numberToHrtime(getTimeOrigin());
const now = numberToHrtime(typeof performanceNow === 'number' ? performanceNow : platform_1.otperformance.now());
let seconds = timeOrigin[0] + now[0];
let nanos = timeOrigin[1] + now[1];
// Nanoseconds
if (nanos > SECOND_TO_NANOSECONDS) {
nanos -= SECOND_TO_NANOSECONDS;
seconds += 1;
}
return [seconds, nanos];
const timeOrigin = millisToHrTime(getTimeOrigin());
const now = millisToHrTime(typeof performanceNow === 'number' ? performanceNow : platform_1.otperformance.now());
return addHrTimes(timeOrigin, now);
}

@@ -89,7 +77,7 @@ exports.hrTime = hrTime;

// epoch milliseconds or performance.timeOrigin
return numberToHrtime(time);
return millisToHrTime(time);
}
}
else if (time instanceof Date) {
return numberToHrtime(time.getTime());
return millisToHrTime(time.getTime());
}

@@ -175,2 +163,15 @@ else {

exports.isTimeInput = isTimeInput;
/**
* Given 2 HrTime formatted times, return their sum as an HrTime.
*/
function addHrTimes(time1, time2) {
const out = [time1[0] + time2[0], time1[1] + time2[1]];
// Nanoseconds
if (out[1] >= SECOND_TO_NANOSECONDS) {
out[1] -= SECOND_TO_NANOSECONDS;
out[0] += 1;
}
return out;
}
exports.addHrTimes = addHrTimes;
//# sourceMappingURL=time.js.map

@@ -59,4 +59,4 @@ "use strict";

exports.internal = {
_export: exporter_1._export
_export: exporter_1._export,
};
//# sourceMappingURL=index.js.map

@@ -6,6 +6,6 @@ import { ExportResult } from '../ExportResult';

/**
* @internal
* Shared functionality used by Exporters while exporting data, including suppresion of Traces.
*/
* @internal
* Shared functionality used by Exporters while exporting data, including suppresion of Traces.
*/
export declare function _export<T>(exporter: Exporter<T>, arg: T): Promise<ExportResult>;
//# sourceMappingURL=exporter.d.ts.map

@@ -22,5 +22,5 @@ "use strict";

/**
* @internal
* Shared functionality used by Exporters while exporting data, including suppresion of Traces.
*/
* @internal
* Shared functionality used by Exporters while exporting data, including suppresion of Traces.
*/
function _export(exporter, arg) {

@@ -27,0 +27,0 @@ return new Promise(resolve => {

@@ -29,7 +29,11 @@ "use strict";

// eslint-disable-next-line node/no-unsupported-features/es-builtins, no-undef
exports._globalThis = typeof globalThis === 'object' ? globalThis :
typeof self === 'object' ? self :
typeof window === 'object' ? window :
typeof global === 'object' ? global :
{};
exports._globalThis = typeof globalThis === 'object'
? globalThis
: typeof self === 'object'
? self
: typeof window === 'object'
? window
: typeof global === 'object'
? global
: {};
//# sourceMappingURL=globalThis.js.map

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

try {
Promise.resolve(this._callback.call(this._that, ...args))
.then(val => this._deferred.resolve(val), err => this._deferred.reject(err));
Promise.resolve(this._callback.call(this._that, ...args)).then(val => this._deferred.resolve(val), err => this._deferred.reject(err));
}

@@ -44,0 +43,0 @@ catch (err) {

@@ -5,2 +5,6 @@ import { DiagLogLevel } from '@opentelemetry/api';

*/
declare const ENVIRONMENT_BOOLEAN_KEYS: readonly ["OTEL_SDK_DISABLED"];
declare type ENVIRONMENT_BOOLEANS = {
[K in typeof ENVIRONMENT_BOOLEAN_KEYS[number]]?: boolean;
};
declare const ENVIRONMENT_NUMBERS_KEYS: readonly ["OTEL_BSP_EXPORT_TIMEOUT", "OTEL_BSP_MAX_EXPORT_BATCH_SIZE", "OTEL_BSP_MAX_QUEUE_SIZE", "OTEL_BSP_SCHEDULE_DELAY", "OTEL_ATTRIBUTE_VALUE_LENGTH_LIMIT", "OTEL_ATTRIBUTE_COUNT_LIMIT", "OTEL_SPAN_ATTRIBUTE_VALUE_LENGTH_LIMIT", "OTEL_SPAN_ATTRIBUTE_COUNT_LIMIT", "OTEL_SPAN_EVENT_COUNT_LIMIT", "OTEL_SPAN_LINK_COUNT_LIMIT", "OTEL_EXPORTER_OTLP_TIMEOUT", "OTEL_EXPORTER_OTLP_TRACES_TIMEOUT", "OTEL_EXPORTER_OTLP_METRICS_TIMEOUT", "OTEL_EXPORTER_JAEGER_AGENT_PORT"];

@@ -57,3 +61,3 @@ declare type ENVIRONMENT_NUMBERS = {

OTEL_EXPORTER_OTLP_METRICS_TEMPORALITY_PREFERENCE?: string;
} & ENVIRONMENT_NUMBERS & ENVIRONMENT_LISTS;
} & ENVIRONMENT_BOOLEANS & ENVIRONMENT_NUMBERS & ENVIRONMENT_LISTS;
export declare type RAW_ENVIRONMENT = {

@@ -60,0 +64,0 @@ [key: string]: string | number | undefined | string[];

@@ -26,2 +26,6 @@ "use strict";

*/
const ENVIRONMENT_BOOLEAN_KEYS = ['OTEL_SDK_DISABLED'];
function isEnvVarABoolean(key) {
return (ENVIRONMENT_BOOLEAN_KEYS.indexOf(key) > -1);
}
const ENVIRONMENT_NUMBERS_KEYS = [

@@ -59,2 +63,3 @@ 'OTEL_BSP_EXPORT_TIMEOUT',

exports.DEFAULT_ENVIRONMENT = {
OTEL_SDK_DISABLED: false,
CONTAINER_NAME: '',

@@ -96,3 +101,3 @@ ECS_CONTAINER_METADATA_URI_V4: '',

OTEL_SPAN_LINK_COUNT_LIMIT: 128,
OTEL_TRACES_EXPORTER: 'otlp',
OTEL_TRACES_EXPORTER: '',
OTEL_TRACES_SAMPLER: sampling_1.TracesSamplerValues.ParentBasedAlwaysOn,

@@ -118,5 +123,18 @@ OTEL_TRACES_SAMPLER_ARG: '',

OTEL_EXPORTER_OTLP_METRICS_PROTOCOL: 'http/protobuf',
OTEL_EXPORTER_OTLP_METRICS_TEMPORALITY_PREFERENCE: 'cumulative'
OTEL_EXPORTER_OTLP_METRICS_TEMPORALITY_PREFERENCE: 'cumulative',
};
/**
* @param key
* @param environment
* @param values
*/
function parseBoolean(key, environment, values) {
if (typeof values[key] === 'undefined') {
return;
}
const value = String(values[key]);
// support case-insensitive "true"
environment[key] = value.toLowerCase() === 'true';
}
/**
* Parses a variable as number with number validation

@@ -196,3 +214,6 @@ * @param name

default:
if (isEnvVarANumber(key)) {
if (isEnvVarABoolean(key)) {
parseBoolean(key, environment, values);
}
else if (isEnvVarANumber(key)) {
parseNumber(key, environment, values);

@@ -219,7 +240,7 @@ }

function getEnvWithoutDefaults() {
return typeof process !== 'undefined' ?
parseEnvironment(process.env) :
parseEnvironment(globalThis_1._globalThis);
return typeof process !== 'undefined'
? parseEnvironment(process.env)
: parseEnvironment(globalThis_1._globalThis);
}
exports.getEnvWithoutDefaults = getEnvWithoutDefaults;
//# sourceMappingURL=environment.js.map

@@ -85,4 +85,5 @@ "use strict";

const Ctor = hasOwnProperty.call(proto, 'constructor') && proto.constructor;
return typeof Ctor == 'function' && Ctor instanceof Ctor &&
funcToString.call(Ctor) === objectCtorString;
return (typeof Ctor == 'function' &&
Ctor instanceof Ctor &&
funcToString.call(Ctor) === objectCtorString);
}

@@ -128,3 +129,3 @@ exports.isPlainObject = isPlainObject;

}
return (symToStringTag && symToStringTag in Object(value))
return symToStringTag && symToStringTag in Object(value)
? getRawTag(value)

@@ -131,0 +132,0 @@ : objectToString(value);

@@ -142,6 +142,9 @@ "use strict";

function isObject(value) {
return !isPrimitive(value) && !isArray(value) && !isFunction(value) && typeof value === 'object';
return (!isPrimitive(value) &&
!isArray(value) &&
!isFunction(value) &&
typeof value === 'object');
}
function isPrimitive(value) {
return typeof value === 'string' ||
return (typeof value === 'string' ||
typeof value === 'number' ||

@@ -152,3 +155,3 @@ typeof value === 'boolean' ||

value instanceof RegExp ||
value === null;
value === null);
}

@@ -155,0 +158,0 @@ function shouldMerge(one, two) {

@@ -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/core",
"version": "1.8.0",
"version": "1.9.0",
"description": "OpenTelemetry Core provides constants and utilities shared by all OpenTelemetry SDK packages.",

@@ -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/platform/browser/**/*.ts'",

@@ -31,3 +31,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",

@@ -83,7 +83,7 @@ "@types/node": "18.6.5",

"karma-webpack": "4.0.2",
"lerna": "5.4.3",
"lerna": "6.0.3",
"mocha": "10.0.0",
"nyc": "15.1.0",
"rimraf": "3.0.2",
"sinon": "14.0.0",
"sinon": "15.0.0",
"ts-loader": "8.4.0",

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

"peerDependencies": {
"@opentelemetry/api": ">=1.0.0 <1.4.0"
"@opentelemetry/api": ">=1.0.0 <1.5.0"
},
"dependencies": {
"@opentelemetry/semantic-conventions": "1.8.0"
"@opentelemetry/semantic-conventions": "1.9.0"
},
"homepage": "https://github.com/open-telemetry/opentelemetry-js/tree/main/packages/opentelemetry-core",
"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

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