feat: Complete zCode CLI X with Telegram bot integration

- Add full Telegram bot functionality with Z.AI API integration
- Implement 4 tools: Bash, FileEdit, WebSearch, Git
- Add 3 agents: Code Reviewer, Architect, DevOps Engineer
- Add 6 skills for common coding tasks
- Add systemd service file for 24/7 operation
- Add nginx configuration for HTTPS webhook
- Add comprehensive documentation
- Implement WebSocket server for real-time updates
- Add logging system with Winston
- Add environment validation

🤖 zCode CLI X - Agentic coder with Z.AI + Telegram integration
This commit is contained in:
admin
2026-05-05 09:01:26 +00:00
Unverified
parent 4a7035dd92
commit 875c7f9b91
24688 changed files with 3224957 additions and 221 deletions

View File

@@ -0,0 +1,9 @@
export interface ExportResult {
code: ExportResultCode;
error?: Error;
}
export declare enum ExportResultCode {
SUCCESS = 0,
FAILED = 1
}
//# sourceMappingURL=ExportResult.d.ts.map

View File

@@ -0,0 +1,13 @@
"use strict";
/*
* Copyright The OpenTelemetry Authors
* SPDX-License-Identifier: Apache-2.0
*/
Object.defineProperty(exports, "__esModule", { value: true });
exports.ExportResultCode = void 0;
var ExportResultCode;
(function (ExportResultCode) {
ExportResultCode[ExportResultCode["SUCCESS"] = 0] = "SUCCESS";
ExportResultCode[ExportResultCode["FAILED"] = 1] = "FAILED";
})(ExportResultCode = exports.ExportResultCode || (exports.ExportResultCode = {}));
//# sourceMappingURL=ExportResult.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"ExportResult.js","sourceRoot":"","sources":["../../src/ExportResult.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAOH,IAAY,gBAGX;AAHD,WAAY,gBAAgB;IAC1B,6DAAO,CAAA;IACP,2DAAM,CAAA;AACR,CAAC,EAHW,gBAAgB,GAAhB,wBAAgB,KAAhB,wBAAgB,QAG3B","sourcesContent":["/*\n * Copyright The OpenTelemetry Authors\n * SPDX-License-Identifier: Apache-2.0\n */\n\nexport interface ExportResult {\n code: ExportResultCode;\n error?: Error;\n}\n\nexport enum ExportResultCode {\n SUCCESS,\n FAILED,\n}\n"]}

View File

@@ -0,0 +1,8 @@
export declare const BAGGAGE_KEY_PAIR_SEPARATOR = "=";
export declare const BAGGAGE_PROPERTIES_SEPARATOR = ";";
export declare const BAGGAGE_ITEMS_SEPARATOR = ",";
export declare const BAGGAGE_HEADER = "baggage";
export declare const BAGGAGE_MAX_NAME_VALUE_PAIRS = 180;
export declare const BAGGAGE_MAX_PER_NAME_VALUE_PAIRS = 4096;
export declare const BAGGAGE_MAX_TOTAL_LENGTH = 8192;
//# sourceMappingURL=constants.d.ts.map

View File

@@ -0,0 +1,19 @@
"use strict";
/*
* Copyright The OpenTelemetry Authors
* SPDX-License-Identifier: Apache-2.0
*/
Object.defineProperty(exports, "__esModule", { value: true });
exports.BAGGAGE_MAX_TOTAL_LENGTH = exports.BAGGAGE_MAX_PER_NAME_VALUE_PAIRS = exports.BAGGAGE_MAX_NAME_VALUE_PAIRS = exports.BAGGAGE_HEADER = exports.BAGGAGE_ITEMS_SEPARATOR = exports.BAGGAGE_PROPERTIES_SEPARATOR = exports.BAGGAGE_KEY_PAIR_SEPARATOR = void 0;
exports.BAGGAGE_KEY_PAIR_SEPARATOR = '=';
exports.BAGGAGE_PROPERTIES_SEPARATOR = ';';
exports.BAGGAGE_ITEMS_SEPARATOR = ',';
// Name of the http header used to propagate the baggage
exports.BAGGAGE_HEADER = 'baggage';
// Maximum number of name-value pairs allowed by w3c spec
exports.BAGGAGE_MAX_NAME_VALUE_PAIRS = 180;
// Maximum number of bytes per a single name-value pair allowed by w3c spec
exports.BAGGAGE_MAX_PER_NAME_VALUE_PAIRS = 4096;
// Maximum total length of all name-value pairs allowed by w3c spec
exports.BAGGAGE_MAX_TOTAL_LENGTH = 8192;
//# sourceMappingURL=constants.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../../../src/baggage/constants.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEU,QAAA,0BAA0B,GAAG,GAAG,CAAC;AACjC,QAAA,4BAA4B,GAAG,GAAG,CAAC;AACnC,QAAA,uBAAuB,GAAG,GAAG,CAAC;AAE3C,wDAAwD;AAC3C,QAAA,cAAc,GAAG,SAAS,CAAC;AACxC,yDAAyD;AAC5C,QAAA,4BAA4B,GAAG,GAAG,CAAC;AAChD,2EAA2E;AAC9D,QAAA,gCAAgC,GAAG,IAAI,CAAC;AACrD,mEAAmE;AACtD,QAAA,wBAAwB,GAAG,IAAI,CAAC","sourcesContent":["/*\n * Copyright The OpenTelemetry Authors\n * SPDX-License-Identifier: Apache-2.0\n */\n\nexport const BAGGAGE_KEY_PAIR_SEPARATOR = '=';\nexport const BAGGAGE_PROPERTIES_SEPARATOR = ';';\nexport const BAGGAGE_ITEMS_SEPARATOR = ',';\n\n// Name of the http header used to propagate the baggage\nexport const BAGGAGE_HEADER = 'baggage';\n// Maximum number of name-value pairs allowed by w3c spec\nexport const BAGGAGE_MAX_NAME_VALUE_PAIRS = 180;\n// Maximum number of bytes per a single name-value pair allowed by w3c spec\nexport const BAGGAGE_MAX_PER_NAME_VALUE_PAIRS = 4096;\n// Maximum total length of all name-value pairs allowed by w3c spec\nexport const BAGGAGE_MAX_TOTAL_LENGTH = 8192;\n"]}

View File

@@ -0,0 +1,13 @@
import type { Context, TextMapGetter, TextMapPropagator, TextMapSetter } from '@opentelemetry/api';
/**
* Propagates {@link Baggage} through Context format propagation.
*
* Based on the Baggage specification:
* https://w3c.github.io/baggage/
*/
export declare class W3CBaggagePropagator implements TextMapPropagator {
inject(context: Context, carrier: unknown, setter: TextMapSetter): void;
extract(context: Context, carrier: unknown, getter: TextMapGetter): Context;
fields(): string[];
}
//# sourceMappingURL=W3CBaggagePropagator.d.ts.map

View File

@@ -0,0 +1,65 @@
"use strict";
/*
* Copyright The OpenTelemetry Authors
* SPDX-License-Identifier: Apache-2.0
*/
Object.defineProperty(exports, "__esModule", { value: true });
exports.W3CBaggagePropagator = void 0;
const api_1 = require("@opentelemetry/api");
const suppress_tracing_1 = require("../../trace/suppress-tracing");
const constants_1 = require("../constants");
const utils_1 = require("../utils");
/**
* Propagates {@link Baggage} through Context format propagation.
*
* Based on the Baggage specification:
* https://w3c.github.io/baggage/
*/
class W3CBaggagePropagator {
inject(context, carrier, setter) {
const baggage = api_1.propagation.getBaggage(context);
if (!baggage || (0, suppress_tracing_1.isTracingSuppressed)(context))
return;
const keyPairs = (0, utils_1.getKeyPairs)(baggage)
.filter((pair) => {
return pair.length <= constants_1.BAGGAGE_MAX_PER_NAME_VALUE_PAIRS;
})
.slice(0, constants_1.BAGGAGE_MAX_NAME_VALUE_PAIRS);
const headerValue = (0, utils_1.serializeKeyPairs)(keyPairs);
if (headerValue.length > 0) {
setter.set(carrier, constants_1.BAGGAGE_HEADER, headerValue);
}
}
extract(context, carrier, getter) {
const headerValue = getter.get(carrier, constants_1.BAGGAGE_HEADER);
const baggageString = Array.isArray(headerValue)
? headerValue.join(constants_1.BAGGAGE_ITEMS_SEPARATOR)
: headerValue;
if (!baggageString)
return context;
const baggage = {};
if (baggageString.length === 0) {
return context;
}
const pairs = baggageString.split(constants_1.BAGGAGE_ITEMS_SEPARATOR);
pairs.forEach(entry => {
const keyPair = (0, utils_1.parsePairKeyValue)(entry);
if (keyPair) {
const baggageEntry = { value: keyPair.value };
if (keyPair.metadata) {
baggageEntry.metadata = keyPair.metadata;
}
baggage[keyPair.key] = baggageEntry;
}
});
if (Object.entries(baggage).length === 0) {
return context;
}
return api_1.propagation.setBaggage(context, api_1.propagation.createBaggage(baggage));
}
fields() {
return [constants_1.BAGGAGE_HEADER];
}
}
exports.W3CBaggagePropagator = W3CBaggagePropagator;
//# sourceMappingURL=W3CBaggagePropagator.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"W3CBaggagePropagator.js","sourceRoot":"","sources":["../../../../src/baggage/propagation/W3CBaggagePropagator.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AASH,4CAAiD;AAEjD,mEAAmE;AACnE,4CAKsB;AACtB,oCAA6E;AAE7E;;;;;GAKG;AACH,MAAa,oBAAoB;IAC/B,MAAM,CAAC,OAAgB,EAAE,OAAgB,EAAE,MAAqB;QAC9D,MAAM,OAAO,GAAG,iBAAW,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC;QAChD,IAAI,CAAC,OAAO,IAAI,IAAA,sCAAmB,EAAC,OAAO,CAAC;YAAE,OAAO;QACrD,MAAM,QAAQ,GAAG,IAAA,mBAAW,EAAC,OAAO,CAAC;aAClC,MAAM,CAAC,CAAC,IAAY,EAAE,EAAE;YACvB,OAAO,IAAI,CAAC,MAAM,IAAI,4CAAgC,CAAC;QACzD,CAAC,CAAC;aACD,KAAK,CAAC,CAAC,EAAE,wCAA4B,CAAC,CAAC;QAC1C,MAAM,WAAW,GAAG,IAAA,yBAAiB,EAAC,QAAQ,CAAC,CAAC;QAChD,IAAI,WAAW,CAAC,MAAM,GAAG,CAAC,EAAE;YAC1B,MAAM,CAAC,GAAG,CAAC,OAAO,EAAE,0BAAc,EAAE,WAAW,CAAC,CAAC;SAClD;IACH,CAAC;IAED,OAAO,CAAC,OAAgB,EAAE,OAAgB,EAAE,MAAqB;QAC/D,MAAM,WAAW,GAAG,MAAM,CAAC,GAAG,CAAC,OAAO,EAAE,0BAAc,CAAC,CAAC;QACxD,MAAM,aAAa,GAAG,KAAK,CAAC,OAAO,CAAC,WAAW,CAAC;YAC9C,CAAC,CAAC,WAAW,CAAC,IAAI,CAAC,mCAAuB,CAAC;YAC3C,CAAC,CAAC,WAAW,CAAC;QAChB,IAAI,CAAC,aAAa;YAAE,OAAO,OAAO,CAAC;QACnC,MAAM,OAAO,GAAiC,EAAE,CAAC;QACjD,IAAI,aAAa,CAAC,MAAM,KAAK,CAAC,EAAE;YAC9B,OAAO,OAAO,CAAC;SAChB;QACD,MAAM,KAAK,GAAG,aAAa,CAAC,KAAK,CAAC,mCAAuB,CAAC,CAAC;QAC3D,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE;YACpB,MAAM,OAAO,GAAG,IAAA,yBAAiB,EAAC,KAAK,CAAC,CAAC;YACzC,IAAI,OAAO,EAAE;gBACX,MAAM,YAAY,GAAiB,EAAE,KAAK,EAAE,OAAO,CAAC,KAAK,EAAE,CAAC;gBAC5D,IAAI,OAAO,CAAC,QAAQ,EAAE;oBACpB,YAAY,CAAC,QAAQ,GAAG,OAAO,CAAC,QAAQ,CAAC;iBAC1C;gBACD,OAAO,CAAC,OAAO,CAAC,GAAG,CAAC,GAAG,YAAY,CAAC;aACrC;QACH,CAAC,CAAC,CAAC;QACH,IAAI,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,MAAM,KAAK,CAAC,EAAE;YACxC,OAAO,OAAO,CAAC;SAChB;QACD,OAAO,iBAAW,CAAC,UAAU,CAAC,OAAO,EAAE,iBAAW,CAAC,aAAa,CAAC,OAAO,CAAC,CAAC,CAAC;IAC7E,CAAC;IAED,MAAM;QACJ,OAAO,CAAC,0BAAc,CAAC,CAAC;IAC1B,CAAC;CACF;AA7CD,oDA6CC","sourcesContent":["/*\n * Copyright The OpenTelemetry Authors\n * SPDX-License-Identifier: Apache-2.0\n */\n\nimport type {\n BaggageEntry,\n Context,\n TextMapGetter,\n TextMapPropagator,\n TextMapSetter,\n} from '@opentelemetry/api';\nimport { propagation } from '@opentelemetry/api';\n\nimport { isTracingSuppressed } from '../../trace/suppress-tracing';\nimport {\n BAGGAGE_HEADER,\n BAGGAGE_ITEMS_SEPARATOR,\n BAGGAGE_MAX_NAME_VALUE_PAIRS,\n BAGGAGE_MAX_PER_NAME_VALUE_PAIRS,\n} from '../constants';\nimport { getKeyPairs, parsePairKeyValue, serializeKeyPairs } from '../utils';\n\n/**\n * Propagates {@link Baggage} through Context format propagation.\n *\n * Based on the Baggage specification:\n * https://w3c.github.io/baggage/\n */\nexport class W3CBaggagePropagator implements TextMapPropagator {\n inject(context: Context, carrier: unknown, setter: TextMapSetter): void {\n const baggage = propagation.getBaggage(context);\n if (!baggage || isTracingSuppressed(context)) return;\n const keyPairs = getKeyPairs(baggage)\n .filter((pair: string) => {\n return pair.length <= BAGGAGE_MAX_PER_NAME_VALUE_PAIRS;\n })\n .slice(0, BAGGAGE_MAX_NAME_VALUE_PAIRS);\n const headerValue = serializeKeyPairs(keyPairs);\n if (headerValue.length > 0) {\n setter.set(carrier, BAGGAGE_HEADER, headerValue);\n }\n }\n\n extract(context: Context, carrier: unknown, getter: TextMapGetter): Context {\n const headerValue = getter.get(carrier, BAGGAGE_HEADER);\n const baggageString = Array.isArray(headerValue)\n ? headerValue.join(BAGGAGE_ITEMS_SEPARATOR)\n : headerValue;\n if (!baggageString) return context;\n const baggage: Record<string, BaggageEntry> = {};\n if (baggageString.length === 0) {\n return context;\n }\n const pairs = baggageString.split(BAGGAGE_ITEMS_SEPARATOR);\n pairs.forEach(entry => {\n const keyPair = parsePairKeyValue(entry);\n if (keyPair) {\n const baggageEntry: BaggageEntry = { value: keyPair.value };\n if (keyPair.metadata) {\n baggageEntry.metadata = keyPair.metadata;\n }\n baggage[keyPair.key] = baggageEntry;\n }\n });\n if (Object.entries(baggage).length === 0) {\n return context;\n }\n return propagation.setBaggage(context, propagation.createBaggage(baggage));\n }\n\n fields(): string[] {\n return [BAGGAGE_HEADER];\n }\n}\n"]}

View File

@@ -0,0 +1,16 @@
import type { Baggage, BaggageEntryMetadata } from '@opentelemetry/api';
type ParsedBaggageKeyValue = {
key: string;
value: string;
metadata: BaggageEntryMetadata | undefined;
};
export declare function serializeKeyPairs(keyPairs: string[]): string;
export declare function getKeyPairs(baggage: Baggage): string[];
export declare function parsePairKeyValue(entry: string): ParsedBaggageKeyValue | undefined;
/**
* Parse a string serialized in the baggage HTTP Format (without metadata):
* https://github.com/w3c/baggage/blob/master/baggage/HTTP_HEADER_FORMAT.md
*/
export declare function parseKeyPairsIntoRecord(value?: string): Record<string, string>;
export {};
//# sourceMappingURL=utils.d.ts.map

View File

@@ -0,0 +1,74 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.parseKeyPairsIntoRecord = exports.parsePairKeyValue = exports.getKeyPairs = exports.serializeKeyPairs = void 0;
const api_1 = require("@opentelemetry/api");
const constants_1 = require("./constants");
function serializeKeyPairs(keyPairs) {
return keyPairs.reduce((hValue, current) => {
const value = `${hValue}${hValue !== '' ? constants_1.BAGGAGE_ITEMS_SEPARATOR : ''}${current}`;
return value.length > constants_1.BAGGAGE_MAX_TOTAL_LENGTH ? hValue : value;
}, '');
}
exports.serializeKeyPairs = serializeKeyPairs;
function getKeyPairs(baggage) {
return baggage.getAllEntries().map(([key, value]) => {
let entry = `${encodeURIComponent(key)}=${encodeURIComponent(value.value)}`;
// include opaque metadata if provided
// NOTE: we intentionally don't URI-encode the metadata - that responsibility falls on the metadata implementation
if (value.metadata !== undefined) {
entry += constants_1.BAGGAGE_PROPERTIES_SEPARATOR + value.metadata.toString();
}
return entry;
});
}
exports.getKeyPairs = getKeyPairs;
function parsePairKeyValue(entry) {
if (!entry)
return;
const metadataSeparatorIndex = entry.indexOf(constants_1.BAGGAGE_PROPERTIES_SEPARATOR);
const keyPairPart = metadataSeparatorIndex === -1
? entry
: entry.substring(0, metadataSeparatorIndex);
const separatorIndex = keyPairPart.indexOf(constants_1.BAGGAGE_KEY_PAIR_SEPARATOR);
if (separatorIndex <= 0)
return;
const rawKey = keyPairPart.substring(0, separatorIndex).trim();
const rawValue = keyPairPart.substring(separatorIndex + 1).trim();
if (!rawKey || !rawValue)
return;
let key;
let value;
try {
key = decodeURIComponent(rawKey);
value = decodeURIComponent(rawValue);
}
catch {
return;
}
let metadata;
if (metadataSeparatorIndex !== -1 &&
metadataSeparatorIndex < entry.length - 1) {
const metadataString = entry.substring(metadataSeparatorIndex + 1);
metadata = (0, api_1.baggageEntryMetadataFromString)(metadataString);
}
return { key, value, metadata };
}
exports.parsePairKeyValue = parsePairKeyValue;
/**
* Parse a string serialized in the baggage HTTP Format (without metadata):
* https://github.com/w3c/baggage/blob/master/baggage/HTTP_HEADER_FORMAT.md
*/
function parseKeyPairsIntoRecord(value) {
const result = {};
if (typeof value === 'string' && value.length > 0) {
value.split(constants_1.BAGGAGE_ITEMS_SEPARATOR).forEach(entry => {
const keyPair = parsePairKeyValue(entry);
if (keyPair !== undefined && keyPair.value.length > 0) {
result[keyPair.key] = keyPair.value;
}
});
}
return result;
}
exports.parseKeyPairsIntoRecord = parseKeyPairsIntoRecord;
//# sourceMappingURL=utils.js.map

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,41 @@
export interface Clock {
/**
* Return the current time in milliseconds from some epoch such as the Unix epoch or process start
*/
now(): number;
}
/**
* A utility for returning wall times anchored to a given point in time. Wall time measurements will
* not be taken from the system, but instead are computed by adding a monotonic clock time
* to the anchor point.
*
* This is needed because the system time can change and result in unexpected situations like
* spans ending before they are started. Creating an anchored clock for each local root span
* ensures that span timings and durations are accurate while preventing span times from drifting
* too far from the system clock.
*
* Only creating an anchored clock once per local trace ensures span times are correct relative
* to each other. For example, a child span will never have a start time before its parent even
* if the system clock is corrected during the local trace.
*
* Heavily inspired by the OTel Java anchored clock
* https://github.com/open-telemetry/opentelemetry-java/blob/main/sdk/trace/src/main/java/io/opentelemetry/sdk/trace/AnchoredClock.java
*/
export declare class AnchoredClock implements Clock {
private _monotonicClock;
private _epochMillis;
private _performanceMillis;
/**
* Create a new AnchoredClock anchored to the current time returned by systemClock.
*
* @param systemClock should be a clock that returns the number of milliseconds since January 1 1970 such as Date
* @param monotonicClock should be a clock that counts milliseconds monotonically such as window.performance or perf_hooks.performance
*/
constructor(systemClock: Clock, monotonicClock: Clock);
/**
* Returns the current time by adding the number of milliseconds since the
* AnchoredClock was created to the creation epoch time
*/
now(): number;
}
//# sourceMappingURL=anchored-clock.d.ts.map

View File

@@ -0,0 +1,50 @@
"use strict";
/*
* Copyright The OpenTelemetry Authors
* SPDX-License-Identifier: Apache-2.0
*/
Object.defineProperty(exports, "__esModule", { value: true });
exports.AnchoredClock = void 0;
/**
* A utility for returning wall times anchored to a given point in time. Wall time measurements will
* not be taken from the system, but instead are computed by adding a monotonic clock time
* to the anchor point.
*
* This is needed because the system time can change and result in unexpected situations like
* spans ending before they are started. Creating an anchored clock for each local root span
* ensures that span timings and durations are accurate while preventing span times from drifting
* too far from the system clock.
*
* Only creating an anchored clock once per local trace ensures span times are correct relative
* to each other. For example, a child span will never have a start time before its parent even
* if the system clock is corrected during the local trace.
*
* Heavily inspired by the OTel Java anchored clock
* https://github.com/open-telemetry/opentelemetry-java/blob/main/sdk/trace/src/main/java/io/opentelemetry/sdk/trace/AnchoredClock.java
*/
class AnchoredClock {
_monotonicClock;
_epochMillis;
_performanceMillis;
/**
* Create a new AnchoredClock anchored to the current time returned by systemClock.
*
* @param systemClock should be a clock that returns the number of milliseconds since January 1 1970 such as Date
* @param monotonicClock should be a clock that counts milliseconds monotonically such as window.performance or perf_hooks.performance
*/
constructor(systemClock, monotonicClock) {
this._monotonicClock = monotonicClock;
this._epochMillis = systemClock.now();
this._performanceMillis = monotonicClock.now();
}
/**
* Returns the current time by adding the number of milliseconds since the
* AnchoredClock was created to the creation epoch time
*/
now() {
const delta = this._monotonicClock.now() - this._performanceMillis;
return this._epochMillis + delta;
}
}
exports.AnchoredClock = AnchoredClock;
//# sourceMappingURL=anchored-clock.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"anchored-clock.js","sourceRoot":"","sources":["../../../src/common/anchored-clock.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AASH;;;;;;;;;;;;;;;;GAgBG;AACH,MAAa,aAAa;IAChB,eAAe,CAAQ;IACvB,YAAY,CAAS;IACrB,kBAAkB,CAAS;IAEnC;;;;;OAKG;IACH,YAAmB,WAAkB,EAAE,cAAqB;QAC1D,IAAI,CAAC,eAAe,GAAG,cAAc,CAAC;QACtC,IAAI,CAAC,YAAY,GAAG,WAAW,CAAC,GAAG,EAAE,CAAC;QACtC,IAAI,CAAC,kBAAkB,GAAG,cAAc,CAAC,GAAG,EAAE,CAAC;IACjD,CAAC;IAED;;;OAGG;IACI,GAAG;QACR,MAAM,KAAK,GAAG,IAAI,CAAC,eAAe,CAAC,GAAG,EAAE,GAAG,IAAI,CAAC,kBAAkB,CAAC;QACnE,OAAO,IAAI,CAAC,YAAY,GAAG,KAAK,CAAC;IACnC,CAAC;CACF;AAzBD,sCAyBC","sourcesContent":["/*\n * Copyright The OpenTelemetry Authors\n * SPDX-License-Identifier: Apache-2.0\n */\n\nexport interface Clock {\n /**\n * Return the current time in milliseconds from some epoch such as the Unix epoch or process start\n */\n now(): number;\n}\n\n/**\n * A utility for returning wall times anchored to a given point in time. Wall time measurements will\n * not be taken from the system, but instead are computed by adding a monotonic clock time\n * to the anchor point.\n *\n * This is needed because the system time can change and result in unexpected situations like\n * spans ending before they are started. Creating an anchored clock for each local root span\n * ensures that span timings and durations are accurate while preventing span times from drifting\n * too far from the system clock.\n *\n * Only creating an anchored clock once per local trace ensures span times are correct relative\n * to each other. For example, a child span will never have a start time before its parent even\n * if the system clock is corrected during the local trace.\n *\n * Heavily inspired by the OTel Java anchored clock\n * https://github.com/open-telemetry/opentelemetry-java/blob/main/sdk/trace/src/main/java/io/opentelemetry/sdk/trace/AnchoredClock.java\n */\nexport class AnchoredClock implements Clock {\n private _monotonicClock: Clock;\n private _epochMillis: number;\n private _performanceMillis: number;\n\n /**\n * Create a new AnchoredClock anchored to the current time returned by systemClock.\n *\n * @param systemClock should be a clock that returns the number of milliseconds since January 1 1970 such as Date\n * @param monotonicClock should be a clock that counts milliseconds monotonically such as window.performance or perf_hooks.performance\n */\n public constructor(systemClock: Clock, monotonicClock: Clock) {\n this._monotonicClock = monotonicClock;\n this._epochMillis = systemClock.now();\n this._performanceMillis = monotonicClock.now();\n }\n\n /**\n * Returns the current time by adding the number of milliseconds since the\n * AnchoredClock was created to the creation epoch time\n */\n public now(): number {\n const delta = this._monotonicClock.now() - this._performanceMillis;\n return this._epochMillis + delta;\n }\n}\n"]}

View File

@@ -0,0 +1,5 @@
import type { AttributeValue, Attributes } from '@opentelemetry/api';
export declare function sanitizeAttributes(attributes: unknown): Attributes;
export declare function isAttributeKey(key: unknown): key is string;
export declare function isAttributeValue(val: unknown): val is AttributeValue;
//# sourceMappingURL=attributes.d.ts.map

View File

@@ -0,0 +1,82 @@
"use strict";
/*
* Copyright The OpenTelemetry Authors
* SPDX-License-Identifier: Apache-2.0
*/
Object.defineProperty(exports, "__esModule", { value: true });
exports.isAttributeValue = exports.isAttributeKey = exports.sanitizeAttributes = void 0;
const api_1 = require("@opentelemetry/api");
function sanitizeAttributes(attributes) {
const out = {};
if (typeof attributes !== 'object' || attributes == null) {
return out;
}
for (const key in attributes) {
if (!Object.prototype.hasOwnProperty.call(attributes, key)) {
continue;
}
if (!isAttributeKey(key)) {
api_1.diag.warn(`Invalid attribute key: ${key}`);
continue;
}
const val = attributes[key];
if (!isAttributeValue(val)) {
api_1.diag.warn(`Invalid attribute value set for key: ${key}`);
continue;
}
if (Array.isArray(val)) {
out[key] = val.slice();
}
else {
out[key] = val;
}
}
return out;
}
exports.sanitizeAttributes = sanitizeAttributes;
function isAttributeKey(key) {
return typeof key === 'string' && key !== '';
}
exports.isAttributeKey = isAttributeKey;
function isAttributeValue(val) {
if (val == null) {
return true;
}
if (Array.isArray(val)) {
return isHomogeneousAttributeValueArray(val);
}
return isValidPrimitiveAttributeValueType(typeof val);
}
exports.isAttributeValue = isAttributeValue;
function isHomogeneousAttributeValueArray(arr) {
let type;
for (const element of arr) {
// null/undefined elements are allowed
if (element == null)
continue;
const elementType = typeof element;
if (elementType === type) {
continue;
}
if (!type) {
if (isValidPrimitiveAttributeValueType(elementType)) {
type = elementType;
continue;
}
// encountered an invalid primitive
return false;
}
return false;
}
return true;
}
function isValidPrimitiveAttributeValueType(valType) {
switch (valType) {
case 'number':
case 'boolean':
case 'string':
return true;
}
return false;
}
//# sourceMappingURL=attributes.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"attributes.js","sourceRoot":"","sources":["../../../src/common/attributes.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAGH,4CAA0C;AAE1C,SAAgB,kBAAkB,CAAC,UAAmB;IACpD,MAAM,GAAG,GAAe,EAAE,CAAC;IAE3B,IAAI,OAAO,UAAU,KAAK,QAAQ,IAAI,UAAU,IAAI,IAAI,EAAE;QACxD,OAAO,GAAG,CAAC;KACZ;IAED,KAAK,MAAM,GAAG,IAAI,UAAU,EAAE;QAC5B,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,cAAc,CAAC,IAAI,CAAC,UAAU,EAAE,GAAG,CAAC,EAAE;YAC1D,SAAS;SACV;QACD,IAAI,CAAC,cAAc,CAAC,GAAG,CAAC,EAAE;YACxB,UAAI,CAAC,IAAI,CAAC,0BAA0B,GAAG,EAAE,CAAC,CAAC;YAC3C,SAAS;SACV;QACD,MAAM,GAAG,GAAI,UAAsC,CAAC,GAAG,CAAC,CAAC;QACzD,IAAI,CAAC,gBAAgB,CAAC,GAAG,CAAC,EAAE;YAC1B,UAAI,CAAC,IAAI,CAAC,wCAAwC,GAAG,EAAE,CAAC,CAAC;YACzD,SAAS;SACV;QACD,IAAI,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,EAAE;YACtB,GAAG,CAAC,GAAG,CAAC,GAAG,GAAG,CAAC,KAAK,EAAE,CAAC;SACxB;aAAM;YACL,GAAG,CAAC,GAAG,CAAC,GAAG,GAAG,CAAC;SAChB;KACF;IAED,OAAO,GAAG,CAAC;AACb,CAAC;AA5BD,gDA4BC;AAED,SAAgB,cAAc,CAAC,GAAY;IACzC,OAAO,OAAO,GAAG,KAAK,QAAQ,IAAI,GAAG,KAAK,EAAE,CAAC;AAC/C,CAAC;AAFD,wCAEC;AAED,SAAgB,gBAAgB,CAAC,GAAY;IAC3C,IAAI,GAAG,IAAI,IAAI,EAAE;QACf,OAAO,IAAI,CAAC;KACb;IAED,IAAI,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,EAAE;QACtB,OAAO,gCAAgC,CAAC,GAAG,CAAC,CAAC;KAC9C;IAED,OAAO,kCAAkC,CAAC,OAAO,GAAG,CAAC,CAAC;AACxD,CAAC;AAVD,4CAUC;AAED,SAAS,gCAAgC,CAAC,GAAc;IACtD,IAAI,IAAwB,CAAC;IAE7B,KAAK,MAAM,OAAO,IAAI,GAAG,EAAE;QACzB,sCAAsC;QACtC,IAAI,OAAO,IAAI,IAAI;YAAE,SAAS;QAC9B,MAAM,WAAW,GAAG,OAAO,OAAO,CAAC;QAEnC,IAAI,WAAW,KAAK,IAAI,EAAE;YACxB,SAAS;SACV;QAED,IAAI,CAAC,IAAI,EAAE;YACT,IAAI,kCAAkC,CAAC,WAAW,CAAC,EAAE;gBACnD,IAAI,GAAG,WAAW,CAAC;gBACnB,SAAS;aACV;YACD,mCAAmC;YACnC,OAAO,KAAK,CAAC;SACd;QAED,OAAO,KAAK,CAAC;KACd;IAED,OAAO,IAAI,CAAC;AACd,CAAC;AAED,SAAS,kCAAkC,CAAC,OAAe;IACzD,QAAQ,OAAO,EAAE;QACf,KAAK,QAAQ,CAAC;QACd,KAAK,SAAS,CAAC;QACf,KAAK,QAAQ;YACX,OAAO,IAAI,CAAC;KACf;IAED,OAAO,KAAK,CAAC;AACf,CAAC","sourcesContent":["/*\n * Copyright The OpenTelemetry Authors\n * SPDX-License-Identifier: Apache-2.0\n */\n\nimport type { AttributeValue, Attributes } from '@opentelemetry/api';\nimport { diag } from '@opentelemetry/api';\n\nexport function sanitizeAttributes(attributes: unknown): Attributes {\n const out: Attributes = {};\n\n if (typeof attributes !== 'object' || attributes == null) {\n return out;\n }\n\n for (const key in attributes) {\n if (!Object.prototype.hasOwnProperty.call(attributes, key)) {\n continue;\n }\n if (!isAttributeKey(key)) {\n diag.warn(`Invalid attribute key: ${key}`);\n continue;\n }\n const val = (attributes as Record<string, unknown>)[key];\n if (!isAttributeValue(val)) {\n diag.warn(`Invalid attribute value set for key: ${key}`);\n continue;\n }\n if (Array.isArray(val)) {\n out[key] = val.slice();\n } else {\n out[key] = val;\n }\n }\n\n return out;\n}\n\nexport function isAttributeKey(key: unknown): key is string {\n return typeof key === 'string' && key !== '';\n}\n\nexport function isAttributeValue(val: unknown): val is AttributeValue {\n if (val == null) {\n return true;\n }\n\n if (Array.isArray(val)) {\n return isHomogeneousAttributeValueArray(val);\n }\n\n return isValidPrimitiveAttributeValueType(typeof val);\n}\n\nfunction isHomogeneousAttributeValueArray(arr: unknown[]): boolean {\n let type: string | undefined;\n\n for (const element of arr) {\n // null/undefined elements are allowed\n if (element == null) continue;\n const elementType = typeof element;\n\n if (elementType === type) {\n continue;\n }\n\n if (!type) {\n if (isValidPrimitiveAttributeValueType(elementType)) {\n type = elementType;\n continue;\n }\n // encountered an invalid primitive\n return false;\n }\n\n return false;\n }\n\n return true;\n}\n\nfunction isValidPrimitiveAttributeValueType(valType: string): boolean {\n switch (valType) {\n case 'number':\n case 'boolean':\n case 'string':\n return true;\n }\n\n return false;\n}\n"]}

View File

@@ -0,0 +1,13 @@
import type { Exception } from '@opentelemetry/api';
import type { ErrorHandler } from './types';
/**
* Set the global error handler
* @param {ErrorHandler} handler
*/
export declare function setGlobalErrorHandler(handler: ErrorHandler): void;
/**
* Return the global error handler
* @param {Exception} ex
*/
export declare function globalErrorHandler(ex: Exception): void;
//# sourceMappingURL=global-error-handler.d.ts.map

View File

@@ -0,0 +1,30 @@
"use strict";
/*
* Copyright The OpenTelemetry Authors
* SPDX-License-Identifier: Apache-2.0
*/
Object.defineProperty(exports, "__esModule", { value: true });
exports.globalErrorHandler = exports.setGlobalErrorHandler = void 0;
const logging_error_handler_1 = require("./logging-error-handler");
/** The global error handler delegate */
let delegateHandler = (0, logging_error_handler_1.loggingErrorHandler)();
/**
* Set the global error handler
* @param {ErrorHandler} handler
*/
function setGlobalErrorHandler(handler) {
delegateHandler = handler;
}
exports.setGlobalErrorHandler = setGlobalErrorHandler;
/**
* Return the global error handler
* @param {Exception} ex
*/
function globalErrorHandler(ex) {
try {
delegateHandler(ex);
}
catch { } // eslint-disable-line no-empty
}
exports.globalErrorHandler = globalErrorHandler;
//# sourceMappingURL=global-error-handler.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"global-error-handler.js","sourceRoot":"","sources":["../../../src/common/global-error-handler.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAGH,mEAA8D;AAG9D,wCAAwC;AACxC,IAAI,eAAe,GAAG,IAAA,2CAAmB,GAAE,CAAC;AAE5C;;;GAGG;AACH,SAAgB,qBAAqB,CAAC,OAAqB;IACzD,eAAe,GAAG,OAAO,CAAC;AAC5B,CAAC;AAFD,sDAEC;AAED;;;GAGG;AACH,SAAgB,kBAAkB,CAAC,EAAa;IAC9C,IAAI;QACF,eAAe,CAAC,EAAE,CAAC,CAAC;KACrB;IAAC,MAAM,GAAE,CAAC,+BAA+B;AAC5C,CAAC;AAJD,gDAIC","sourcesContent":["/*\n * Copyright The OpenTelemetry Authors\n * SPDX-License-Identifier: Apache-2.0\n */\n\nimport type { Exception } from '@opentelemetry/api';\nimport { loggingErrorHandler } from './logging-error-handler';\nimport type { ErrorHandler } from './types';\n\n/** The global error handler delegate */\nlet delegateHandler = loggingErrorHandler();\n\n/**\n * Set the global error handler\n * @param {ErrorHandler} handler\n */\nexport function setGlobalErrorHandler(handler: ErrorHandler): void {\n delegateHandler = handler;\n}\n\n/**\n * Return the global error handler\n * @param {Exception} ex\n */\nexport function globalErrorHandler(ex: Exception): void {\n try {\n delegateHandler(ex);\n } catch {} // eslint-disable-line no-empty\n}\n"]}

View File

@@ -0,0 +1,5 @@
/**
* @deprecated Use globalThis directly instead.
*/
export declare const _globalThis: typeof globalThis;
//# sourceMappingURL=globalThis.d.ts.map

View File

@@ -0,0 +1,12 @@
"use strict";
/*
* Copyright The OpenTelemetry Authors
* SPDX-License-Identifier: Apache-2.0
*/
Object.defineProperty(exports, "__esModule", { value: true });
exports._globalThis = void 0;
/**
* @deprecated Use globalThis directly instead.
*/
exports._globalThis = globalThis;
//# sourceMappingURL=globalThis.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"globalThis.js","sourceRoot":"","sources":["../../../src/common/globalThis.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH;;GAEG;AACU,QAAA,WAAW,GAAG,UAAU,CAAC","sourcesContent":["/*\n * Copyright The OpenTelemetry Authors\n * SPDX-License-Identifier: Apache-2.0\n */\n\n/**\n * @deprecated Use globalThis directly instead.\n */\nexport const _globalThis = globalThis;\n"]}

View File

@@ -0,0 +1,7 @@
import type { ErrorHandler } from './types';
/**
* Returns a function that logs an error using the provided logger, or a
* console logger if one was not provided.
*/
export declare function loggingErrorHandler(): ErrorHandler;
//# sourceMappingURL=logging-error-handler.d.ts.map

View File

@@ -0,0 +1,52 @@
"use strict";
/*
* Copyright The OpenTelemetry Authors
* SPDX-License-Identifier: Apache-2.0
*/
Object.defineProperty(exports, "__esModule", { value: true });
exports.loggingErrorHandler = void 0;
const api_1 = require("@opentelemetry/api");
/**
* Returns a function that logs an error using the provided logger, or a
* console logger if one was not provided.
*/
function loggingErrorHandler() {
return (ex) => {
api_1.diag.error(stringifyException(ex));
};
}
exports.loggingErrorHandler = loggingErrorHandler;
/**
* Converts an exception into a string representation
* @param {Exception} ex
*/
function stringifyException(ex) {
if (typeof ex === 'string') {
return ex;
}
else {
return JSON.stringify(flattenException(ex));
}
}
/**
* Flattens an exception into key-value pairs by traversing the prototype chain
* and coercing values to strings. Duplicate properties will not be overwritten;
* the first insert wins.
*/
function flattenException(ex) {
const result = {};
let current = ex;
while (current !== null) {
Object.getOwnPropertyNames(current).forEach(propertyName => {
if (result[propertyName])
return;
const value = current[propertyName];
if (value) {
result[propertyName] = String(value);
}
});
current = Object.getPrototypeOf(current);
}
return result;
}
//# sourceMappingURL=logging-error-handler.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"logging-error-handler.js","sourceRoot":"","sources":["../../../src/common/logging-error-handler.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAGH,4CAA0C;AAG1C;;;GAGG;AACH,SAAgB,mBAAmB;IACjC,OAAO,CAAC,EAAa,EAAE,EAAE;QACvB,UAAI,CAAC,KAAK,CAAC,kBAAkB,CAAC,EAAE,CAAC,CAAC,CAAC;IACrC,CAAC,CAAC;AACJ,CAAC;AAJD,kDAIC;AAED;;;GAGG;AACH,SAAS,kBAAkB,CAAC,EAAsB;IAChD,IAAI,OAAO,EAAE,KAAK,QAAQ,EAAE;QAC1B,OAAO,EAAE,CAAC;KACX;SAAM;QACL,OAAO,IAAI,CAAC,SAAS,CAAC,gBAAgB,CAAC,EAAE,CAAC,CAAC,CAAC;KAC7C;AACH,CAAC;AAED;;;;GAIG;AACH,SAAS,gBAAgB,CAAC,EAAa;IACrC,MAAM,MAAM,GAAG,EAA4B,CAAC;IAC5C,IAAI,OAAO,GAAG,EAAE,CAAC;IAEjB,OAAO,OAAO,KAAK,IAAI,EAAE;QACvB,MAAM,CAAC,mBAAmB,CAAC,OAAO,CAAC,CAAC,OAAO,CAAC,YAAY,CAAC,EAAE;YACzD,IAAI,MAAM,CAAC,YAAY,CAAC;gBAAE,OAAO;YACjC,MAAM,KAAK,GAAG,OAAO,CAAC,YAAoC,CAAC,CAAC;YAC5D,IAAI,KAAK,EAAE;gBACT,MAAM,CAAC,YAAY,CAAC,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC;aACtC;QACH,CAAC,CAAC,CAAC;QACH,OAAO,GAAG,MAAM,CAAC,cAAc,CAAC,OAAO,CAAC,CAAC;KAC1C;IAED,OAAO,MAAM,CAAC;AAChB,CAAC","sourcesContent":["/*\n * Copyright The OpenTelemetry Authors\n * SPDX-License-Identifier: Apache-2.0\n */\n\nimport type { Exception } from '@opentelemetry/api';\nimport { diag } from '@opentelemetry/api';\nimport type { ErrorHandler } from './types';\n\n/**\n * Returns a function that logs an error using the provided logger, or a\n * console logger if one was not provided.\n */\nexport function loggingErrorHandler(): ErrorHandler {\n return (ex: Exception) => {\n diag.error(stringifyException(ex));\n };\n}\n\n/**\n * Converts an exception into a string representation\n * @param {Exception} ex\n */\nfunction stringifyException(ex: Exception | string): string {\n if (typeof ex === 'string') {\n return ex;\n } else {\n return JSON.stringify(flattenException(ex));\n }\n}\n\n/**\n * Flattens an exception into key-value pairs by traversing the prototype chain\n * and coercing values to strings. Duplicate properties will not be overwritten;\n * the first insert wins.\n */\nfunction flattenException(ex: Exception): Record<string, string> {\n const result = {} as Record<string, string>;\n let current = ex;\n\n while (current !== null) {\n Object.getOwnPropertyNames(current).forEach(propertyName => {\n if (result[propertyName]) return;\n const value = current[propertyName as keyof typeof current];\n if (value) {\n result[propertyName] = String(value);\n }\n });\n current = Object.getPrototypeOf(current);\n }\n\n return result;\n}\n"]}

View File

@@ -0,0 +1,62 @@
import type * 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;
/**
* @deprecated Use `performance.timeOrigin` directly.
*/
export declare function getTimeOrigin(): number;
/**
* Returns an hrtime calculated via performance component.
* @param performanceNow
*/
export declare function hrTime(performanceNow?: number): api.HrTime;
/**
*
* Converts a TimeInput to an HrTime, defaults to _hrtime().
* @param time
*/
export declare function timeInputToHrTime(time: api.TimeInput): api.HrTime;
/**
* Returns a duration of two hrTime.
* @param startTime
* @param endTime
*/
export declare function hrTimeDuration(startTime: api.HrTime, endTime: api.HrTime): api.HrTime;
/**
* Convert hrTime to timestamp, for example "2019-05-14T17:00:00.000123456Z"
* @param time
*/
export declare function hrTimeToTimeStamp(time: api.HrTime): string;
/**
* Convert hrTime to nanoseconds.
* @param time
*/
export declare function hrTimeToNanoseconds(time: api.HrTime): number;
/**
* Convert hrTime to milliseconds.
* @param time
*/
export declare function hrTimeToMilliseconds(time: api.HrTime): number;
/**
* Convert hrTime to microseconds.
* @param time
*/
export declare function hrTimeToMicroseconds(time: api.HrTime): number;
/**
* check if time is HrTime
* @param value
*/
export declare function isTimeInputHrTime(value: unknown): value is api.HrTime;
/**
* check if input value is a correct types.TimeInput
* @param value
*/
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

View File

@@ -0,0 +1,158 @@
"use strict";
/*
* Copyright The OpenTelemetry Authors
* SPDX-License-Identifier: Apache-2.0
*/
Object.defineProperty(exports, "__esModule", { value: true });
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 of milliseconds from epoch to HrTime([seconds, remainder in nanoseconds]).
* @param epochMillis
*/
function millisToHrTime(epochMillis) {
const epochSeconds = epochMillis / 1000;
// Decimals only.
const seconds = Math.trunc(epochSeconds);
// Round sub-nanosecond accuracy to nanosecond.
const nanos = Math.round((epochMillis % 1000) * MILLISECONDS_TO_NANOSECONDS);
return [seconds, nanos];
}
exports.millisToHrTime = millisToHrTime;
/**
* @deprecated Use `performance.timeOrigin` directly.
*/
function getTimeOrigin() {
return platform_1.otperformance.timeOrigin;
}
exports.getTimeOrigin = getTimeOrigin;
/**
* Returns an hrtime calculated via performance component.
* @param performanceNow
*/
function hrTime(performanceNow) {
const timeOrigin = millisToHrTime(platform_1.otperformance.timeOrigin);
const now = millisToHrTime(typeof performanceNow === 'number' ? performanceNow : platform_1.otperformance.now());
return addHrTimes(timeOrigin, now);
}
exports.hrTime = hrTime;
/**
*
* Converts a TimeInput to an HrTime, defaults to _hrtime().
* @param time
*/
function timeInputToHrTime(time) {
// process.hrtime
if (isTimeInputHrTime(time)) {
return time;
}
else if (typeof time === 'number') {
// Must be a performance.now() if it's smaller than process start time.
if (time < platform_1.otperformance.timeOrigin) {
return hrTime(time);
}
else {
// epoch milliseconds or performance.timeOrigin
return millisToHrTime(time);
}
}
else if (time instanceof Date) {
return millisToHrTime(time.getTime());
}
else {
throw TypeError('Invalid input type');
}
}
exports.timeInputToHrTime = timeInputToHrTime;
/**
* Returns a duration of two hrTime.
* @param startTime
* @param endTime
*/
function hrTimeDuration(startTime, endTime) {
let seconds = endTime[0] - startTime[0];
let nanos = endTime[1] - startTime[1];
// overflow
if (nanos < 0) {
seconds -= 1;
// negate
nanos += SECOND_TO_NANOSECONDS;
}
return [seconds, nanos];
}
exports.hrTimeDuration = hrTimeDuration;
/**
* Convert hrTime to timestamp, for example "2019-05-14T17:00:00.000123456Z"
* @param time
*/
function hrTimeToTimeStamp(time) {
const precision = NANOSECOND_DIGITS;
const tmp = `${'0'.repeat(precision)}${time[1]}Z`;
const nanoString = tmp.substring(tmp.length - precision - 1);
const date = new Date(time[0] * 1000).toISOString();
return date.replace('000Z', nanoString);
}
exports.hrTimeToTimeStamp = hrTimeToTimeStamp;
/**
* Convert hrTime to nanoseconds.
* @param time
*/
function hrTimeToNanoseconds(time) {
return time[0] * SECOND_TO_NANOSECONDS + time[1];
}
exports.hrTimeToNanoseconds = hrTimeToNanoseconds;
/**
* Convert hrTime to milliseconds.
* @param time
*/
function hrTimeToMilliseconds(time) {
return time[0] * 1e3 + time[1] / 1e6;
}
exports.hrTimeToMilliseconds = hrTimeToMilliseconds;
/**
* Convert hrTime to microseconds.
* @param time
*/
function hrTimeToMicroseconds(time) {
return time[0] * 1e6 + time[1] / 1e3;
}
exports.hrTimeToMicroseconds = hrTimeToMicroseconds;
/**
* check if time is HrTime
* @param value
*/
function isTimeInputHrTime(value) {
return (Array.isArray(value) &&
value.length === 2 &&
typeof value[0] === 'number' &&
typeof value[1] === 'number');
}
exports.isTimeInputHrTime = isTimeInputHrTime;
/**
* check if input value is a correct types.TimeInput
* @param value
*/
function isTimeInput(value) {
return (isTimeInputHrTime(value) ||
typeof value === 'number' ||
value instanceof Date);
}
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

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,8 @@
/**
* @deprecated please copy this code to your implementation instead, this function will be removed in the next major version of this package.
* @param timer
*/
export declare function unrefTimer(timer: {
unref(): unknown;
} | number): void;
//# sourceMappingURL=timer-util.d.ts.map

View File

@@ -0,0 +1,18 @@
"use strict";
/*
* Copyright The OpenTelemetry Authors
* SPDX-License-Identifier: Apache-2.0
*/
Object.defineProperty(exports, "__esModule", { value: true });
exports.unrefTimer = void 0;
/**
* @deprecated please copy this code to your implementation instead, this function will be removed in the next major version of this package.
* @param timer
*/
function unrefTimer(timer) {
if (typeof timer !== 'number') {
timer.unref();
}
}
exports.unrefTimer = unrefTimer;
//# sourceMappingURL=timer-util.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"timer-util.js","sourceRoot":"","sources":["../../../src/common/timer-util.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH;;;GAGG;AACH,SAAgB,UAAU,CAAC,KAAoC;IAC7D,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE;QAC7B,KAAK,CAAC,KAAK,EAAE,CAAC;KACf;AACH,CAAC;AAJD,gCAIC","sourcesContent":["/*\n * Copyright The OpenTelemetry Authors\n * SPDX-License-Identifier: Apache-2.0\n */\n\n/**\n * @deprecated please copy this code to your implementation instead, this function will be removed in the next major version of this package.\n * @param timer\n */\nexport function unrefTimer(timer: { unref(): unknown } | number): void {\n if (typeof timer !== 'number') {\n timer.unref();\n }\n}\n"]}

View File

@@ -0,0 +1,23 @@
import type { Exception } from '@opentelemetry/api';
/**
* This interface defines the params that are be added to the wrapped function
* using the "shimmer.wrap"
*/
export interface ShimWrapped extends Function {
__wrapped: boolean;
__unwrap: Function;
__original: Function;
}
/**
* An instrumentation scope consists of the name and optional version
* used to obtain a tracer or meter from a provider. This metadata is made
* available on ReadableSpan and MetricRecord for use by the export pipeline.
*/
export interface InstrumentationScope {
readonly name: string;
readonly version?: string;
readonly schemaUrl?: string;
}
/** Defines an error handler function */
export type ErrorHandler = (ex: Exception) => void;
//# sourceMappingURL=types.d.ts.map

View File

@@ -0,0 +1,7 @@
"use strict";
/*
* Copyright The OpenTelemetry Authors
* SPDX-License-Identifier: Apache-2.0
*/
Object.defineProperty(exports, "__esModule", { value: true });
//# sourceMappingURL=types.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/common/types.ts"],"names":[],"mappings":";AAAA;;;GAGG","sourcesContent":["/*\n * Copyright The OpenTelemetry Authors\n * SPDX-License-Identifier: Apache-2.0\n */\n\nimport type { Exception } from '@opentelemetry/api';\n\n/**\n * This interface defines the params that are be added to the wrapped function\n * using the \"shimmer.wrap\"\n */\nexport interface ShimWrapped extends Function {\n __wrapped: boolean;\n // eslint-disable-next-line @typescript-eslint/no-unsafe-function-type\n __unwrap: Function;\n // eslint-disable-next-line @typescript-eslint/no-unsafe-function-type\n __original: Function;\n}\n\n/**\n * An instrumentation scope consists of the name and optional version\n * used to obtain a tracer or meter from a provider. This metadata is made\n * available on ReadableSpan and MetricRecord for use by the export pipeline.\n */\nexport interface InstrumentationScope {\n readonly name: string;\n readonly version?: string;\n readonly schemaUrl?: string;\n}\n\n/** Defines an error handler function */\nexport type ErrorHandler = (ex: Exception) => void;\n"]}

View File

@@ -0,0 +1,30 @@
export { W3CBaggagePropagator } from './baggage/propagation/W3CBaggagePropagator';
export { AnchoredClock } from './common/anchored-clock';
export type { Clock } from './common/anchored-clock';
export { isAttributeValue, sanitizeAttributes } from './common/attributes';
export { globalErrorHandler, setGlobalErrorHandler, } from './common/global-error-handler';
export { loggingErrorHandler } from './common/logging-error-handler';
export { addHrTimes, getTimeOrigin, hrTime, hrTimeDuration, hrTimeToMicroseconds, hrTimeToMilliseconds, hrTimeToNanoseconds, hrTimeToTimeStamp, isTimeInput, isTimeInputHrTime, millisToHrTime, timeInputToHrTime, } from './common/time';
export { unrefTimer } from './common/timer-util';
export type { ErrorHandler, InstrumentationScope } from './common/types';
export { ExportResultCode } from './ExportResult';
export type { ExportResult } from './ExportResult';
export { parseKeyPairsIntoRecord } from './baggage/utils';
export { SDK_INFO, _globalThis, getStringFromEnv, getBooleanFromEnv, getNumberFromEnv, getStringListFromEnv, otperformance, } from './platform';
export { CompositePropagator } from './propagation/composite';
export type { CompositePropagatorConfig } from './propagation/composite';
export { TRACE_PARENT_HEADER, TRACE_STATE_HEADER, W3CTraceContextPropagator, parseTraceParent, } from './trace/W3CTraceContextPropagator';
export { RPCType, deleteRPCMetadata, getRPCMetadata, setRPCMetadata, } from './trace/rpc-metadata';
export type { RPCMetadata } from './trace/rpc-metadata';
export { isTracingSuppressed, suppressTracing, unsuppressTracing, } from './trace/suppress-tracing';
export { TraceState } from './trace/TraceState';
export { merge } from './utils/merge';
export { TimeoutError, callWithTimeout } from './utils/timeout';
export { isUrlIgnored, urlMatches } from './utils/url';
export { BindOnceFuture } from './utils/callback';
export { diagLogLevelFromString } from './utils/configuration';
import { _export } from './internal/exporter';
export declare const internal: {
_export: typeof _export;
};
//# sourceMappingURL=index.d.ts.map

View File

@@ -0,0 +1,81 @@
"use strict";
/*
* Copyright The OpenTelemetry Authors
* SPDX-License-Identifier: Apache-2.0
*/
Object.defineProperty(exports, "__esModule", { value: true });
exports.internal = exports.diagLogLevelFromString = exports.BindOnceFuture = exports.urlMatches = exports.isUrlIgnored = exports.callWithTimeout = exports.TimeoutError = exports.merge = exports.TraceState = exports.unsuppressTracing = exports.suppressTracing = exports.isTracingSuppressed = exports.setRPCMetadata = exports.getRPCMetadata = exports.deleteRPCMetadata = exports.RPCType = exports.parseTraceParent = exports.W3CTraceContextPropagator = exports.TRACE_STATE_HEADER = exports.TRACE_PARENT_HEADER = exports.CompositePropagator = exports.otperformance = exports.getStringListFromEnv = exports.getNumberFromEnv = exports.getBooleanFromEnv = exports.getStringFromEnv = exports._globalThis = exports.SDK_INFO = exports.parseKeyPairsIntoRecord = exports.ExportResultCode = exports.unrefTimer = exports.timeInputToHrTime = exports.millisToHrTime = exports.isTimeInputHrTime = exports.isTimeInput = exports.hrTimeToTimeStamp = exports.hrTimeToNanoseconds = exports.hrTimeToMilliseconds = exports.hrTimeToMicroseconds = exports.hrTimeDuration = exports.hrTime = exports.getTimeOrigin = exports.addHrTimes = exports.loggingErrorHandler = exports.setGlobalErrorHandler = exports.globalErrorHandler = exports.sanitizeAttributes = exports.isAttributeValue = exports.AnchoredClock = exports.W3CBaggagePropagator = void 0;
var W3CBaggagePropagator_1 = require("./baggage/propagation/W3CBaggagePropagator");
Object.defineProperty(exports, "W3CBaggagePropagator", { enumerable: true, get: function () { return W3CBaggagePropagator_1.W3CBaggagePropagator; } });
var anchored_clock_1 = require("./common/anchored-clock");
Object.defineProperty(exports, "AnchoredClock", { enumerable: true, get: function () { return anchored_clock_1.AnchoredClock; } });
var attributes_1 = require("./common/attributes");
Object.defineProperty(exports, "isAttributeValue", { enumerable: true, get: function () { return attributes_1.isAttributeValue; } });
Object.defineProperty(exports, "sanitizeAttributes", { enumerable: true, get: function () { return attributes_1.sanitizeAttributes; } });
var global_error_handler_1 = require("./common/global-error-handler");
Object.defineProperty(exports, "globalErrorHandler", { enumerable: true, get: function () { return global_error_handler_1.globalErrorHandler; } });
Object.defineProperty(exports, "setGlobalErrorHandler", { enumerable: true, get: function () { return global_error_handler_1.setGlobalErrorHandler; } });
var logging_error_handler_1 = require("./common/logging-error-handler");
Object.defineProperty(exports, "loggingErrorHandler", { enumerable: true, get: function () { return logging_error_handler_1.loggingErrorHandler; } });
var time_1 = require("./common/time");
Object.defineProperty(exports, "addHrTimes", { enumerable: true, get: function () { return time_1.addHrTimes; } });
Object.defineProperty(exports, "getTimeOrigin", { enumerable: true, get: function () { return time_1.getTimeOrigin; } });
Object.defineProperty(exports, "hrTime", { enumerable: true, get: function () { return time_1.hrTime; } });
Object.defineProperty(exports, "hrTimeDuration", { enumerable: true, get: function () { return time_1.hrTimeDuration; } });
Object.defineProperty(exports, "hrTimeToMicroseconds", { enumerable: true, get: function () { return time_1.hrTimeToMicroseconds; } });
Object.defineProperty(exports, "hrTimeToMilliseconds", { enumerable: true, get: function () { return time_1.hrTimeToMilliseconds; } });
Object.defineProperty(exports, "hrTimeToNanoseconds", { enumerable: true, get: function () { return time_1.hrTimeToNanoseconds; } });
Object.defineProperty(exports, "hrTimeToTimeStamp", { enumerable: true, get: function () { return time_1.hrTimeToTimeStamp; } });
Object.defineProperty(exports, "isTimeInput", { enumerable: true, get: function () { return time_1.isTimeInput; } });
Object.defineProperty(exports, "isTimeInputHrTime", { enumerable: true, get: function () { return time_1.isTimeInputHrTime; } });
Object.defineProperty(exports, "millisToHrTime", { enumerable: true, get: function () { return time_1.millisToHrTime; } });
Object.defineProperty(exports, "timeInputToHrTime", { enumerable: true, get: function () { return time_1.timeInputToHrTime; } });
var timer_util_1 = require("./common/timer-util");
Object.defineProperty(exports, "unrefTimer", { enumerable: true, get: function () { return timer_util_1.unrefTimer; } });
var ExportResult_1 = require("./ExportResult");
Object.defineProperty(exports, "ExportResultCode", { enumerable: true, get: function () { return ExportResult_1.ExportResultCode; } });
var utils_1 = require("./baggage/utils");
Object.defineProperty(exports, "parseKeyPairsIntoRecord", { enumerable: true, get: function () { return utils_1.parseKeyPairsIntoRecord; } });
var platform_1 = require("./platform");
Object.defineProperty(exports, "SDK_INFO", { enumerable: true, get: function () { return platform_1.SDK_INFO; } });
Object.defineProperty(exports, "_globalThis", { enumerable: true, get: function () { return platform_1._globalThis; } });
Object.defineProperty(exports, "getStringFromEnv", { enumerable: true, get: function () { return platform_1.getStringFromEnv; } });
Object.defineProperty(exports, "getBooleanFromEnv", { enumerable: true, get: function () { return platform_1.getBooleanFromEnv; } });
Object.defineProperty(exports, "getNumberFromEnv", { enumerable: true, get: function () { return platform_1.getNumberFromEnv; } });
Object.defineProperty(exports, "getStringListFromEnv", { enumerable: true, get: function () { return platform_1.getStringListFromEnv; } });
Object.defineProperty(exports, "otperformance", { enumerable: true, get: function () { return platform_1.otperformance; } });
var composite_1 = require("./propagation/composite");
Object.defineProperty(exports, "CompositePropagator", { enumerable: true, get: function () { return composite_1.CompositePropagator; } });
var W3CTraceContextPropagator_1 = require("./trace/W3CTraceContextPropagator");
Object.defineProperty(exports, "TRACE_PARENT_HEADER", { enumerable: true, get: function () { return W3CTraceContextPropagator_1.TRACE_PARENT_HEADER; } });
Object.defineProperty(exports, "TRACE_STATE_HEADER", { enumerable: true, get: function () { return W3CTraceContextPropagator_1.TRACE_STATE_HEADER; } });
Object.defineProperty(exports, "W3CTraceContextPropagator", { enumerable: true, get: function () { return W3CTraceContextPropagator_1.W3CTraceContextPropagator; } });
Object.defineProperty(exports, "parseTraceParent", { enumerable: true, get: function () { return W3CTraceContextPropagator_1.parseTraceParent; } });
var rpc_metadata_1 = require("./trace/rpc-metadata");
Object.defineProperty(exports, "RPCType", { enumerable: true, get: function () { return rpc_metadata_1.RPCType; } });
Object.defineProperty(exports, "deleteRPCMetadata", { enumerable: true, get: function () { return rpc_metadata_1.deleteRPCMetadata; } });
Object.defineProperty(exports, "getRPCMetadata", { enumerable: true, get: function () { return rpc_metadata_1.getRPCMetadata; } });
Object.defineProperty(exports, "setRPCMetadata", { enumerable: true, get: function () { return rpc_metadata_1.setRPCMetadata; } });
var suppress_tracing_1 = require("./trace/suppress-tracing");
Object.defineProperty(exports, "isTracingSuppressed", { enumerable: true, get: function () { return suppress_tracing_1.isTracingSuppressed; } });
Object.defineProperty(exports, "suppressTracing", { enumerable: true, get: function () { return suppress_tracing_1.suppressTracing; } });
Object.defineProperty(exports, "unsuppressTracing", { enumerable: true, get: function () { return suppress_tracing_1.unsuppressTracing; } });
var TraceState_1 = require("./trace/TraceState");
Object.defineProperty(exports, "TraceState", { enumerable: true, get: function () { return TraceState_1.TraceState; } });
var merge_1 = require("./utils/merge");
Object.defineProperty(exports, "merge", { enumerable: true, get: function () { return merge_1.merge; } });
var timeout_1 = require("./utils/timeout");
Object.defineProperty(exports, "TimeoutError", { enumerable: true, get: function () { return timeout_1.TimeoutError; } });
Object.defineProperty(exports, "callWithTimeout", { enumerable: true, get: function () { return timeout_1.callWithTimeout; } });
var url_1 = require("./utils/url");
Object.defineProperty(exports, "isUrlIgnored", { enumerable: true, get: function () { return url_1.isUrlIgnored; } });
Object.defineProperty(exports, "urlMatches", { enumerable: true, get: function () { return url_1.urlMatches; } });
var callback_1 = require("./utils/callback");
Object.defineProperty(exports, "BindOnceFuture", { enumerable: true, get: function () { return callback_1.BindOnceFuture; } });
var configuration_1 = require("./utils/configuration");
Object.defineProperty(exports, "diagLogLevelFromString", { enumerable: true, get: function () { return configuration_1.diagLogLevelFromString; } });
const exporter_1 = require("./internal/exporter");
exports.internal = {
_export: exporter_1._export,
};
//# sourceMappingURL=index.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,mFAAkF;AAAzE,4HAAA,oBAAoB,OAAA;AAC7B,0DAAwD;AAA/C,+GAAA,aAAa,OAAA;AAEtB,kDAA2E;AAAlE,8GAAA,gBAAgB,OAAA;AAAE,gHAAA,kBAAkB,OAAA;AAC7C,sEAGuC;AAFrC,0HAAA,kBAAkB,OAAA;AAClB,6HAAA,qBAAqB,OAAA;AAEvB,wEAAqE;AAA5D,4HAAA,mBAAmB,OAAA;AAC5B,sCAauB;AAZrB,kGAAA,UAAU,OAAA;AACV,qGAAA,aAAa,OAAA;AACb,8FAAA,MAAM,OAAA;AACN,sGAAA,cAAc,OAAA;AACd,4GAAA,oBAAoB,OAAA;AACpB,4GAAA,oBAAoB,OAAA;AACpB,2GAAA,mBAAmB,OAAA;AACnB,yGAAA,iBAAiB,OAAA;AACjB,mGAAA,WAAW,OAAA;AACX,yGAAA,iBAAiB,OAAA;AACjB,sGAAA,cAAc,OAAA;AACd,yGAAA,iBAAiB,OAAA;AAEnB,kDAAiD;AAAxC,wGAAA,UAAU,OAAA;AAEnB,+CAAkD;AAAzC,gHAAA,gBAAgB,OAAA;AAEzB,yCAA0D;AAAjD,gHAAA,uBAAuB,OAAA;AAChC,uCAQoB;AAPlB,oGAAA,QAAQ,OAAA;AACR,uGAAA,WAAW,OAAA;AACX,4GAAA,gBAAgB,OAAA;AAChB,6GAAA,iBAAiB,OAAA;AACjB,4GAAA,gBAAgB,OAAA;AAChB,gHAAA,oBAAoB,OAAA;AACpB,yGAAA,aAAa,OAAA;AAEf,qDAA8D;AAArD,gHAAA,mBAAmB,OAAA;AAE5B,+EAK2C;AAJzC,gIAAA,mBAAmB,OAAA;AACnB,+HAAA,kBAAkB,OAAA;AAClB,sIAAA,yBAAyB,OAAA;AACzB,6HAAA,gBAAgB,OAAA;AAElB,qDAK8B;AAJ5B,uGAAA,OAAO,OAAA;AACP,iHAAA,iBAAiB,OAAA;AACjB,8GAAA,cAAc,OAAA;AACd,8GAAA,cAAc,OAAA;AAGhB,6DAIkC;AAHhC,uHAAA,mBAAmB,OAAA;AACnB,mHAAA,eAAe,OAAA;AACf,qHAAA,iBAAiB,OAAA;AAEnB,iDAAgD;AAAvC,wGAAA,UAAU,OAAA;AACnB,uCAAsC;AAA7B,8FAAA,KAAK,OAAA;AACd,2CAAgE;AAAvD,uGAAA,YAAY,OAAA;AAAE,0GAAA,eAAe,OAAA;AACtC,mCAAuD;AAA9C,mGAAA,YAAY,OAAA;AAAE,iGAAA,UAAU,OAAA;AACjC,6CAAkD;AAAzC,0GAAA,cAAc,OAAA;AACvB,uDAA+D;AAAtD,uHAAA,sBAAsB,OAAA;AAC/B,kDAA8C;AACjC,QAAA,QAAQ,GAAG;IACtB,OAAO,EAAP,kBAAO;CACR,CAAC","sourcesContent":["/*\n * Copyright The OpenTelemetry Authors\n * SPDX-License-Identifier: Apache-2.0\n */\n\nexport { W3CBaggagePropagator } from './baggage/propagation/W3CBaggagePropagator';\nexport { AnchoredClock } from './common/anchored-clock';\nexport type { Clock } from './common/anchored-clock';\nexport { isAttributeValue, sanitizeAttributes } from './common/attributes';\nexport {\n globalErrorHandler,\n setGlobalErrorHandler,\n} from './common/global-error-handler';\nexport { loggingErrorHandler } from './common/logging-error-handler';\nexport {\n addHrTimes,\n getTimeOrigin,\n hrTime,\n hrTimeDuration,\n hrTimeToMicroseconds,\n hrTimeToMilliseconds,\n hrTimeToNanoseconds,\n hrTimeToTimeStamp,\n isTimeInput,\n isTimeInputHrTime,\n millisToHrTime,\n timeInputToHrTime,\n} from './common/time';\nexport { unrefTimer } from './common/timer-util';\nexport type { ErrorHandler, InstrumentationScope } from './common/types';\nexport { ExportResultCode } from './ExportResult';\nexport type { ExportResult } from './ExportResult';\nexport { parseKeyPairsIntoRecord } from './baggage/utils';\nexport {\n SDK_INFO,\n _globalThis,\n getStringFromEnv,\n getBooleanFromEnv,\n getNumberFromEnv,\n getStringListFromEnv,\n otperformance,\n} from './platform';\nexport { CompositePropagator } from './propagation/composite';\nexport type { CompositePropagatorConfig } from './propagation/composite';\nexport {\n TRACE_PARENT_HEADER,\n TRACE_STATE_HEADER,\n W3CTraceContextPropagator,\n parseTraceParent,\n} from './trace/W3CTraceContextPropagator';\nexport {\n RPCType,\n deleteRPCMetadata,\n getRPCMetadata,\n setRPCMetadata,\n} from './trace/rpc-metadata';\nexport type { RPCMetadata } from './trace/rpc-metadata';\nexport {\n isTracingSuppressed,\n suppressTracing,\n unsuppressTracing,\n} from './trace/suppress-tracing';\nexport { TraceState } from './trace/TraceState';\nexport { merge } from './utils/merge';\nexport { TimeoutError, callWithTimeout } from './utils/timeout';\nexport { isUrlIgnored, urlMatches } from './utils/url';\nexport { BindOnceFuture } from './utils/callback';\nexport { diagLogLevelFromString } from './utils/configuration';\nimport { _export } from './internal/exporter';\nexport const internal = {\n _export,\n};\n"]}

View File

@@ -0,0 +1,10 @@
import type { ExportResult } from '../ExportResult';
export interface Exporter<T> {
export(arg: T, resultCallback: (result: ExportResult) => void): void;
}
/**
* @internal
* Shared functionality used by Exporters while exporting data, including suppression of Traces.
*/
export declare function _export<T>(exporter: Exporter<T>, arg: T): Promise<ExportResult>;
//# sourceMappingURL=exporter.d.ts.map

View File

@@ -0,0 +1,23 @@
"use strict";
/*
* Copyright The OpenTelemetry Authors
* SPDX-License-Identifier: Apache-2.0
*/
Object.defineProperty(exports, "__esModule", { value: true });
exports._export = void 0;
const api_1 = require("@opentelemetry/api");
const suppress_tracing_1 = require("../trace/suppress-tracing");
/**
* @internal
* Shared functionality used by Exporters while exporting data, including suppression of Traces.
*/
function _export(exporter, arg) {
return new Promise(resolve => {
// prevent downstream exporter calls from generating spans
api_1.context.with((0, suppress_tracing_1.suppressTracing)(api_1.context.active()), () => {
exporter.export(arg, resolve);
});
});
}
exports._export = _export;
//# sourceMappingURL=exporter.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"exporter.js","sourceRoot":"","sources":["../../../src/internal/exporter.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,4CAA6C;AAE7C,gEAA4D;AAM5D;;;GAGG;AACH,SAAgB,OAAO,CACrB,QAAqB,EACrB,GAAM;IAEN,OAAO,IAAI,OAAO,CAAC,OAAO,CAAC,EAAE;QAC3B,0DAA0D;QAC1D,aAAO,CAAC,IAAI,CAAC,IAAA,kCAAe,EAAC,aAAO,CAAC,MAAM,EAAE,CAAC,EAAE,GAAG,EAAE;YACnD,QAAQ,CAAC,MAAM,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC;QAChC,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC;AAVD,0BAUC","sourcesContent":["/*\n * Copyright The OpenTelemetry Authors\n * SPDX-License-Identifier: Apache-2.0\n */\n\nimport { context } from '@opentelemetry/api';\nimport type { ExportResult } from '../ExportResult';\nimport { suppressTracing } from '../trace/suppress-tracing';\n\nexport interface Exporter<T> {\n export(arg: T, resultCallback: (result: ExportResult) => void): void;\n}\n\n/**\n * @internal\n * Shared functionality used by Exporters while exporting data, including suppression of Traces.\n */\nexport function _export<T>(\n exporter: Exporter<T>,\n arg: T\n): Promise<ExportResult> {\n return new Promise(resolve => {\n // prevent downstream exporter calls from generating spans\n context.with(suppressTracing(context.active()), () => {\n exporter.export(arg, resolve);\n });\n });\n}\n"]}

View File

@@ -0,0 +1,15 @@
/**
* Key is opaque string up to 256 characters printable. It MUST begin with a
* lowercase letter, and can only contain lowercase letters a-z, digits 0-9,
* underscores _, dashes -, asterisks *, and forward slashes /.
* For multi-tenant vendor scenarios, an at sign (@) can be used to prefix the
* vendor name. Vendors SHOULD set the tenant ID at the beginning of the key.
* see https://www.w3.org/TR/trace-context/#key
*/
export declare function validateKey(key: string): boolean;
/**
* Value is opaque string up to 256 characters printable ASCII RFC0020
* characters (i.e., the range 0x20 to 0x7E) except comma , and =.
*/
export declare function validateValue(value: string): boolean;
//# sourceMappingURL=validators.d.ts.map

View File

@@ -0,0 +1,35 @@
"use strict";
/*
* Copyright The OpenTelemetry Authors
* SPDX-License-Identifier: Apache-2.0
*/
Object.defineProperty(exports, "__esModule", { value: true });
exports.validateValue = exports.validateKey = void 0;
const VALID_KEY_CHAR_RANGE = '[_0-9a-z-*/]';
const VALID_KEY = `[a-z]${VALID_KEY_CHAR_RANGE}{0,255}`;
const VALID_VENDOR_KEY = `[a-z0-9]${VALID_KEY_CHAR_RANGE}{0,240}@[a-z]${VALID_KEY_CHAR_RANGE}{0,13}`;
const VALID_KEY_REGEX = new RegExp(`^(?:${VALID_KEY}|${VALID_VENDOR_KEY})$`);
const VALID_VALUE_BASE_REGEX = /^[ -~]{0,255}[!-~]$/;
const INVALID_VALUE_COMMA_EQUAL_REGEX = /,|=/;
/**
* Key is opaque string up to 256 characters printable. It MUST begin with a
* lowercase letter, and can only contain lowercase letters a-z, digits 0-9,
* underscores _, dashes -, asterisks *, and forward slashes /.
* For multi-tenant vendor scenarios, an at sign (@) can be used to prefix the
* vendor name. Vendors SHOULD set the tenant ID at the beginning of the key.
* see https://www.w3.org/TR/trace-context/#key
*/
function validateKey(key) {
return VALID_KEY_REGEX.test(key);
}
exports.validateKey = validateKey;
/**
* Value is opaque string up to 256 characters printable ASCII RFC0020
* characters (i.e., the range 0x20 to 0x7E) except comma , and =.
*/
function validateValue(value) {
return (VALID_VALUE_BASE_REGEX.test(value) &&
!INVALID_VALUE_COMMA_EQUAL_REGEX.test(value));
}
exports.validateValue = validateValue;
//# sourceMappingURL=validators.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"validators.js","sourceRoot":"","sources":["../../../src/internal/validators.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,MAAM,oBAAoB,GAAG,cAAc,CAAC;AAC5C,MAAM,SAAS,GAAG,QAAQ,oBAAoB,SAAS,CAAC;AACxD,MAAM,gBAAgB,GAAG,WAAW,oBAAoB,gBAAgB,oBAAoB,QAAQ,CAAC;AACrG,MAAM,eAAe,GAAG,IAAI,MAAM,CAAC,OAAO,SAAS,IAAI,gBAAgB,IAAI,CAAC,CAAC;AAC7E,MAAM,sBAAsB,GAAG,qBAAqB,CAAC;AACrD,MAAM,+BAA+B,GAAG,KAAK,CAAC;AAE9C;;;;;;;GAOG;AACH,SAAgB,WAAW,CAAC,GAAW;IACrC,OAAO,eAAe,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AACnC,CAAC;AAFD,kCAEC;AAED;;;GAGG;AACH,SAAgB,aAAa,CAAC,KAAa;IACzC,OAAO,CACL,sBAAsB,CAAC,IAAI,CAAC,KAAK,CAAC;QAClC,CAAC,+BAA+B,CAAC,IAAI,CAAC,KAAK,CAAC,CAC7C,CAAC;AACJ,CAAC;AALD,sCAKC","sourcesContent":["/*\n * Copyright The OpenTelemetry Authors\n * SPDX-License-Identifier: Apache-2.0\n */\n\nconst VALID_KEY_CHAR_RANGE = '[_0-9a-z-*/]';\nconst VALID_KEY = `[a-z]${VALID_KEY_CHAR_RANGE}{0,255}`;\nconst VALID_VENDOR_KEY = `[a-z0-9]${VALID_KEY_CHAR_RANGE}{0,240}@[a-z]${VALID_KEY_CHAR_RANGE}{0,13}`;\nconst VALID_KEY_REGEX = new RegExp(`^(?:${VALID_KEY}|${VALID_VENDOR_KEY})$`);\nconst VALID_VALUE_BASE_REGEX = /^[ -~]{0,255}[!-~]$/;\nconst INVALID_VALUE_COMMA_EQUAL_REGEX = /,|=/;\n\n/**\n * Key is opaque string up to 256 characters printable. It MUST begin with a\n * lowercase letter, and can only contain lowercase letters a-z, digits 0-9,\n * underscores _, dashes -, asterisks *, and forward slashes /.\n * For multi-tenant vendor scenarios, an at sign (@) can be used to prefix the\n * vendor name. Vendors SHOULD set the tenant ID at the beginning of the key.\n * see https://www.w3.org/TR/trace-context/#key\n */\nexport function validateKey(key: string): boolean {\n return VALID_KEY_REGEX.test(key);\n}\n\n/**\n * Value is opaque string up to 256 characters printable ASCII RFC0020\n * characters (i.e., the range 0x20 to 0x7E) except comma , and =.\n */\nexport function validateValue(value: string): boolean {\n return (\n VALID_VALUE_BASE_REGEX.test(value) &&\n !INVALID_VALUE_COMMA_EQUAL_REGEX.test(value)\n );\n}\n"]}

View File

@@ -0,0 +1,5 @@
export declare function getStringFromEnv(_: string): string | undefined;
export declare function getBooleanFromEnv(_: string): boolean | undefined;
export declare function getNumberFromEnv(_: string): number | undefined;
export declare function getStringListFromEnv(_: string): string[] | undefined;
//# sourceMappingURL=environment.d.ts.map

View File

@@ -0,0 +1,24 @@
"use strict";
/*
* Copyright The OpenTelemetry Authors
* SPDX-License-Identifier: Apache-2.0
*/
Object.defineProperty(exports, "__esModule", { value: true });
exports.getStringListFromEnv = exports.getNumberFromEnv = exports.getBooleanFromEnv = exports.getStringFromEnv = void 0;
function getStringFromEnv(_) {
return undefined;
}
exports.getStringFromEnv = getStringFromEnv;
function getBooleanFromEnv(_) {
return undefined;
}
exports.getBooleanFromEnv = getBooleanFromEnv;
function getNumberFromEnv(_) {
return undefined;
}
exports.getNumberFromEnv = getNumberFromEnv;
function getStringListFromEnv(_) {
return undefined;
}
exports.getStringListFromEnv = getStringListFromEnv;
//# sourceMappingURL=environment.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"environment.js","sourceRoot":"","sources":["../../../../src/platform/browser/environment.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,SAAgB,gBAAgB,CAAC,CAAS;IACxC,OAAO,SAAS,CAAC;AACnB,CAAC;AAFD,4CAEC;AAED,SAAgB,iBAAiB,CAAC,CAAS;IACzC,OAAO,SAAS,CAAC;AACnB,CAAC;AAFD,8CAEC;AAED,SAAgB,gBAAgB,CAAC,CAAS;IACxC,OAAO,SAAS,CAAC;AACnB,CAAC;AAFD,4CAEC;AAED,SAAgB,oBAAoB,CAAC,CAAS;IAC5C,OAAO,SAAS,CAAC;AACnB,CAAC;AAFD,oDAEC","sourcesContent":["/*\n * Copyright The OpenTelemetry Authors\n * SPDX-License-Identifier: Apache-2.0\n */\n\nexport function getStringFromEnv(_: string): string | undefined {\n return undefined;\n}\n\nexport function getBooleanFromEnv(_: string): boolean | undefined {\n return undefined;\n}\n\nexport function getNumberFromEnv(_: string): number | undefined {\n return undefined;\n}\n\nexport function getStringListFromEnv(_: string): string[] | undefined {\n return undefined;\n}\n"]}

View File

@@ -0,0 +1,8 @@
export { getStringFromEnv, getBooleanFromEnv, getNumberFromEnv, getStringListFromEnv, } from './environment';
export { _globalThis } from '../../common/globalThis';
export { SDK_INFO } from './sdk-info';
/**
* @deprecated Use performance directly.
*/
export declare const otperformance: Performance;
//# sourceMappingURL=index.d.ts.map

View File

@@ -0,0 +1,21 @@
"use strict";
/*
* Copyright The OpenTelemetry Authors
* SPDX-License-Identifier: Apache-2.0
*/
Object.defineProperty(exports, "__esModule", { value: true });
exports.otperformance = exports.SDK_INFO = exports._globalThis = exports.getStringListFromEnv = exports.getNumberFromEnv = exports.getBooleanFromEnv = exports.getStringFromEnv = void 0;
var environment_1 = require("./environment");
Object.defineProperty(exports, "getStringFromEnv", { enumerable: true, get: function () { return environment_1.getStringFromEnv; } });
Object.defineProperty(exports, "getBooleanFromEnv", { enumerable: true, get: function () { return environment_1.getBooleanFromEnv; } });
Object.defineProperty(exports, "getNumberFromEnv", { enumerable: true, get: function () { return environment_1.getNumberFromEnv; } });
Object.defineProperty(exports, "getStringListFromEnv", { enumerable: true, get: function () { return environment_1.getStringListFromEnv; } });
var globalThis_1 = require("../../common/globalThis");
Object.defineProperty(exports, "_globalThis", { enumerable: true, get: function () { return globalThis_1._globalThis; } });
var sdk_info_1 = require("./sdk-info");
Object.defineProperty(exports, "SDK_INFO", { enumerable: true, get: function () { return sdk_info_1.SDK_INFO; } });
/**
* @deprecated Use performance directly.
*/
exports.otperformance = performance;
//# sourceMappingURL=index.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/platform/browser/index.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,6CAKuB;AAJrB,+GAAA,gBAAgB,OAAA;AAChB,gHAAA,iBAAiB,OAAA;AACjB,+GAAA,gBAAgB,OAAA;AAChB,mHAAA,oBAAoB,OAAA;AAEtB,sDAAsD;AAA7C,yGAAA,WAAW,OAAA;AACpB,uCAAsC;AAA7B,oGAAA,QAAQ,OAAA;AAEjB;;GAEG;AACU,QAAA,aAAa,GAAG,WAAW,CAAC","sourcesContent":["/*\n * Copyright The OpenTelemetry Authors\n * SPDX-License-Identifier: Apache-2.0\n */\n\nexport {\n getStringFromEnv,\n getBooleanFromEnv,\n getNumberFromEnv,\n getStringListFromEnv,\n} from './environment';\nexport { _globalThis } from '../../common/globalThis';\nexport { SDK_INFO } from './sdk-info';\n\n/**\n * @deprecated Use performance directly.\n */\nexport const otperformance = performance;\n"]}

View File

@@ -0,0 +1,8 @@
/** Constants describing the SDK in use */
export declare const SDK_INFO: {
"telemetry.sdk.name": string;
"process.runtime.name": string;
"telemetry.sdk.language": "webjs";
"telemetry.sdk.version": string;
};
//# sourceMappingURL=sdk-info.d.ts.map

View File

@@ -0,0 +1,18 @@
"use strict";
/*
* Copyright The OpenTelemetry Authors
* SPDX-License-Identifier: Apache-2.0
*/
Object.defineProperty(exports, "__esModule", { value: true });
exports.SDK_INFO = void 0;
const version_1 = require("../../version");
const semantic_conventions_1 = require("@opentelemetry/semantic-conventions");
const semconv_1 = require("../../semconv");
/** Constants describing the SDK in use */
exports.SDK_INFO = {
[semantic_conventions_1.ATTR_TELEMETRY_SDK_NAME]: 'opentelemetry',
[semconv_1.ATTR_PROCESS_RUNTIME_NAME]: 'browser',
[semantic_conventions_1.ATTR_TELEMETRY_SDK_LANGUAGE]: semantic_conventions_1.TELEMETRY_SDK_LANGUAGE_VALUE_WEBJS,
[semantic_conventions_1.ATTR_TELEMETRY_SDK_VERSION]: version_1.VERSION,
};
//# sourceMappingURL=sdk-info.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"sdk-info.js","sourceRoot":"","sources":["../../../../src/platform/browser/sdk-info.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,2CAAwC;AACxC,8EAK6C;AAC7C,2CAA0D;AAE1D,0CAA0C;AAC7B,QAAA,QAAQ,GAAG;IACtB,CAAC,8CAAuB,CAAC,EAAE,eAAe;IAC1C,CAAC,mCAAyB,CAAC,EAAE,SAAS;IACtC,CAAC,kDAA2B,CAAC,EAAE,yDAAkC;IACjE,CAAC,iDAA0B,CAAC,EAAE,iBAAO;CACtC,CAAC","sourcesContent":["/*\n * Copyright The OpenTelemetry Authors\n * SPDX-License-Identifier: Apache-2.0\n */\n\nimport { VERSION } from '../../version';\nimport {\n ATTR_TELEMETRY_SDK_NAME,\n ATTR_TELEMETRY_SDK_LANGUAGE,\n TELEMETRY_SDK_LANGUAGE_VALUE_WEBJS,\n ATTR_TELEMETRY_SDK_VERSION,\n} from '@opentelemetry/semantic-conventions';\nimport { ATTR_PROCESS_RUNTIME_NAME } from '../../semconv';\n\n/** Constants describing the SDK in use */\nexport const SDK_INFO = {\n [ATTR_TELEMETRY_SDK_NAME]: 'opentelemetry',\n [ATTR_PROCESS_RUNTIME_NAME]: 'browser',\n [ATTR_TELEMETRY_SDK_LANGUAGE]: TELEMETRY_SDK_LANGUAGE_VALUE_WEBJS,\n [ATTR_TELEMETRY_SDK_VERSION]: VERSION,\n};\n"]}

View File

@@ -0,0 +1,2 @@
export { SDK_INFO, _globalThis, otperformance, getBooleanFromEnv, getStringFromEnv, getNumberFromEnv, getStringListFromEnv, } from './node';
//# sourceMappingURL=index.d.ts.map

View File

@@ -0,0 +1,16 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.getStringListFromEnv = exports.getNumberFromEnv = exports.getStringFromEnv = exports.getBooleanFromEnv = exports.otperformance = exports._globalThis = exports.SDK_INFO = void 0;
/*
* Copyright The OpenTelemetry Authors
* SPDX-License-Identifier: Apache-2.0
*/
var node_1 = require("./node");
Object.defineProperty(exports, "SDK_INFO", { enumerable: true, get: function () { return node_1.SDK_INFO; } });
Object.defineProperty(exports, "_globalThis", { enumerable: true, get: function () { return node_1._globalThis; } });
Object.defineProperty(exports, "otperformance", { enumerable: true, get: function () { return node_1.otperformance; } });
Object.defineProperty(exports, "getBooleanFromEnv", { enumerable: true, get: function () { return node_1.getBooleanFromEnv; } });
Object.defineProperty(exports, "getStringFromEnv", { enumerable: true, get: function () { return node_1.getStringFromEnv; } });
Object.defineProperty(exports, "getNumberFromEnv", { enumerable: true, get: function () { return node_1.getNumberFromEnv; } });
Object.defineProperty(exports, "getStringListFromEnv", { enumerable: true, get: function () { return node_1.getStringListFromEnv; } });
//# sourceMappingURL=index.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/platform/index.ts"],"names":[],"mappings":";;;AAAA;;;GAGG;AACH,+BAQgB;AAPd,gGAAA,QAAQ,OAAA;AACR,mGAAA,WAAW,OAAA;AACX,qGAAA,aAAa,OAAA;AACb,yGAAA,iBAAiB,OAAA;AACjB,wGAAA,gBAAgB,OAAA;AAChB,wGAAA,gBAAgB,OAAA;AAChB,4GAAA,oBAAoB,OAAA","sourcesContent":["/*\n * Copyright The OpenTelemetry Authors\n * SPDX-License-Identifier: Apache-2.0\n */\nexport {\n SDK_INFO,\n _globalThis,\n otperformance,\n getBooleanFromEnv,\n getStringFromEnv,\n getNumberFromEnv,\n getStringListFromEnv,\n} from './node';\n"]}

View File

@@ -0,0 +1,40 @@
/**
* Retrieves a number from an environment variable.
* - Returns `undefined` if the environment variable is empty, unset, contains only whitespace, or is not a number.
* - Returns a number in all other cases.
*
* @param {string} key - The name of the environment variable to retrieve.
* @returns {number | undefined} - The number value or `undefined`.
*/
export declare function getNumberFromEnv(key: string): number | undefined;
/**
* Retrieves a string from an environment variable.
* - Returns `undefined` if the environment variable is empty, unset, or contains only whitespace.
*
* @param {string} key - The name of the environment variable to retrieve.
* @returns {string | undefined} - The string value or `undefined`.
*/
export declare function getStringFromEnv(key: string): string | undefined;
/**
* Retrieves a boolean value from an environment variable.
* - Trims leading and trailing whitespace and ignores casing.
* - Returns `false` if the environment variable is empty, unset, or contains only whitespace.
* - Returns `false` for strings that cannot be mapped to a boolean.
*
* @param {string} key - The name of the environment variable to retrieve.
* @returns {boolean} - The boolean value or `false` if the environment variable is unset empty, unset, or contains only whitespace.
*/
export declare function getBooleanFromEnv(key: string): boolean;
/**
* Retrieves a list of strings from an environment variable.
* - Uses ',' as the delimiter.
* - Trims leading and trailing whitespace from each entry.
* - Excludes empty entries.
* - Returns `undefined` if the environment variable is empty or contains only whitespace.
* - Returns an empty array if all entries are empty or whitespace.
*
* @param {string} key - The name of the environment variable to retrieve.
* @returns {string[] | undefined} - The list of strings or `undefined`.
*/
export declare function getStringListFromEnv(key: string): string[] | undefined;
//# sourceMappingURL=environment.d.ts.map

View File

@@ -0,0 +1,93 @@
"use strict";
/*
* Copyright The OpenTelemetry Authors
* SPDX-License-Identifier: Apache-2.0
*/
Object.defineProperty(exports, "__esModule", { value: true });
exports.getStringListFromEnv = exports.getBooleanFromEnv = exports.getStringFromEnv = exports.getNumberFromEnv = void 0;
const api_1 = require("@opentelemetry/api");
const util_1 = require("util");
/**
* Retrieves a number from an environment variable.
* - Returns `undefined` if the environment variable is empty, unset, contains only whitespace, or is not a number.
* - Returns a number in all other cases.
*
* @param {string} key - The name of the environment variable to retrieve.
* @returns {number | undefined} - The number value or `undefined`.
*/
function getNumberFromEnv(key) {
const raw = process.env[key];
if (raw == null || raw.trim() === '') {
return undefined;
}
const value = Number(raw);
if (isNaN(value)) {
api_1.diag.warn(`Unknown value ${(0, util_1.inspect)(raw)} for ${key}, expected a number, using defaults`);
return undefined;
}
return value;
}
exports.getNumberFromEnv = getNumberFromEnv;
/**
* Retrieves a string from an environment variable.
* - Returns `undefined` if the environment variable is empty, unset, or contains only whitespace.
*
* @param {string} key - The name of the environment variable to retrieve.
* @returns {string | undefined} - The string value or `undefined`.
*/
function getStringFromEnv(key) {
const raw = process.env[key];
if (raw == null || raw.trim() === '') {
return undefined;
}
return raw;
}
exports.getStringFromEnv = getStringFromEnv;
/**
* Retrieves a boolean value from an environment variable.
* - Trims leading and trailing whitespace and ignores casing.
* - Returns `false` if the environment variable is empty, unset, or contains only whitespace.
* - Returns `false` for strings that cannot be mapped to a boolean.
*
* @param {string} key - The name of the environment variable to retrieve.
* @returns {boolean} - The boolean value or `false` if the environment variable is unset empty, unset, or contains only whitespace.
*/
function getBooleanFromEnv(key) {
const raw = process.env[key]?.trim().toLowerCase();
if (raw == null || raw === '') {
// NOTE: falling back to `false` instead of `undefined` as required by the specification.
// If you have a use-case that requires `undefined`, consider using `getStringFromEnv()` and applying the necessary
// normalizations in the consuming code.
return false;
}
if (raw === 'true') {
return true;
}
else if (raw === 'false') {
return false;
}
else {
api_1.diag.warn(`Unknown value ${(0, util_1.inspect)(raw)} for ${key}, expected 'true' or 'false', falling back to 'false' (default)`);
return false;
}
}
exports.getBooleanFromEnv = getBooleanFromEnv;
/**
* Retrieves a list of strings from an environment variable.
* - Uses ',' as the delimiter.
* - Trims leading and trailing whitespace from each entry.
* - Excludes empty entries.
* - Returns `undefined` if the environment variable is empty or contains only whitespace.
* - Returns an empty array if all entries are empty or whitespace.
*
* @param {string} key - The name of the environment variable to retrieve.
* @returns {string[] | undefined} - The list of strings or `undefined`.
*/
function getStringListFromEnv(key) {
return getStringFromEnv(key)
?.split(',')
.map(v => v.trim())
.filter(s => s !== '');
}
exports.getStringListFromEnv = getStringListFromEnv;
//# sourceMappingURL=environment.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"environment.js","sourceRoot":"","sources":["../../../../src/platform/node/environment.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,4CAA0C;AAC1C,+BAA+B;AAE/B;;;;;;;GAOG;AACH,SAAgB,gBAAgB,CAAC,GAAW;IAC1C,MAAM,GAAG,GAAG,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;IAC7B,IAAI,GAAG,IAAI,IAAI,IAAI,GAAG,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE;QACpC,OAAO,SAAS,CAAC;KAClB;IAED,MAAM,KAAK,GAAG,MAAM,CAAC,GAAG,CAAC,CAAC;IAC1B,IAAI,KAAK,CAAC,KAAK,CAAC,EAAE;QAChB,UAAI,CAAC,IAAI,CACP,iBAAiB,IAAA,cAAO,EAAC,GAAG,CAAC,QAAQ,GAAG,qCAAqC,CAC9E,CAAC;QACF,OAAO,SAAS,CAAC;KAClB;IAED,OAAO,KAAK,CAAC;AACf,CAAC;AAfD,4CAeC;AAED;;;;;;GAMG;AACH,SAAgB,gBAAgB,CAAC,GAAW;IAC1C,MAAM,GAAG,GAAG,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;IAC7B,IAAI,GAAG,IAAI,IAAI,IAAI,GAAG,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE;QACpC,OAAO,SAAS,CAAC;KAClB;IACD,OAAO,GAAG,CAAC;AACb,CAAC;AAND,4CAMC;AAED;;;;;;;;GAQG;AACH,SAAgB,iBAAiB,CAAC,GAAW;IAC3C,MAAM,GAAG,GAAG,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE,IAAI,EAAE,CAAC,WAAW,EAAE,CAAC;IACnD,IAAI,GAAG,IAAI,IAAI,IAAI,GAAG,KAAK,EAAE,EAAE;QAC7B,yFAAyF;QACzF,mHAAmH;QACnH,wCAAwC;QACxC,OAAO,KAAK,CAAC;KACd;IACD,IAAI,GAAG,KAAK,MAAM,EAAE;QAClB,OAAO,IAAI,CAAC;KACb;SAAM,IAAI,GAAG,KAAK,OAAO,EAAE;QAC1B,OAAO,KAAK,CAAC;KACd;SAAM;QACL,UAAI,CAAC,IAAI,CACP,iBAAiB,IAAA,cAAO,EAAC,GAAG,CAAC,QAAQ,GAAG,iEAAiE,CAC1G,CAAC;QACF,OAAO,KAAK,CAAC;KACd;AACH,CAAC;AAlBD,8CAkBC;AAED;;;;;;;;;;GAUG;AACH,SAAgB,oBAAoB,CAAC,GAAW;IAC9C,OAAO,gBAAgB,CAAC,GAAG,CAAC;QAC1B,EAAE,KAAK,CAAC,GAAG,CAAC;SACX,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC;SAClB,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,KAAK,EAAE,CAAC,CAAC;AAC3B,CAAC;AALD,oDAKC","sourcesContent":["/*\n * Copyright The OpenTelemetry Authors\n * SPDX-License-Identifier: Apache-2.0\n */\n\nimport { diag } from '@opentelemetry/api';\nimport { inspect } from 'util';\n\n/**\n * Retrieves a number from an environment variable.\n * - Returns `undefined` if the environment variable is empty, unset, contains only whitespace, or is not a number.\n * - Returns a number in all other cases.\n *\n * @param {string} key - The name of the environment variable to retrieve.\n * @returns {number | undefined} - The number value or `undefined`.\n */\nexport function getNumberFromEnv(key: string): number | undefined {\n const raw = process.env[key];\n if (raw == null || raw.trim() === '') {\n return undefined;\n }\n\n const value = Number(raw);\n if (isNaN(value)) {\n diag.warn(\n `Unknown value ${inspect(raw)} for ${key}, expected a number, using defaults`\n );\n return undefined;\n }\n\n return value;\n}\n\n/**\n * Retrieves a string from an environment variable.\n * - Returns `undefined` if the environment variable is empty, unset, or contains only whitespace.\n *\n * @param {string} key - The name of the environment variable to retrieve.\n * @returns {string | undefined} - The string value or `undefined`.\n */\nexport function getStringFromEnv(key: string): string | undefined {\n const raw = process.env[key];\n if (raw == null || raw.trim() === '') {\n return undefined;\n }\n return raw;\n}\n\n/**\n * Retrieves a boolean value from an environment variable.\n * - Trims leading and trailing whitespace and ignores casing.\n * - Returns `false` if the environment variable is empty, unset, or contains only whitespace.\n * - Returns `false` for strings that cannot be mapped to a boolean.\n *\n * @param {string} key - The name of the environment variable to retrieve.\n * @returns {boolean} - The boolean value or `false` if the environment variable is unset empty, unset, or contains only whitespace.\n */\nexport function getBooleanFromEnv(key: string): boolean {\n const raw = process.env[key]?.trim().toLowerCase();\n if (raw == null || raw === '') {\n // NOTE: falling back to `false` instead of `undefined` as required by the specification.\n // If you have a use-case that requires `undefined`, consider using `getStringFromEnv()` and applying the necessary\n // normalizations in the consuming code.\n return false;\n }\n if (raw === 'true') {\n return true;\n } else if (raw === 'false') {\n return false;\n } else {\n diag.warn(\n `Unknown value ${inspect(raw)} for ${key}, expected 'true' or 'false', falling back to 'false' (default)`\n );\n return false;\n }\n}\n\n/**\n * Retrieves a list of strings from an environment variable.\n * - Uses ',' as the delimiter.\n * - Trims leading and trailing whitespace from each entry.\n * - Excludes empty entries.\n * - Returns `undefined` if the environment variable is empty or contains only whitespace.\n * - Returns an empty array if all entries are empty or whitespace.\n *\n * @param {string} key - The name of the environment variable to retrieve.\n * @returns {string[] | undefined} - The list of strings or `undefined`.\n */\nexport function getStringListFromEnv(key: string): string[] | undefined {\n return getStringFromEnv(key)\n ?.split(',')\n .map(v => v.trim())\n .filter(s => s !== '');\n}\n"]}

View File

@@ -0,0 +1,11 @@
export { getStringFromEnv, getBooleanFromEnv, getNumberFromEnv, getStringListFromEnv, } from './environment';
export { _globalThis } from '../../common/globalThis';
export { SDK_INFO } from './sdk-info';
/**
* @deprecated Use performance directly.
*/
export declare const otperformance: {
now(): number;
readonly timeOrigin: number;
};
//# sourceMappingURL=index.d.ts.map

View File

@@ -0,0 +1,21 @@
"use strict";
/*
* Copyright The OpenTelemetry Authors
* SPDX-License-Identifier: Apache-2.0
*/
Object.defineProperty(exports, "__esModule", { value: true });
exports.otperformance = exports.SDK_INFO = exports._globalThis = exports.getStringListFromEnv = exports.getNumberFromEnv = exports.getBooleanFromEnv = exports.getStringFromEnv = void 0;
var environment_1 = require("./environment");
Object.defineProperty(exports, "getStringFromEnv", { enumerable: true, get: function () { return environment_1.getStringFromEnv; } });
Object.defineProperty(exports, "getBooleanFromEnv", { enumerable: true, get: function () { return environment_1.getBooleanFromEnv; } });
Object.defineProperty(exports, "getNumberFromEnv", { enumerable: true, get: function () { return environment_1.getNumberFromEnv; } });
Object.defineProperty(exports, "getStringListFromEnv", { enumerable: true, get: function () { return environment_1.getStringListFromEnv; } });
var globalThis_1 = require("../../common/globalThis");
Object.defineProperty(exports, "_globalThis", { enumerable: true, get: function () { return globalThis_1._globalThis; } });
var sdk_info_1 = require("./sdk-info");
Object.defineProperty(exports, "SDK_INFO", { enumerable: true, get: function () { return sdk_info_1.SDK_INFO; } });
/**
* @deprecated Use performance directly.
*/
exports.otperformance = performance;
//# sourceMappingURL=index.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/platform/node/index.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,6CAKuB;AAJrB,+GAAA,gBAAgB,OAAA;AAChB,gHAAA,iBAAiB,OAAA;AACjB,+GAAA,gBAAgB,OAAA;AAChB,mHAAA,oBAAoB,OAAA;AAEtB,sDAAsD;AAA7C,yGAAA,WAAW,OAAA;AACpB,uCAAsC;AAA7B,oGAAA,QAAQ,OAAA;AAEjB;;GAEG;AACU,QAAA,aAAa,GACxB,WAAW,CAAC","sourcesContent":["/*\n * Copyright The OpenTelemetry Authors\n * SPDX-License-Identifier: Apache-2.0\n */\n\nexport {\n getStringFromEnv,\n getBooleanFromEnv,\n getNumberFromEnv,\n getStringListFromEnv,\n} from './environment';\nexport { _globalThis } from '../../common/globalThis';\nexport { SDK_INFO } from './sdk-info';\n\n/**\n * @deprecated Use performance directly.\n */\nexport const otperformance: { now(): number; readonly timeOrigin: number } =\n performance;\n"]}

View File

@@ -0,0 +1,8 @@
/** Constants describing the SDK in use */
export declare const SDK_INFO: {
"telemetry.sdk.name": string;
"process.runtime.name": string;
"telemetry.sdk.language": "nodejs";
"telemetry.sdk.version": string;
};
//# sourceMappingURL=sdk-info.d.ts.map

View File

@@ -0,0 +1,18 @@
"use strict";
/*
* Copyright The OpenTelemetry Authors
* SPDX-License-Identifier: Apache-2.0
*/
Object.defineProperty(exports, "__esModule", { value: true });
exports.SDK_INFO = void 0;
const version_1 = require("../../version");
const semantic_conventions_1 = require("@opentelemetry/semantic-conventions");
const semconv_1 = require("../../semconv");
/** Constants describing the SDK in use */
exports.SDK_INFO = {
[semantic_conventions_1.ATTR_TELEMETRY_SDK_NAME]: 'opentelemetry',
[semconv_1.ATTR_PROCESS_RUNTIME_NAME]: 'node',
[semantic_conventions_1.ATTR_TELEMETRY_SDK_LANGUAGE]: semantic_conventions_1.TELEMETRY_SDK_LANGUAGE_VALUE_NODEJS,
[semantic_conventions_1.ATTR_TELEMETRY_SDK_VERSION]: version_1.VERSION,
};
//# sourceMappingURL=sdk-info.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"sdk-info.js","sourceRoot":"","sources":["../../../../src/platform/node/sdk-info.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,2CAAwC;AACxC,8EAK6C;AAC7C,2CAA0D;AAE1D,0CAA0C;AAC7B,QAAA,QAAQ,GAAG;IACtB,CAAC,8CAAuB,CAAC,EAAE,eAAe;IAC1C,CAAC,mCAAyB,CAAC,EAAE,MAAM;IACnC,CAAC,kDAA2B,CAAC,EAAE,0DAAmC;IAClE,CAAC,iDAA0B,CAAC,EAAE,iBAAO;CACtC,CAAC","sourcesContent":["/*\n * Copyright The OpenTelemetry Authors\n * SPDX-License-Identifier: Apache-2.0\n */\n\nimport { VERSION } from '../../version';\nimport {\n ATTR_TELEMETRY_SDK_NAME,\n ATTR_TELEMETRY_SDK_LANGUAGE,\n TELEMETRY_SDK_LANGUAGE_VALUE_NODEJS,\n ATTR_TELEMETRY_SDK_VERSION,\n} from '@opentelemetry/semantic-conventions';\nimport { ATTR_PROCESS_RUNTIME_NAME } from '../../semconv';\n\n/** Constants describing the SDK in use */\nexport const SDK_INFO = {\n [ATTR_TELEMETRY_SDK_NAME]: 'opentelemetry',\n [ATTR_PROCESS_RUNTIME_NAME]: 'node',\n [ATTR_TELEMETRY_SDK_LANGUAGE]: TELEMETRY_SDK_LANGUAGE_VALUE_NODEJS,\n [ATTR_TELEMETRY_SDK_VERSION]: VERSION,\n};\n"]}

View File

@@ -0,0 +1,43 @@
import type { Context, TextMapGetter, TextMapPropagator, TextMapSetter } from '@opentelemetry/api';
/** Configuration object for composite propagator */
export interface CompositePropagatorConfig {
/**
* List of propagators to run. Propagators run in the
* list order. If a propagator later in the list writes the same context
* key as a propagator earlier in the list, the later on will "win".
*/
propagators?: TextMapPropagator[];
}
/** Combines multiple propagators into a single propagator. */
export declare class CompositePropagator implements TextMapPropagator {
private readonly _propagators;
private readonly _fields;
/**
* Construct a composite propagator from a list of propagators.
*
* @param [config] Configuration object for composite propagator
*/
constructor(config?: CompositePropagatorConfig);
/**
* Run each of the configured propagators with the given context and carrier.
* Propagators are run in the order they are configured, so if multiple
* propagators write the same carrier key, the propagator later in the list
* will "win".
*
* @param context Context to inject
* @param carrier Carrier into which context will be injected
*/
inject(context: Context, carrier: unknown, setter: TextMapSetter): void;
/**
* Run each of the configured propagators with the given context and carrier.
* Propagators are run in the order they are configured, so if multiple
* propagators write the same context key, the propagator later in the list
* will "win".
*
* @param context Context to add values to
* @param carrier Carrier from which to extract context
*/
extract(context: Context, carrier: unknown, getter: TextMapGetter): Context;
fields(): string[];
}
//# sourceMappingURL=composite.d.ts.map

View File

@@ -0,0 +1,70 @@
"use strict";
/*
* Copyright The OpenTelemetry Authors
* SPDX-License-Identifier: Apache-2.0
*/
Object.defineProperty(exports, "__esModule", { value: true });
exports.CompositePropagator = void 0;
const api_1 = require("@opentelemetry/api");
/** Combines multiple propagators into a single propagator. */
class CompositePropagator {
_propagators;
_fields;
/**
* Construct a composite propagator from a list of propagators.
*
* @param [config] Configuration object for composite propagator
*/
constructor(config = {}) {
this._propagators = config.propagators ?? [];
this._fields = Array.from(new Set(this._propagators
// older propagators may not have fields function, null check to be sure
.map(p => (typeof p.fields === 'function' ? p.fields() : []))
.reduce((x, y) => x.concat(y), [])));
}
/**
* Run each of the configured propagators with the given context and carrier.
* Propagators are run in the order they are configured, so if multiple
* propagators write the same carrier key, the propagator later in the list
* will "win".
*
* @param context Context to inject
* @param carrier Carrier into which context will be injected
*/
inject(context, carrier, setter) {
for (const propagator of this._propagators) {
try {
propagator.inject(context, carrier, setter);
}
catch (err) {
api_1.diag.warn(`Failed to inject with ${propagator.constructor.name}. Err: ${err.message}`);
}
}
}
/**
* Run each of the configured propagators with the given context and carrier.
* Propagators are run in the order they are configured, so if multiple
* propagators write the same context key, the propagator later in the list
* will "win".
*
* @param context Context to add values to
* @param carrier Carrier from which to extract context
*/
extract(context, carrier, getter) {
return this._propagators.reduce((ctx, propagator) => {
try {
return propagator.extract(ctx, carrier, getter);
}
catch (err) {
api_1.diag.warn(`Failed to extract with ${propagator.constructor.name}. Err: ${err.message}`);
}
return ctx;
}, context);
}
fields() {
// return a new array so our fields cannot be modified
return this._fields.slice();
}
}
exports.CompositePropagator = CompositePropagator;
//# sourceMappingURL=composite.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"composite.js","sourceRoot":"","sources":["../../../src/propagation/composite.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAQH,4CAA0C;AAY1C,8DAA8D;AAC9D,MAAa,mBAAmB;IACb,YAAY,CAAsB;IAClC,OAAO,CAAW;IAEnC;;;;OAIG;IACH,YAAY,SAAoC,EAAE;QAChD,IAAI,CAAC,YAAY,GAAG,MAAM,CAAC,WAAW,IAAI,EAAE,CAAC;QAE7C,IAAI,CAAC,OAAO,GAAG,KAAK,CAAC,IAAI,CACvB,IAAI,GAAG,CACL,IAAI,CAAC,YAAY;YACf,wEAAwE;aACvE,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,OAAO,CAAC,CAAC,MAAM,KAAK,UAAU,CAAC,CAAC,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC;aAC5D,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CACrC,CACF,CAAC;IACJ,CAAC;IAED;;;;;;;;OAQG;IACH,MAAM,CAAC,OAAgB,EAAE,OAAgB,EAAE,MAAqB;QAC9D,KAAK,MAAM,UAAU,IAAI,IAAI,CAAC,YAAY,EAAE;YAC1C,IAAI;gBACF,UAAU,CAAC,MAAM,CAAC,OAAO,EAAE,OAAO,EAAE,MAAM,CAAC,CAAC;aAC7C;YAAC,OAAO,GAAG,EAAE;gBACZ,UAAI,CAAC,IAAI,CACP,yBAAyB,UAAU,CAAC,WAAW,CAAC,IAAI,UAAU,GAAG,CAAC,OAAO,EAAE,CAC5E,CAAC;aACH;SACF;IACH,CAAC;IAED;;;;;;;;OAQG;IACH,OAAO,CAAC,OAAgB,EAAE,OAAgB,EAAE,MAAqB;QAC/D,OAAO,IAAI,CAAC,YAAY,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,UAAU,EAAE,EAAE;YAClD,IAAI;gBACF,OAAO,UAAU,CAAC,OAAO,CAAC,GAAG,EAAE,OAAO,EAAE,MAAM,CAAC,CAAC;aACjD;YAAC,OAAO,GAAG,EAAE;gBACZ,UAAI,CAAC,IAAI,CACP,0BAA0B,UAAU,CAAC,WAAW,CAAC,IAAI,UAAU,GAAG,CAAC,OAAO,EAAE,CAC7E,CAAC;aACH;YACD,OAAO,GAAG,CAAC;QACb,CAAC,EAAE,OAAO,CAAC,CAAC;IACd,CAAC;IAED,MAAM;QACJ,sDAAsD;QACtD,OAAO,IAAI,CAAC,OAAO,CAAC,KAAK,EAAE,CAAC;IAC9B,CAAC;CACF;AArED,kDAqEC","sourcesContent":["/*\n * Copyright The OpenTelemetry Authors\n * SPDX-License-Identifier: Apache-2.0\n */\n\nimport type {\n Context,\n TextMapGetter,\n TextMapPropagator,\n TextMapSetter,\n} from '@opentelemetry/api';\nimport { diag } from '@opentelemetry/api';\n\n/** Configuration object for composite propagator */\nexport interface CompositePropagatorConfig {\n /**\n * List of propagators to run. Propagators run in the\n * list order. If a propagator later in the list writes the same context\n * key as a propagator earlier in the list, the later on will \"win\".\n */\n propagators?: TextMapPropagator[];\n}\n\n/** Combines multiple propagators into a single propagator. */\nexport class CompositePropagator implements TextMapPropagator {\n private readonly _propagators: TextMapPropagator[];\n private readonly _fields: string[];\n\n /**\n * Construct a composite propagator from a list of propagators.\n *\n * @param [config] Configuration object for composite propagator\n */\n constructor(config: CompositePropagatorConfig = {}) {\n this._propagators = config.propagators ?? [];\n\n this._fields = Array.from(\n new Set(\n this._propagators\n // older propagators may not have fields function, null check to be sure\n .map(p => (typeof p.fields === 'function' ? p.fields() : []))\n .reduce((x, y) => x.concat(y), [])\n )\n );\n }\n\n /**\n * Run each of the configured propagators with the given context and carrier.\n * Propagators are run in the order they are configured, so if multiple\n * propagators write the same carrier key, the propagator later in the list\n * will \"win\".\n *\n * @param context Context to inject\n * @param carrier Carrier into which context will be injected\n */\n inject(context: Context, carrier: unknown, setter: TextMapSetter): void {\n for (const propagator of this._propagators) {\n try {\n propagator.inject(context, carrier, setter);\n } catch (err) {\n diag.warn(\n `Failed to inject with ${propagator.constructor.name}. Err: ${err.message}`\n );\n }\n }\n }\n\n /**\n * Run each of the configured propagators with the given context and carrier.\n * Propagators are run in the order they are configured, so if multiple\n * propagators write the same context key, the propagator later in the list\n * will \"win\".\n *\n * @param context Context to add values to\n * @param carrier Carrier from which to extract context\n */\n extract(context: Context, carrier: unknown, getter: TextMapGetter): Context {\n return this._propagators.reduce((ctx, propagator) => {\n try {\n return propagator.extract(ctx, carrier, getter);\n } catch (err) {\n diag.warn(\n `Failed to extract with ${propagator.constructor.name}. Err: ${err.message}`\n );\n }\n return ctx;\n }, context);\n }\n\n fields(): string[] {\n // return a new array so our fields cannot be modified\n return this._fields.slice();\n }\n}\n"]}

View File

@@ -0,0 +1,9 @@
/**
* The name of the runtime of this process.
*
* @example OpenJDK Runtime Environment
*
* @experimental This attribute is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`.
*/
export declare const ATTR_PROCESS_RUNTIME_NAME: "process.runtime.name";
//# sourceMappingURL=semconv.d.ts.map

View File

@@ -0,0 +1,21 @@
"use strict";
/*
* Copyright The OpenTelemetry Authors
* SPDX-License-Identifier: Apache-2.0
*/
Object.defineProperty(exports, "__esModule", { value: true });
exports.ATTR_PROCESS_RUNTIME_NAME = void 0;
/*
* This file contains a copy of unstable semantic convention definitions
* used by this package.
* @see https://github.com/open-telemetry/opentelemetry-js/tree/main/semantic-conventions#unstable-semconv
*/
/**
* The name of the runtime of this process.
*
* @example OpenJDK Runtime Environment
*
* @experimental This attribute is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`.
*/
exports.ATTR_PROCESS_RUNTIME_NAME = 'process.runtime.name';
//# sourceMappingURL=semconv.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"semconv.js","sourceRoot":"","sources":["../../src/semconv.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH;;;;GAIG;AAEH;;;;;;GAMG;AACU,QAAA,yBAAyB,GAAG,sBAA+B,CAAC","sourcesContent":["/*\n * Copyright The OpenTelemetry Authors\n * SPDX-License-Identifier: Apache-2.0\n */\n\n/*\n * This file contains a copy of unstable semantic convention definitions\n * used by this package.\n * @see https://github.com/open-telemetry/opentelemetry-js/tree/main/semantic-conventions#unstable-semconv\n */\n\n/**\n * The name of the runtime of this process.\n *\n * @example OpenJDK Runtime Environment\n *\n * @experimental This attribute is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`.\n */\nexport const ATTR_PROCESS_RUNTIME_NAME = 'process.runtime.name' as const;\n"]}

View File

@@ -0,0 +1,22 @@
import type * as api from '@opentelemetry/api';
/**
* TraceState must be a class and not a simple object type because of the spec
* requirement (https://www.w3.org/TR/trace-context/#tracestate-field).
*
* Here is the list of allowed mutations:
* - New key-value pair should be added into the beginning of the list
* - The value of any key can be updated. Modified keys MUST be moved to the
* beginning of the list.
*/
export declare class TraceState implements api.TraceState {
private _internalState;
constructor(rawTraceState?: string);
set(key: string, value: string): TraceState;
unset(key: string): TraceState;
get(key: string): string | undefined;
serialize(): string;
private _parse;
private _keys;
private _clone;
}
//# sourceMappingURL=TraceState.d.ts.map

View File

@@ -0,0 +1,92 @@
"use strict";
/*
* Copyright The OpenTelemetry Authors
* SPDX-License-Identifier: Apache-2.0
*/
Object.defineProperty(exports, "__esModule", { value: true });
exports.TraceState = void 0;
const validators_1 = require("../internal/validators");
const MAX_TRACE_STATE_ITEMS = 32;
const MAX_TRACE_STATE_LEN = 512;
const LIST_MEMBERS_SEPARATOR = ',';
const LIST_MEMBER_KEY_VALUE_SPLITTER = '=';
/**
* TraceState must be a class and not a simple object type because of the spec
* requirement (https://www.w3.org/TR/trace-context/#tracestate-field).
*
* Here is the list of allowed mutations:
* - New key-value pair should be added into the beginning of the list
* - The value of any key can be updated. Modified keys MUST be moved to the
* beginning of the list.
*/
class TraceState {
_internalState = new Map();
constructor(rawTraceState) {
if (rawTraceState)
this._parse(rawTraceState);
}
set(key, value) {
// TODO: Benchmark the different approaches(map vs list) and
// use the faster one.
const traceState = this._clone();
if (traceState._internalState.has(key)) {
traceState._internalState.delete(key);
}
traceState._internalState.set(key, value);
return traceState;
}
unset(key) {
const traceState = this._clone();
traceState._internalState.delete(key);
return traceState;
}
get(key) {
return this._internalState.get(key);
}
serialize() {
return this._keys()
.reduce((agg, key) => {
agg.push(key + LIST_MEMBER_KEY_VALUE_SPLITTER + this.get(key));
return agg;
}, [])
.join(LIST_MEMBERS_SEPARATOR);
}
_parse(rawTraceState) {
if (rawTraceState.length > MAX_TRACE_STATE_LEN)
return;
this._internalState = rawTraceState
.split(LIST_MEMBERS_SEPARATOR)
.reverse() // Store in reverse so new keys (.set(...)) will be placed at the beginning
.reduce((agg, part) => {
const listMember = part.trim(); // Optional Whitespace (OWS) handling
const i = listMember.indexOf(LIST_MEMBER_KEY_VALUE_SPLITTER);
if (i !== -1) {
const key = listMember.slice(0, i);
const value = listMember.slice(i + 1, part.length);
if ((0, validators_1.validateKey)(key) && (0, validators_1.validateValue)(value)) {
agg.set(key, value);
}
else {
// TODO: Consider to add warning log
}
}
return agg;
}, new Map());
// Because of the reverse() requirement, trunc must be done after map is created
if (this._internalState.size > MAX_TRACE_STATE_ITEMS) {
this._internalState = new Map(Array.from(this._internalState.entries())
.reverse() // Use reverse same as original tracestate parse chain
.slice(0, MAX_TRACE_STATE_ITEMS));
}
}
_keys() {
return Array.from(this._internalState.keys()).reverse();
}
_clone() {
const traceState = new TraceState();
traceState._internalState = new Map(this._internalState);
return traceState;
}
}
exports.TraceState = TraceState;
//# sourceMappingURL=TraceState.js.map

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,26 @@
import type { Context, SpanContext, TextMapGetter, TextMapPropagator, TextMapSetter } from '@opentelemetry/api';
export declare const TRACE_PARENT_HEADER = "traceparent";
export declare const TRACE_STATE_HEADER = "tracestate";
/**
* Parses information from the [traceparent] span tag and converts it into {@link SpanContext}
* @param traceParent - A meta property that comes from server.
* It should be dynamically generated server side to have the server's request trace Id,
* a parent span Id that was set on the server's request span,
* and the trace flags to indicate the server's sampling decision
* (01 = sampled, 00 = not sampled).
* for example: '{version}-{traceId}-{spanId}-{sampleDecision}'
* For more information see {@link https://www.w3.org/TR/trace-context/}
*/
export declare function parseTraceParent(traceParent: string): SpanContext | null;
/**
* Propagates {@link SpanContext} through Trace Context format propagation.
*
* Based on the Trace Context specification:
* https://www.w3.org/TR/trace-context/
*/
export declare class W3CTraceContextPropagator implements TextMapPropagator {
inject(context: Context, carrier: unknown, setter: TextMapSetter): void;
extract(context: Context, carrier: unknown, getter: TextMapGetter): Context;
fields(): string[];
}
//# sourceMappingURL=W3CTraceContextPropagator.d.ts.map

View File

@@ -0,0 +1,93 @@
"use strict";
/*
* Copyright The OpenTelemetry Authors
* SPDX-License-Identifier: Apache-2.0
*/
Object.defineProperty(exports, "__esModule", { value: true });
exports.W3CTraceContextPropagator = exports.parseTraceParent = exports.TRACE_STATE_HEADER = exports.TRACE_PARENT_HEADER = void 0;
const api_1 = require("@opentelemetry/api");
const suppress_tracing_1 = require("./suppress-tracing");
const TraceState_1 = require("./TraceState");
exports.TRACE_PARENT_HEADER = 'traceparent';
exports.TRACE_STATE_HEADER = 'tracestate';
const VERSION = '00';
const VERSION_PART = '(?!ff)[\\da-f]{2}';
const TRACE_ID_PART = '(?![0]{32})[\\da-f]{32}';
const PARENT_ID_PART = '(?![0]{16})[\\da-f]{16}';
const FLAGS_PART = '[\\da-f]{2}';
const TRACE_PARENT_REGEX = new RegExp(`^\\s?(${VERSION_PART})-(${TRACE_ID_PART})-(${PARENT_ID_PART})-(${FLAGS_PART})(-.*)?\\s?$`);
/**
* Parses information from the [traceparent] span tag and converts it into {@link SpanContext}
* @param traceParent - A meta property that comes from server.
* It should be dynamically generated server side to have the server's request trace Id,
* a parent span Id that was set on the server's request span,
* and the trace flags to indicate the server's sampling decision
* (01 = sampled, 00 = not sampled).
* for example: '{version}-{traceId}-{spanId}-{sampleDecision}'
* For more information see {@link https://www.w3.org/TR/trace-context/}
*/
function parseTraceParent(traceParent) {
const match = TRACE_PARENT_REGEX.exec(traceParent);
if (!match)
return null;
// According to the specification the implementation should be compatible
// with future versions. If there are more parts, we only reject it if it's using version 00
// See https://www.w3.org/TR/trace-context/#versioning-of-traceparent
if (match[1] === '00' && match[5])
return null;
return {
traceId: match[2],
spanId: match[3],
traceFlags: parseInt(match[4], 16),
};
}
exports.parseTraceParent = parseTraceParent;
/**
* Propagates {@link SpanContext} through Trace Context format propagation.
*
* Based on the Trace Context specification:
* https://www.w3.org/TR/trace-context/
*/
class W3CTraceContextPropagator {
inject(context, carrier, setter) {
const spanContext = api_1.trace.getSpanContext(context);
if (!spanContext ||
(0, suppress_tracing_1.isTracingSuppressed)(context) ||
!(0, api_1.isSpanContextValid)(spanContext))
return;
const traceParent = `${VERSION}-${spanContext.traceId}-${spanContext.spanId}-0${Number(spanContext.traceFlags || api_1.TraceFlags.NONE).toString(16)}`;
setter.set(carrier, exports.TRACE_PARENT_HEADER, traceParent);
if (spanContext.traceState) {
setter.set(carrier, exports.TRACE_STATE_HEADER, spanContext.traceState.serialize());
}
}
extract(context, carrier, getter) {
const traceParentHeader = getter.get(carrier, exports.TRACE_PARENT_HEADER);
if (!traceParentHeader)
return context;
const traceParent = Array.isArray(traceParentHeader)
? traceParentHeader[0]
: traceParentHeader;
if (typeof traceParent !== 'string')
return context;
const spanContext = parseTraceParent(traceParent);
if (!spanContext)
return context;
spanContext.isRemote = true;
const traceStateHeader = getter.get(carrier, exports.TRACE_STATE_HEADER);
if (traceStateHeader) {
// If more than one `tracestate` header is found, we merge them into a
// single header.
const state = Array.isArray(traceStateHeader)
? traceStateHeader.join(',')
: traceStateHeader;
spanContext.traceState = new TraceState_1.TraceState(typeof state === 'string' ? state : undefined);
}
return api_1.trace.setSpanContext(context, spanContext);
}
fields() {
return [exports.TRACE_PARENT_HEADER, exports.TRACE_STATE_HEADER];
}
}
exports.W3CTraceContextPropagator = W3CTraceContextPropagator;
//# sourceMappingURL=W3CTraceContextPropagator.js.map

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,18 @@
import type { Context, Span } from '@opentelemetry/api';
export declare enum RPCType {
HTTP = "http"
}
type HTTPMetadata = {
type: RPCType.HTTP;
route?: string;
span: Span;
};
/**
* Allows for future rpc metadata to be used with this mechanism
*/
export type RPCMetadata = HTTPMetadata;
export declare function setRPCMetadata(context: Context, meta: RPCMetadata): Context;
export declare function deleteRPCMetadata(context: Context): Context;
export declare function getRPCMetadata(context: Context): RPCMetadata | undefined;
export {};
//# sourceMappingURL=rpc-metadata.d.ts.map

View File

@@ -0,0 +1,26 @@
"use strict";
/*
* Copyright The OpenTelemetry Authors
* SPDX-License-Identifier: Apache-2.0
*/
Object.defineProperty(exports, "__esModule", { value: true });
exports.getRPCMetadata = exports.deleteRPCMetadata = exports.setRPCMetadata = exports.RPCType = void 0;
const api_1 = require("@opentelemetry/api");
const RPC_METADATA_KEY = (0, api_1.createContextKey)('OpenTelemetry SDK Context Key RPC_METADATA');
var RPCType;
(function (RPCType) {
RPCType["HTTP"] = "http";
})(RPCType = exports.RPCType || (exports.RPCType = {}));
function setRPCMetadata(context, meta) {
return context.setValue(RPC_METADATA_KEY, meta);
}
exports.setRPCMetadata = setRPCMetadata;
function deleteRPCMetadata(context) {
return context.deleteValue(RPC_METADATA_KEY);
}
exports.deleteRPCMetadata = deleteRPCMetadata;
function getRPCMetadata(context) {
return context.getValue(RPC_METADATA_KEY);
}
exports.getRPCMetadata = getRPCMetadata;
//# sourceMappingURL=rpc-metadata.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"rpc-metadata.js","sourceRoot":"","sources":["../../../src/trace/rpc-metadata.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAGH,4CAAsD;AAEtD,MAAM,gBAAgB,GAAG,IAAA,sBAAgB,EACvC,4CAA4C,CAC7C,CAAC;AAEF,IAAY,OAEX;AAFD,WAAY,OAAO;IACjB,wBAAa,CAAA;AACf,CAAC,EAFW,OAAO,GAAP,eAAO,KAAP,eAAO,QAElB;AAaD,SAAgB,cAAc,CAAC,OAAgB,EAAE,IAAiB;IAChE,OAAO,OAAO,CAAC,QAAQ,CAAC,gBAAgB,EAAE,IAAI,CAAC,CAAC;AAClD,CAAC;AAFD,wCAEC;AAED,SAAgB,iBAAiB,CAAC,OAAgB;IAChD,OAAO,OAAO,CAAC,WAAW,CAAC,gBAAgB,CAAC,CAAC;AAC/C,CAAC;AAFD,8CAEC;AAED,SAAgB,cAAc,CAAC,OAAgB;IAC7C,OAAO,OAAO,CAAC,QAAQ,CAAC,gBAAgB,CAA4B,CAAC;AACvE,CAAC;AAFD,wCAEC","sourcesContent":["/*\n * Copyright The OpenTelemetry Authors\n * SPDX-License-Identifier: Apache-2.0\n */\n\nimport type { Context, Span } from '@opentelemetry/api';\nimport { createContextKey } from '@opentelemetry/api';\n\nconst RPC_METADATA_KEY = createContextKey(\n 'OpenTelemetry SDK Context Key RPC_METADATA'\n);\n\nexport enum RPCType {\n HTTP = 'http',\n}\n\ntype HTTPMetadata = {\n type: RPCType.HTTP;\n route?: string;\n span: Span;\n};\n\n/**\n * Allows for future rpc metadata to be used with this mechanism\n */\nexport type RPCMetadata = HTTPMetadata;\n\nexport function setRPCMetadata(context: Context, meta: RPCMetadata): Context {\n return context.setValue(RPC_METADATA_KEY, meta);\n}\n\nexport function deleteRPCMetadata(context: Context): Context {\n return context.deleteValue(RPC_METADATA_KEY);\n}\n\nexport function getRPCMetadata(context: Context): RPCMetadata | undefined {\n return context.getValue(RPC_METADATA_KEY) as RPCMetadata | undefined;\n}\n"]}

View File

@@ -0,0 +1,5 @@
import type { Context } from '@opentelemetry/api';
export declare function suppressTracing(context: Context): Context;
export declare function unsuppressTracing(context: Context): Context;
export declare function isTracingSuppressed(context: Context): boolean;
//# sourceMappingURL=suppress-tracing.d.ts.map

View File

@@ -0,0 +1,22 @@
"use strict";
/*
* Copyright The OpenTelemetry Authors
* SPDX-License-Identifier: Apache-2.0
*/
Object.defineProperty(exports, "__esModule", { value: true });
exports.isTracingSuppressed = exports.unsuppressTracing = exports.suppressTracing = void 0;
const api_1 = require("@opentelemetry/api");
const SUPPRESS_TRACING_KEY = (0, api_1.createContextKey)('OpenTelemetry SDK Context Key SUPPRESS_TRACING');
function suppressTracing(context) {
return context.setValue(SUPPRESS_TRACING_KEY, true);
}
exports.suppressTracing = suppressTracing;
function unsuppressTracing(context) {
return context.deleteValue(SUPPRESS_TRACING_KEY);
}
exports.unsuppressTracing = unsuppressTracing;
function isTracingSuppressed(context) {
return context.getValue(SUPPRESS_TRACING_KEY) === true;
}
exports.isTracingSuppressed = isTracingSuppressed;
//# sourceMappingURL=suppress-tracing.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"suppress-tracing.js","sourceRoot":"","sources":["../../../src/trace/suppress-tracing.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAGH,4CAAsD;AAEtD,MAAM,oBAAoB,GAAG,IAAA,sBAAgB,EAC3C,gDAAgD,CACjD,CAAC;AAEF,SAAgB,eAAe,CAAC,OAAgB;IAC9C,OAAO,OAAO,CAAC,QAAQ,CAAC,oBAAoB,EAAE,IAAI,CAAC,CAAC;AACtD,CAAC;AAFD,0CAEC;AAED,SAAgB,iBAAiB,CAAC,OAAgB;IAChD,OAAO,OAAO,CAAC,WAAW,CAAC,oBAAoB,CAAC,CAAC;AACnD,CAAC;AAFD,8CAEC;AAED,SAAgB,mBAAmB,CAAC,OAAgB;IAClD,OAAO,OAAO,CAAC,QAAQ,CAAC,oBAAoB,CAAC,KAAK,IAAI,CAAC;AACzD,CAAC;AAFD,kDAEC","sourcesContent":["/*\n * Copyright The OpenTelemetry Authors\n * SPDX-License-Identifier: Apache-2.0\n */\n\nimport type { Context } from '@opentelemetry/api';\nimport { createContextKey } from '@opentelemetry/api';\n\nconst SUPPRESS_TRACING_KEY = createContextKey(\n 'OpenTelemetry SDK Context Key SUPPRESS_TRACING'\n);\n\nexport function suppressTracing(context: Context): Context {\n return context.setValue(SUPPRESS_TRACING_KEY, true);\n}\n\nexport function unsuppressTracing(context: Context): Context {\n return context.deleteValue(SUPPRESS_TRACING_KEY);\n}\n\nexport function isTracingSuppressed(context: Context): boolean {\n return context.getValue(SUPPRESS_TRACING_KEY) === true;\n}\n"]}

View File

@@ -0,0 +1,14 @@
/**
* Bind the callback and only invoke the callback once regardless how many times `BindOnceFuture.call` is invoked.
*/
export declare class BindOnceFuture<R, This = unknown, T extends (this: This, ...args: unknown[]) => R = () => R> {
private _isCalled;
private _deferred;
private _callback;
private _that;
constructor(callback: T, that: This);
get isCalled(): boolean;
get promise(): Promise<R>;
call(...args: Parameters<T>): Promise<R>;
}
//# sourceMappingURL=callback.d.ts.map

View File

@@ -0,0 +1,41 @@
"use strict";
/*
* Copyright The OpenTelemetry Authors
* SPDX-License-Identifier: Apache-2.0
*/
Object.defineProperty(exports, "__esModule", { value: true });
exports.BindOnceFuture = void 0;
const promise_1 = require("./promise");
/**
* Bind the callback and only invoke the callback once regardless how many times `BindOnceFuture.call` is invoked.
*/
class BindOnceFuture {
_isCalled = false;
_deferred = new promise_1.Deferred();
_callback;
_that;
constructor(callback, that) {
this._callback = callback;
this._that = that;
}
get isCalled() {
return this._isCalled;
}
get promise() {
return this._deferred.promise;
}
call(...args) {
if (!this._isCalled) {
this._isCalled = true;
try {
Promise.resolve(this._callback.call(this._that, ...args)).then(val => this._deferred.resolve(val), err => this._deferred.reject(err));
}
catch (err) {
this._deferred.reject(err);
}
}
return this._deferred.promise;
}
}
exports.BindOnceFuture = BindOnceFuture;
//# sourceMappingURL=callback.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"callback.js","sourceRoot":"","sources":["../../../src/utils/callback.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,uCAAqC;AAErC;;GAEG;AACH,MAAa,cAAc;IAKjB,SAAS,GAAG,KAAK,CAAC;IAClB,SAAS,GAAG,IAAI,kBAAQ,EAAK,CAAC;IAC9B,SAAS,CAAI;IACb,KAAK,CAAO;IAEpB,YAAY,QAAW,EAAE,IAAU;QACjC,IAAI,CAAC,SAAS,GAAG,QAAQ,CAAC;QAC1B,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC;IACpB,CAAC;IAED,IAAI,QAAQ;QACV,OAAO,IAAI,CAAC,SAAS,CAAC;IACxB,CAAC;IAED,IAAI,OAAO;QACT,OAAO,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC;IAChC,CAAC;IAED,IAAI,CAAC,GAAG,IAAmB;QACzB,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE;YACnB,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC;YACtB,IAAI;gBACF,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,EAAE,GAAG,IAAI,CAAC,CAAC,CAAC,IAAI,CAC5D,GAAG,CAAC,EAAE,CAAC,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,GAAG,CAAC,EAClC,GAAG,CAAC,EAAE,CAAC,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,GAAG,CAAC,CAClC,CAAC;aACH;YAAC,OAAO,GAAG,EAAE;gBACZ,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;aAC5B;SACF;QACD,OAAO,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC;IAChC,CAAC;CACF;AArCD,wCAqCC","sourcesContent":["/*\n * Copyright The OpenTelemetry Authors\n * SPDX-License-Identifier: Apache-2.0\n */\n\nimport { Deferred } from './promise';\n\n/**\n * Bind the callback and only invoke the callback once regardless how many times `BindOnceFuture.call` is invoked.\n */\nexport class BindOnceFuture<\n R,\n This = unknown,\n T extends (this: This, ...args: unknown[]) => R = () => R,\n> {\n private _isCalled = false;\n private _deferred = new Deferred<R>();\n private _callback: T;\n private _that: This;\n\n constructor(callback: T, that: This) {\n this._callback = callback;\n this._that = that;\n }\n\n get isCalled() {\n return this._isCalled;\n }\n\n get promise() {\n return this._deferred.promise;\n }\n\n call(...args: Parameters<T>): Promise<R> {\n if (!this._isCalled) {\n this._isCalled = true;\n try {\n Promise.resolve(this._callback.call(this._that, ...args)).then(\n val => this._deferred.resolve(val),\n err => this._deferred.reject(err)\n );\n } catch (err) {\n this._deferred.reject(err);\n }\n }\n return this._deferred.promise;\n }\n}\n"]}

View File

@@ -0,0 +1,7 @@
import { DiagLogLevel } from '@opentelemetry/api';
/**
* Convert a string to a {@link DiagLogLevel}, defaults to {@link DiagLogLevel} if the log level does not exist or undefined if the input is undefined.
* @param value
*/
export declare function diagLogLevelFromString(value: string | undefined): DiagLogLevel | undefined;
//# sourceMappingURL=configuration.d.ts.map

View File

@@ -0,0 +1,35 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.diagLogLevelFromString = void 0;
/*
* Copyright The OpenTelemetry Authors
* SPDX-License-Identifier: Apache-2.0
*/
const api_1 = require("@opentelemetry/api");
const logLevelMap = {
ALL: api_1.DiagLogLevel.ALL,
VERBOSE: api_1.DiagLogLevel.VERBOSE,
DEBUG: api_1.DiagLogLevel.DEBUG,
INFO: api_1.DiagLogLevel.INFO,
WARN: api_1.DiagLogLevel.WARN,
ERROR: api_1.DiagLogLevel.ERROR,
NONE: api_1.DiagLogLevel.NONE,
};
/**
* Convert a string to a {@link DiagLogLevel}, defaults to {@link DiagLogLevel} if the log level does not exist or undefined if the input is undefined.
* @param value
*/
function diagLogLevelFromString(value) {
if (value == null) {
// don't fall back to default - no value set has different semantics for ús than an incorrect value (do not set vs. fall back to default)
return undefined;
}
const resolvedLogLevel = logLevelMap[value.toUpperCase()];
if (resolvedLogLevel == null) {
api_1.diag.warn(`Unknown log level "${value}", expected one of ${Object.keys(logLevelMap)}, using default`);
return api_1.DiagLogLevel.INFO;
}
return resolvedLogLevel;
}
exports.diagLogLevelFromString = diagLogLevelFromString;
//# sourceMappingURL=configuration.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"configuration.js","sourceRoot":"","sources":["../../../src/utils/configuration.ts"],"names":[],"mappings":";;;AAAA;;;GAGG;AACH,4CAAwD;AAExD,MAAM,WAAW,GAAoC;IACnD,GAAG,EAAE,kBAAY,CAAC,GAAG;IACrB,OAAO,EAAE,kBAAY,CAAC,OAAO;IAC7B,KAAK,EAAE,kBAAY,CAAC,KAAK;IACzB,IAAI,EAAE,kBAAY,CAAC,IAAI;IACvB,IAAI,EAAE,kBAAY,CAAC,IAAI;IACvB,KAAK,EAAE,kBAAY,CAAC,KAAK;IACzB,IAAI,EAAE,kBAAY,CAAC,IAAI;CACxB,CAAC;AAEF;;;GAGG;AACH,SAAgB,sBAAsB,CACpC,KAAyB;IAEzB,IAAI,KAAK,IAAI,IAAI,EAAE;QACjB,yIAAyI;QACzI,OAAO,SAAS,CAAC;KAClB;IAED,MAAM,gBAAgB,GAAG,WAAW,CAAC,KAAK,CAAC,WAAW,EAAE,CAAC,CAAC;IAE1D,IAAI,gBAAgB,IAAI,IAAI,EAAE;QAC5B,UAAI,CAAC,IAAI,CACP,sBAAsB,KAAK,sBAAsB,MAAM,CAAC,IAAI,CAAC,WAAW,CAAC,iBAAiB,CAC3F,CAAC;QACF,OAAO,kBAAY,CAAC,IAAI,CAAC;KAC1B;IAED,OAAO,gBAAgB,CAAC;AAC1B,CAAC;AAlBD,wDAkBC","sourcesContent":["/*\n * Copyright The OpenTelemetry Authors\n * SPDX-License-Identifier: Apache-2.0\n */\nimport { diag, DiagLogLevel } from '@opentelemetry/api';\n\nconst logLevelMap: { [key: string]: DiagLogLevel } = {\n ALL: DiagLogLevel.ALL,\n VERBOSE: DiagLogLevel.VERBOSE,\n DEBUG: DiagLogLevel.DEBUG,\n INFO: DiagLogLevel.INFO,\n WARN: DiagLogLevel.WARN,\n ERROR: DiagLogLevel.ERROR,\n NONE: DiagLogLevel.NONE,\n};\n\n/**\n * Convert a string to a {@link DiagLogLevel}, defaults to {@link DiagLogLevel} if the log level does not exist or undefined if the input is undefined.\n * @param value\n */\nexport function diagLogLevelFromString(\n value: string | undefined\n): DiagLogLevel | undefined {\n if (value == null) {\n // don't fall back to default - no value set has different semantics for ús than an incorrect value (do not set vs. fall back to default)\n return undefined;\n }\n\n const resolvedLogLevel = logLevelMap[value.toUpperCase()];\n\n if (resolvedLogLevel == null) {\n diag.warn(\n `Unknown log level \"${value}\", expected one of ${Object.keys(logLevelMap)}, using default`\n );\n return DiagLogLevel.INFO;\n }\n\n return resolvedLogLevel;\n}\n"]}

View File

@@ -0,0 +1,30 @@
/**
* Checks if `value` is a plain object, that is, an object created by the
* `Object` constructor or one with a `[[Prototype]]` of `null`.
*
* @static
* @memberOf _
* @since 0.8.0
* @category Lang
* @param {*} value The value to check.
* @returns {boolean} Returns `true` if `value` is a plain object, else `false`.
* @example
*
* function Foo() {
* this.a = 1;
* }
*
* _.isPlainObject(new Foo);
* // => false
*
* _.isPlainObject([1, 2, 3]);
* // => false
*
* _.isPlainObject({ 'x': 0, 'y': 0 });
* // => true
*
* _.isPlainObject(Object.create(null));
* // => true
*/
export declare function isPlainObject(value: any): boolean;
//# sourceMappingURL=lodash.merge.d.ts.map

View File

@@ -0,0 +1,146 @@
"use strict";
/*
* Copyright The OpenTelemetry Authors
* SPDX-License-Identifier: Apache-2.0
*/
Object.defineProperty(exports, "__esModule", { value: true });
exports.isPlainObject = void 0;
/* eslint-disable @typescript-eslint/no-explicit-any */
/**
* based on lodash in order to support esm builds without esModuleInterop.
* lodash is using MIT License.
**/
const objectTag = '[object Object]';
const nullTag = '[object Null]';
const undefinedTag = '[object Undefined]';
const funcProto = Function.prototype;
const funcToString = funcProto.toString;
const objectCtorString = funcToString.call(Object);
const getPrototypeOf = Object.getPrototypeOf;
const objectProto = Object.prototype;
const hasOwnProperty = objectProto.hasOwnProperty;
const symToStringTag = Symbol ? Symbol.toStringTag : undefined;
const nativeObjectToString = objectProto.toString;
/**
* Checks if `value` is a plain object, that is, an object created by the
* `Object` constructor or one with a `[[Prototype]]` of `null`.
*
* @static
* @memberOf _
* @since 0.8.0
* @category Lang
* @param {*} value The value to check.
* @returns {boolean} Returns `true` if `value` is a plain object, else `false`.
* @example
*
* function Foo() {
* this.a = 1;
* }
*
* _.isPlainObject(new Foo);
* // => false
*
* _.isPlainObject([1, 2, 3]);
* // => false
*
* _.isPlainObject({ 'x': 0, 'y': 0 });
* // => true
*
* _.isPlainObject(Object.create(null));
* // => true
*/
function isPlainObject(value) {
if (!isObjectLike(value) || baseGetTag(value) !== objectTag) {
return false;
}
const proto = getPrototypeOf(value);
if (proto === null) {
return true;
}
const Ctor = hasOwnProperty.call(proto, 'constructor') && proto.constructor;
return (typeof Ctor == 'function' &&
Ctor instanceof Ctor &&
funcToString.call(Ctor) === objectCtorString);
}
exports.isPlainObject = isPlainObject;
/**
* Checks if `value` is object-like. A value is object-like if it's not `null`
* and has a `typeof` result of "object".
*
* @static
* @memberOf _
* @since 4.0.0
* @category Lang
* @param {*} value The value to check.
* @returns {boolean} Returns `true` if `value` is object-like, else `false`.
* @example
*
* _.isObjectLike({});
* // => true
*
* _.isObjectLike([1, 2, 3]);
* // => true
*
* _.isObjectLike(_.noop);
* // => false
*
* _.isObjectLike(null);
* // => false
*/
function isObjectLike(value) {
return value != null && typeof value == 'object';
}
/**
* The base implementation of `getTag` without fallbacks for buggy environments.
*
* @private
* @param {*} value The value to query.
* @returns {string} Returns the `toStringTag`.
*/
function baseGetTag(value) {
if (value == null) {
return value === undefined ? undefinedTag : nullTag;
}
return symToStringTag && symToStringTag in Object(value)
? getRawTag(value)
: objectToString(value);
}
/**
* A specialized version of `baseGetTag` which ignores `Symbol.toStringTag` values.
*
* @private
* @param {*} value The value to query.
* @returns {string} Returns the raw `toStringTag`.
*/
function getRawTag(value) {
const isOwn = hasOwnProperty.call(value, symToStringTag), tag = value[symToStringTag];
let unmasked = false;
try {
value[symToStringTag] = undefined;
unmasked = true;
}
catch {
// silence
}
const result = nativeObjectToString.call(value);
if (unmasked) {
if (isOwn) {
value[symToStringTag] = tag;
}
else {
delete value[symToStringTag];
}
}
return result;
}
/**
* Converts `value` to a string using `Object.prototype.toString`.
*
* @private
* @param {*} value The value to convert.
* @returns {string} Returns the converted string.
*/
function objectToString(value) {
return nativeObjectToString.call(value);
}
//# sourceMappingURL=lodash.merge.js.map

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,6 @@
/**
* Merges objects together
* @param args - objects / values to be merged
*/
export declare function merge(...args: any[]): any;
//# sourceMappingURL=merge.d.ts.map

View File

@@ -0,0 +1,151 @@
"use strict";
/*
* Copyright The OpenTelemetry Authors
* SPDX-License-Identifier: Apache-2.0
*/
Object.defineProperty(exports, "__esModule", { value: true });
exports.merge = void 0;
/* eslint-disable @typescript-eslint/no-explicit-any */
const lodash_merge_1 = require("./lodash.merge");
const MAX_LEVEL = 20;
/**
* Merges objects together
* @param args - objects / values to be merged
*/
function merge(...args) {
let result = args.shift();
const objects = new WeakMap();
while (args.length > 0) {
result = mergeTwoObjects(result, args.shift(), 0, objects);
}
return result;
}
exports.merge = merge;
function takeValue(value) {
if (isArray(value)) {
return value.slice();
}
return value;
}
/**
* Merges two objects
* @param one - first object
* @param two - second object
* @param level - current deep level
* @param objects - objects holder that has been already referenced - to prevent
* cyclic dependency
*/
function mergeTwoObjects(one, two, level = 0, objects) {
let result;
if (level > MAX_LEVEL) {
return undefined;
}
level++;
if (isPrimitive(one) || isPrimitive(two) || isFunction(two)) {
result = takeValue(two);
}
else if (isArray(one)) {
result = one.slice();
if (isArray(two)) {
for (let i = 0, j = two.length; i < j; i++) {
result.push(takeValue(two[i]));
}
}
else if (isObject(two)) {
const keys = Object.keys(two);
for (let i = 0, j = keys.length; i < j; i++) {
const key = keys[i];
result[key] = takeValue(two[key]);
}
}
}
else if (isObject(one)) {
if (isObject(two)) {
if (!shouldMerge(one, two)) {
return two;
}
result = Object.assign({}, one);
const keys = Object.keys(two);
for (let i = 0, j = keys.length; i < j; i++) {
const key = keys[i];
const twoValue = two[key];
if (isPrimitive(twoValue)) {
if (typeof twoValue === 'undefined') {
delete result[key];
}
else {
// result[key] = takeValue(twoValue);
result[key] = twoValue;
}
}
else {
const obj1 = result[key];
const obj2 = twoValue;
if (wasObjectReferenced(one, key, objects) ||
wasObjectReferenced(two, key, objects)) {
delete result[key];
}
else {
if (isObject(obj1) && isObject(obj2)) {
const arr1 = objects.get(obj1) || [];
const arr2 = objects.get(obj2) || [];
arr1.push({ obj: one, key });
arr2.push({ obj: two, key });
objects.set(obj1, arr1);
objects.set(obj2, arr2);
}
result[key] = mergeTwoObjects(result[key], twoValue, level, objects);
}
}
}
}
else {
result = two;
}
}
return result;
}
/**
* Function to check if object has been already reference
* @param obj
* @param key
* @param objects
*/
function wasObjectReferenced(obj, key, objects) {
const arr = objects.get(obj[key]) || [];
for (let i = 0, j = arr.length; i < j; i++) {
const info = arr[i];
if (info.key === key && info.obj === obj) {
return true;
}
}
return false;
}
function isArray(value) {
return Array.isArray(value);
}
function isFunction(value) {
return typeof value === 'function';
}
function isObject(value) {
return (!isPrimitive(value) &&
!isArray(value) &&
!isFunction(value) &&
typeof value === 'object');
}
function isPrimitive(value) {
return (typeof value === 'string' ||
typeof value === 'number' ||
typeof value === 'boolean' ||
typeof value === 'undefined' ||
value instanceof Date ||
value instanceof RegExp ||
value === null);
}
function shouldMerge(one, two) {
if (!(0, lodash_merge_1.isPlainObject)(one) || !(0, lodash_merge_1.isPlainObject)(two)) {
return false;
}
return true;
}
//# sourceMappingURL=merge.js.map

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,10 @@
export declare class Deferred<T> {
private _promise;
private _resolve;
private _reject;
constructor();
get promise(): Promise<T>;
resolve(val: T): void;
reject(err: unknown): void;
}
//# sourceMappingURL=promise.d.ts.map

View File

@@ -0,0 +1,29 @@
"use strict";
/*
* Copyright The OpenTelemetry Authors
* SPDX-License-Identifier: Apache-2.0
*/
Object.defineProperty(exports, "__esModule", { value: true });
exports.Deferred = void 0;
class Deferred {
_promise;
_resolve;
_reject;
constructor() {
this._promise = new Promise((resolve, reject) => {
this._resolve = resolve;
this._reject = reject;
});
}
get promise() {
return this._promise;
}
resolve(val) {
this._resolve(val);
}
reject(err) {
this._reject(err);
}
}
exports.Deferred = Deferred;
//# sourceMappingURL=promise.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"promise.js","sourceRoot":"","sources":["../../../src/utils/promise.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,MAAa,QAAQ;IACX,QAAQ,CAAa;IACrB,QAAQ,CAAoB;IAC5B,OAAO,CAA4B;IAC3C;QACE,IAAI,CAAC,QAAQ,GAAG,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;YAC9C,IAAI,CAAC,QAAQ,GAAG,OAAO,CAAC;YACxB,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC;QACxB,CAAC,CAAC,CAAC;IACL,CAAC;IAED,IAAI,OAAO;QACT,OAAO,IAAI,CAAC,QAAQ,CAAC;IACvB,CAAC;IAED,OAAO,CAAC,GAAM;QACZ,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC;IACrB,CAAC;IAED,MAAM,CAAC,GAAY;QACjB,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;IACpB,CAAC;CACF;AAtBD,4BAsBC","sourcesContent":["/*\n * Copyright The OpenTelemetry Authors\n * SPDX-License-Identifier: Apache-2.0\n */\n\nexport class Deferred<T> {\n private _promise: Promise<T>;\n private _resolve!: (val: T) => void;\n private _reject!: (error: unknown) => void;\n constructor() {\n this._promise = new Promise((resolve, reject) => {\n this._resolve = resolve;\n this._reject = reject;\n });\n }\n\n get promise() {\n return this._promise;\n }\n\n resolve(val: T) {\n this._resolve(val);\n }\n\n reject(err: unknown) {\n this._reject(err);\n }\n}\n"]}

View File

@@ -0,0 +1,17 @@
/**
* Error that is thrown on timeouts.
*/
export declare class TimeoutError extends Error {
constructor(message?: string);
}
/**
* Adds a timeout to a promise and rejects if the specified timeout has elapsed. Also rejects if the specified promise
* rejects, and resolves if the specified promise resolves.
*
* <p> NOTE: this operation will continue even after it throws a {@link TimeoutError}.
*
* @param promise promise to use with timeout.
* @param timeout the timeout in milliseconds until the returned promise is rejected.
*/
export declare function callWithTimeout<T>(promise: Promise<T>, timeout: number): Promise<T>;
//# sourceMappingURL=timeout.d.ts.map

Some files were not shown because too many files have changed in this diff Show More