Update test framework: fix run_tests.py to support all test files, add auto-import-check for test files

This commit is contained in:
qiaoxinjiu
2026-05-09 15:11:30 +08:00
parent eb053a347f
commit eaba8328da
21739 changed files with 2236758 additions and 719 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,24 @@
"use strict";
/*
* Copyright The OpenTelemetry Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
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;;;;;;;;;;;;;;GAcG;;;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 *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\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,30 @@
"use strict";
/*
* Copyright The OpenTelemetry Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
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;;;;;;;;;;;;;;GAcG;;;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 *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\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 { 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,76 @@
"use strict";
/*
* Copyright The OpenTelemetry Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
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;;;;;;;;;;;;;;GAcG;;;AAEH,4CAO4B;AAE5B,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 *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport {\n BaggageEntry,\n Context,\n propagation,\n TextMapGetter,\n TextMapPropagator,\n TextMapSetter,\n} 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 { 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,79 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.parseKeyPairsIntoRecord = exports.parsePairKeyValue = exports.getKeyPairs = exports.serializeKeyPairs = void 0;
/*
* Copyright The OpenTelemetry Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
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) {
const valueProps = entry.split(constants_1.BAGGAGE_PROPERTIES_SEPARATOR);
if (valueProps.length <= 0)
return;
const keyPairPart = valueProps.shift();
if (!keyPairPart)
return;
const separatorIndex = keyPairPart.indexOf(constants_1.BAGGAGE_KEY_PAIR_SEPARATOR);
if (separatorIndex <= 0)
return;
const key = decodeURIComponent(keyPairPart.substring(0, separatorIndex).trim());
const value = decodeURIComponent(keyPairPart.substring(separatorIndex + 1).trim());
let metadata;
if (valueProps.length > 0) {
metadata = (0, api_1.baggageEntryMetadataFromString)(valueProps.join(constants_1.BAGGAGE_PROPERTIES_SEPARATOR));
}
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) {
if (typeof value !== 'string' || value.length === 0)
return {};
return value
.split(constants_1.BAGGAGE_ITEMS_SEPARATOR)
.map(entry => {
return parsePairKeyValue(entry);
})
.filter(keyPair => keyPair !== undefined && keyPair.value.length > 0)
.reduce((headers, keyPair) => {
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
headers[keyPair.key] = keyPair.value;
return headers;
}, {});
}
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,61 @@
"use strict";
/*
* Copyright The OpenTelemetry Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
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;;;;;;;;;;;;;;GAcG;;;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 *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\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 { 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,88 @@
"use strict";
/*
* Copyright The OpenTelemetry Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
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, val] of Object.entries(attributes)) {
if (!isAttributeKey(key)) {
api_1.diag.warn(`Invalid attribute key: ${key}`);
continue;
}
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.length > 0;
}
exports.isAttributeKey = isAttributeKey;
function isAttributeValue(val) {
if (val == null) {
return true;
}
if (Array.isArray(val)) {
return isHomogeneousAttributeValueArray(val);
}
return isValidPrimitiveAttributeValue(val);
}
exports.isAttributeValue = isAttributeValue;
function isHomogeneousAttributeValueArray(arr) {
let type;
for (const element of arr) {
// null/undefined elements are allowed
if (element == null)
continue;
if (!type) {
if (isValidPrimitiveAttributeValue(element)) {
type = typeof element;
continue;
}
// encountered an invalid primitive
return false;
}
if (typeof element === type) {
continue;
}
return false;
}
return true;
}
function isValidPrimitiveAttributeValue(val) {
switch (typeof val) {
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;;;;;;;;;;;;;;GAcG;;;AAEH,4CAAsE;AAEtE,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,CAAC,GAAG,EAAE,GAAG,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,UAAU,CAAC,EAAE;QACnD,IAAI,CAAC,cAAc,CAAC,GAAG,CAAC,EAAE;YACxB,UAAI,CAAC,IAAI,CAAC,0BAA0B,GAAG,EAAE,CAAC,CAAC;YAC3C,SAAS;SACV;QACD,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;AAxBD,gDAwBC;AAED,SAAgB,cAAc,CAAC,GAAY;IACzC,OAAO,OAAO,GAAG,KAAK,QAAQ,IAAI,GAAG,CAAC,MAAM,GAAG,CAAC,CAAC;AACnD,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,8BAA8B,CAAC,GAAG,CAAC,CAAC;AAC7C,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;QAE9B,IAAI,CAAC,IAAI,EAAE;YACT,IAAI,8BAA8B,CAAC,OAAO,CAAC,EAAE;gBAC3C,IAAI,GAAG,OAAO,OAAO,CAAC;gBACtB,SAAS;aACV;YACD,mCAAmC;YACnC,OAAO,KAAK,CAAC;SACd;QAED,IAAI,OAAO,OAAO,KAAK,IAAI,EAAE;YAC3B,SAAS;SACV;QAED,OAAO,KAAK,CAAC;KACd;IAED,OAAO,IAAI,CAAC;AACd,CAAC;AAED,SAAS,8BAA8B,CAAC,GAAY;IAClD,QAAQ,OAAO,GAAG,EAAE;QAClB,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 *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { diag, AttributeValue, Attributes } 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, val] of Object.entries(attributes)) {\n if (!isAttributeKey(key)) {\n diag.warn(`Invalid attribute key: ${key}`);\n continue;\n }\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.length > 0;\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 isValidPrimitiveAttributeValue(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\n if (!type) {\n if (isValidPrimitiveAttributeValue(element)) {\n type = typeof element;\n continue;\n }\n // encountered an invalid primitive\n return false;\n }\n\n if (typeof element === type) {\n continue;\n }\n\n return false;\n }\n\n return true;\n}\n\nfunction isValidPrimitiveAttributeValue(val: unknown): boolean {\n switch (typeof val) {\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 { Exception } from '@opentelemetry/api';
import { 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,41 @@
"use strict";
/*
* Copyright The OpenTelemetry Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
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;;;;;;;;;;;;;;GAcG;;;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 *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { Exception } from '@opentelemetry/api';\nimport { loggingErrorHandler } from './logging-error-handler';\nimport { 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,7 @@
import { 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,63 @@
"use strict";
/*
* Copyright The OpenTelemetry Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
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;;;;;;;;;;;;;;GAcG;;;AAEH,4CAAqD;AAGrD;;;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 *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { diag, Exception } from '@opentelemetry/api';\nimport { 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,59 @@
import * as api from '@opentelemetry/api';
/**
* Converts a number of milliseconds from epoch to HrTime([seconds, remainder in nanoseconds]).
* @param epochMillis
*/
export declare function millisToHrTime(epochMillis: number): api.HrTime;
export declare function getTimeOrigin(): number;
/**
* Returns an hrtime calculated via performance component.
* @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,171 @@
"use strict";
/*
* Copyright The OpenTelemetry Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
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;
function getTimeOrigin() {
let timeOrigin = platform_1.otperformance.timeOrigin;
if (typeof timeOrigin !== 'number') {
const perf = platform_1.otperformance;
timeOrigin = perf.timing && perf.timing.fetchStart;
}
return timeOrigin;
}
exports.getTimeOrigin = getTimeOrigin;
/**
* Returns an hrtime calculated via performance component.
* @param performanceNow
*/
function hrTime(performanceNow) {
const timeOrigin = millisToHrTime(getTimeOrigin());
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 < getTimeOrigin()) {
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,33 @@
import { Exception } from '@opentelemetry/api';
/**
* This interface defines a fallback to read a timeOrigin when it is not available on performance.timeOrigin,
* this happens for example on Safari Mac
* then the timeOrigin is taken from fetchStart - which is the closest to timeOrigin
*/
export interface TimeOriginLegacy {
timing: {
fetchStart: number;
};
}
/**
* 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,18 @@
"use strict";
/*
* Copyright The OpenTelemetry Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
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;;;;;;;;;;;;;;GAcG","sourcesContent":["/*\n * Copyright The OpenTelemetry Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { Exception } from '@opentelemetry/api';\n\n/**\n * This interface defines a fallback to read a timeOrigin when it is not available on performance.timeOrigin,\n * this happens for example on Safari Mac\n * then the timeOrigin is taken from fetchStart - which is the closest to timeOrigin\n */\nexport interface TimeOriginLegacy {\n timing: {\n fetchStart: number;\n };\n}\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/ban-types\n __unwrap: Function;\n // eslint-disable-next-line @typescript-eslint/ban-types\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"]}

25
node_modules/@opentelemetry/core/build/src/index.d.ts generated vendored Normal file
View File

@@ -0,0 +1,25 @@
export { W3CBaggagePropagator } from './baggage/propagation/W3CBaggagePropagator';
export { AnchoredClock, 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 { ErrorHandler, InstrumentationScope } from './common/types';
export { ExportResult, ExportResultCode } from './ExportResult';
export { parseKeyPairsIntoRecord } from './baggage/utils';
export { SDK_INFO, _globalThis, getStringFromEnv, getBooleanFromEnv, getNumberFromEnv, getStringListFromEnv, otperformance, unrefTimer, } from './platform';
export { CompositePropagator, CompositePropagatorConfig, } from './propagation/composite';
export { TRACE_PARENT_HEADER, TRACE_STATE_HEADER, W3CTraceContextPropagator, parseTraceParent, } from './trace/W3CTraceContextPropagator';
export { RPCMetadata, RPCType, deleteRPCMetadata, getRPCMetadata, setRPCMetadata, } 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

91
node_modules/@opentelemetry/core/build/src/index.js generated vendored Normal file
View File

@@ -0,0 +1,91 @@
"use strict";
/*
* Copyright The OpenTelemetry Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
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.unrefTimer = exports.otperformance = exports.getStringListFromEnv = exports.getNumberFromEnv = exports.getBooleanFromEnv = exports.getStringFromEnv = exports._globalThis = exports.SDK_INFO = exports.parseKeyPairsIntoRecord = exports.ExportResultCode = 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 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; } });
Object.defineProperty(exports, "unrefTimer", { enumerable: true, get: function () { return platform_1.unrefTimer; } });
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;;;;;;;;;;;;;;GAcG;;;AAEH,mFAAkF;AAAzE,4HAAA,oBAAoB,OAAA;AAC7B,0DAA+D;AAAtD,+GAAA,aAAa,OAAA;AACtB,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;AAGnB,+CAAgE;AAAzC,gHAAA,gBAAgB,OAAA;AACvC,yCAA0D;AAAjD,gHAAA,uBAAuB,OAAA;AAChC,uCASoB;AARlB,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;AACb,sGAAA,UAAU,OAAA;AAEZ,qDAGiC;AAF/B,gHAAA,mBAAmB,OAAA;AAGrB,+EAK2C;AAJzC,gIAAA,mBAAmB,OAAA;AACnB,+HAAA,kBAAkB,OAAA;AAClB,sIAAA,yBAAyB,OAAA;AACzB,6HAAA,gBAAgB,OAAA;AAElB,qDAM8B;AAJ5B,uGAAA,OAAO,OAAA;AACP,iHAAA,iBAAiB,OAAA;AACjB,8GAAA,cAAc,OAAA;AACd,8GAAA,cAAc,OAAA;AAEhB,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 *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nexport { W3CBaggagePropagator } from './baggage/propagation/W3CBaggagePropagator';\nexport { AnchoredClock, 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 { ErrorHandler, InstrumentationScope } from './common/types';\nexport { ExportResult, ExportResultCode } from './ExportResult';\nexport { parseKeyPairsIntoRecord } from './baggage/utils';\nexport {\n SDK_INFO,\n _globalThis,\n getStringFromEnv,\n getBooleanFromEnv,\n getNumberFromEnv,\n getStringListFromEnv,\n otperformance,\n unrefTimer,\n} from './platform';\nexport {\n CompositePropagator,\n CompositePropagatorConfig,\n} from './propagation/composite';\nexport {\n TRACE_PARENT_HEADER,\n TRACE_STATE_HEADER,\n W3CTraceContextPropagator,\n parseTraceParent,\n} from './trace/W3CTraceContextPropagator';\nexport {\n RPCMetadata,\n RPCType,\n deleteRPCMetadata,\n getRPCMetadata,\n setRPCMetadata,\n} 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 { 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,36 @@
"use strict";
/*
* Copyright The OpenTelemetry Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
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, (result) => {
resolve(result);
});
});
});
}
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;;;;;;;;;;;;;;GAcG;;;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,CAAC,MAAoB,EAAE,EAAE;gBAC5C,OAAO,CAAC,MAAM,CAAC,CAAC;YAClB,CAAC,CAAC,CAAC;QACL,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC;AAZD,0BAYC","sourcesContent":["/*\n * Copyright The OpenTelemetry Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { context } from '@opentelemetry/api';\nimport { 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, (result: ExportResult) => {\n resolve(result);\n });\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,46 @@
"use strict";
/*
* Copyright The OpenTelemetry Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
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;;;;;;;;;;;;;;GAcG;;;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 *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\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): boolean | undefined;
export declare function getStringListFromEnv(_: string): string[] | undefined;
//# sourceMappingURL=environment.d.ts.map

View File

@@ -0,0 +1,35 @@
"use strict";
/*
* Copyright The OpenTelemetry Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
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;;;;;;;;;;;;;;GAcG;;;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 *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\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): boolean | undefined {\n return undefined;\n}\n\nexport function getStringListFromEnv(_: string): string[] | undefined {\n return undefined;\n}\n"]}

View File

@@ -0,0 +1,10 @@
/**
* - globalThis (New standard)
* - self (Will return the current window instance for supported browsers)
* - window (fallback for older browser implementations)
* - global (NodeJS implementation)
* - <object> (When all else fails)
*/
/** only globals that common to node and browsers are allowed */
export declare const _globalThis: typeof globalThis;
//# sourceMappingURL=globalThis.d.ts.map

View File

@@ -0,0 +1,38 @@
"use strict";
/*
* Copyright The OpenTelemetry Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
Object.defineProperty(exports, "__esModule", { value: true });
exports._globalThis = void 0;
// Updates to this file should also be replicated to @opentelemetry/api too.
/**
* - globalThis (New standard)
* - self (Will return the current window instance for supported browsers)
* - window (fallback for older browser implementations)
* - global (NodeJS implementation)
* - <object> (When all else fails)
*/
/** only globals that common to node and browsers are allowed */
// eslint-disable-next-line node/no-unsupported-features/es-builtins, no-undef
exports._globalThis = typeof globalThis === 'object'
? globalThis
: typeof self === 'object'
? self
: typeof window === 'object'
? window
: typeof global === 'object'
? global
: {};
//# sourceMappingURL=globalThis.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"globalThis.js","sourceRoot":"","sources":["../../../../src/platform/browser/globalThis.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG;;;AAEH,4EAA4E;AAE5E;;;;;;GAMG;AAEH,gEAAgE;AAChE,8EAA8E;AACjE,QAAA,WAAW,GACtB,OAAO,UAAU,KAAK,QAAQ;IAC5B,CAAC,CAAC,UAAU;IACZ,CAAC,CAAC,OAAO,IAAI,KAAK,QAAQ;QACxB,CAAC,CAAC,IAAI;QACN,CAAC,CAAC,OAAO,MAAM,KAAK,QAAQ;YAC1B,CAAC,CAAC,MAAM;YACR,CAAC,CAAC,OAAO,MAAM,KAAK,QAAQ;gBAC1B,CAAC,CAAC,MAAM;gBACR,CAAC,CAAE,EAAwB,CAAC","sourcesContent":["/*\n * Copyright The OpenTelemetry Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n// Updates to this file should also be replicated to @opentelemetry/api too.\n\n/**\n * - globalThis (New standard)\n * - self (Will return the current window instance for supported browsers)\n * - window (fallback for older browser implementations)\n * - global (NodeJS implementation)\n * - <object> (When all else fails)\n */\n\n/** only globals that common to node and browsers are allowed */\n// eslint-disable-next-line node/no-unsupported-features/es-builtins, no-undef\nexport const _globalThis: typeof globalThis =\n typeof globalThis === 'object'\n ? globalThis\n : typeof self === 'object'\n ? self\n : typeof window === 'object'\n ? window\n : typeof global === 'object'\n ? global\n : ({} as typeof globalThis);\n"]}

View File

@@ -0,0 +1,6 @@
export { getStringFromEnv, getBooleanFromEnv, getNumberFromEnv, getStringListFromEnv, } from './environment';
export { _globalThis } from './globalThis';
export { otperformance } from './performance';
export { SDK_INFO } from './sdk-info';
export { unrefTimer } from './timer-util';
//# sourceMappingURL=index.d.ts.map

View File

@@ -0,0 +1,32 @@
"use strict";
/*
* Copyright The OpenTelemetry Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
Object.defineProperty(exports, "__esModule", { value: true });
exports.unrefTimer = exports.SDK_INFO = exports.otperformance = 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("./globalThis");
Object.defineProperty(exports, "_globalThis", { enumerable: true, get: function () { return globalThis_1._globalThis; } });
var performance_1 = require("./performance");
Object.defineProperty(exports, "otperformance", { enumerable: true, get: function () { return performance_1.otperformance; } });
var sdk_info_1 = require("./sdk-info");
Object.defineProperty(exports, "SDK_INFO", { enumerable: true, get: function () { return sdk_info_1.SDK_INFO; } });
var timer_util_1 = require("./timer-util");
Object.defineProperty(exports, "unrefTimer", { enumerable: true, get: function () { return timer_util_1.unrefTimer; } });
//# sourceMappingURL=index.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/platform/browser/index.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG;;;AAEH,6CAKuB;AAJrB,+GAAA,gBAAgB,OAAA;AAChB,gHAAA,iBAAiB,OAAA;AACjB,+GAAA,gBAAgB,OAAA;AAChB,mHAAA,oBAAoB,OAAA;AAEtB,2CAA2C;AAAlC,yGAAA,WAAW,OAAA;AACpB,6CAA8C;AAArC,4GAAA,aAAa,OAAA;AACtB,uCAAsC;AAA7B,oGAAA,QAAQ,OAAA;AACjB,2CAA0C;AAAjC,wGAAA,UAAU,OAAA","sourcesContent":["/*\n * Copyright The OpenTelemetry Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nexport {\n getStringFromEnv,\n getBooleanFromEnv,\n getNumberFromEnv,\n getStringListFromEnv,\n} from './environment';\nexport { _globalThis } from './globalThis';\nexport { otperformance } from './performance';\nexport { SDK_INFO } from './sdk-info';\nexport { unrefTimer } from './timer-util';\n"]}

View File

@@ -0,0 +1,2 @@
export declare const otperformance: Performance;
//# sourceMappingURL=performance.d.ts.map

View File

@@ -0,0 +1,20 @@
"use strict";
/*
* Copyright The OpenTelemetry Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
Object.defineProperty(exports, "__esModule", { value: true });
exports.otperformance = void 0;
exports.otperformance = performance;
//# sourceMappingURL=performance.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"performance.js","sourceRoot":"","sources":["../../../../src/platform/browser/performance.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG;;;AAEU,QAAA,aAAa,GAAG,WAAW,CAAC","sourcesContent":["/*\n * Copyright The OpenTelemetry Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\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": string;
"telemetry.sdk.version": string;
};
//# sourceMappingURL=sdk-info.d.ts.map

View File

@@ -0,0 +1,28 @@
"use strict";
/*
* Copyright The OpenTelemetry Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
Object.defineProperty(exports, "__esModule", { value: true });
exports.SDK_INFO = void 0;
const version_1 = require("../../version");
const semantic_conventions_1 = require("@opentelemetry/semantic-conventions");
/** Constants describing the SDK in use */
exports.SDK_INFO = {
[semantic_conventions_1.SEMRESATTRS_TELEMETRY_SDK_NAME]: 'opentelemetry',
[semantic_conventions_1.SEMRESATTRS_PROCESS_RUNTIME_NAME]: 'browser',
[semantic_conventions_1.SEMRESATTRS_TELEMETRY_SDK_LANGUAGE]: semantic_conventions_1.TELEMETRYSDKLANGUAGEVALUES_WEBJS,
[semantic_conventions_1.SEMRESATTRS_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;;;;;;;;;;;;;;GAcG;;;AAEH,2CAAwC;AACxC,8EAM6C;AAE7C,0CAA0C;AAC7B,QAAA,QAAQ,GAAG;IACtB,CAAC,qDAA8B,CAAC,EAAE,eAAe;IACjD,CAAC,uDAAgC,CAAC,EAAE,SAAS;IAC7C,CAAC,yDAAkC,CAAC,EAAE,uDAAgC;IACtE,CAAC,wDAAiC,CAAC,EAAE,iBAAO;CAC7C,CAAC","sourcesContent":["/*\n * Copyright The OpenTelemetry Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { VERSION } from '../../version';\nimport {\n SEMRESATTRS_TELEMETRY_SDK_NAME,\n SEMRESATTRS_PROCESS_RUNTIME_NAME,\n SEMRESATTRS_TELEMETRY_SDK_LANGUAGE,\n TELEMETRYSDKLANGUAGEVALUES_WEBJS,\n SEMRESATTRS_TELEMETRY_SDK_VERSION,\n} from '@opentelemetry/semantic-conventions';\n\n/** Constants describing the SDK in use */\nexport const SDK_INFO = {\n [SEMRESATTRS_TELEMETRY_SDK_NAME]: 'opentelemetry',\n [SEMRESATTRS_PROCESS_RUNTIME_NAME]: 'browser',\n [SEMRESATTRS_TELEMETRY_SDK_LANGUAGE]: TELEMETRYSDKLANGUAGEVALUES_WEBJS,\n [SEMRESATTRS_TELEMETRY_SDK_VERSION]: VERSION,\n};\n"]}

View File

@@ -0,0 +1,2 @@
export declare function unrefTimer(_timer: number): void;
//# sourceMappingURL=timer-util.d.ts.map

View File

@@ -0,0 +1,21 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.unrefTimer = void 0;
/*
* Copyright The OpenTelemetry Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
function unrefTimer(_timer) { }
exports.unrefTimer = unrefTimer;
//# sourceMappingURL=timer-util.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"timer-util.js","sourceRoot":"","sources":["../../../../src/platform/browser/timer-util.ts"],"names":[],"mappings":";;;AAAA;;;;;;;;;;;;;;GAcG;AACH,SAAgB,UAAU,CAAC,MAAc,IAAS,CAAC;AAAnD,gCAAmD","sourcesContent":["/*\n * Copyright The OpenTelemetry Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nexport function unrefTimer(_timer: number): void {}\n"]}

View File

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

View File

@@ -0,0 +1,28 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.getStringListFromEnv = exports.getNumberFromEnv = exports.getStringFromEnv = exports.getBooleanFromEnv = exports.unrefTimer = exports.otperformance = exports._globalThis = exports.SDK_INFO = void 0;
/*
* Copyright The OpenTelemetry Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
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, "unrefTimer", { enumerable: true, get: function () { return node_1.unrefTimer; } });
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;;;;;;;;;;;;;;GAcG;AACH,+BASgB;AARd,gGAAA,QAAQ,OAAA;AACR,mGAAA,WAAW,OAAA;AACX,qGAAA,aAAa,OAAA;AACb,kGAAA,UAAU,OAAA;AACV,yGAAA,iBAAiB,OAAA;AACjB,wGAAA,gBAAgB,OAAA;AAChB,wGAAA,gBAAgB,OAAA;AAChB,4GAAA,oBAAoB,OAAA","sourcesContent":["/*\n * Copyright The OpenTelemetry Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nexport {\n SDK_INFO,\n _globalThis,\n otperformance,\n unrefTimer,\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,104 @@
"use strict";
/*
* Copyright The OpenTelemetry Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
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

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,3 @@
/** only globals that common to node and browsers are allowed */
export declare const _globalThis: typeof globalThis;
//# sourceMappingURL=globalThis.d.ts.map

View File

@@ -0,0 +1,22 @@
"use strict";
/*
* Copyright The OpenTelemetry Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
Object.defineProperty(exports, "__esModule", { value: true });
exports._globalThis = void 0;
/** only globals that common to node and browsers are allowed */
// eslint-disable-next-line node/no-unsupported-features/es-builtins
exports._globalThis = typeof globalThis === 'object' ? globalThis : global;
//# sourceMappingURL=globalThis.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"globalThis.js","sourceRoot":"","sources":["../../../../src/platform/node/globalThis.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG;;;AAEH,gEAAgE;AAChE,oEAAoE;AACvD,QAAA,WAAW,GAAG,OAAO,UAAU,KAAK,QAAQ,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,MAAM,CAAC","sourcesContent":["/*\n * Copyright The OpenTelemetry Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n/** only globals that common to node and browsers are allowed */\n// eslint-disable-next-line node/no-unsupported-features/es-builtins\nexport const _globalThis = typeof globalThis === 'object' ? globalThis : global;\n"]}

View File

@@ -0,0 +1,6 @@
export { getStringFromEnv, getBooleanFromEnv, getNumberFromEnv, getStringListFromEnv, } from './environment';
export { _globalThis } from './globalThis';
export { otperformance } from './performance';
export { SDK_INFO } from './sdk-info';
export { unrefTimer } from './timer-util';
//# sourceMappingURL=index.d.ts.map

View File

@@ -0,0 +1,32 @@
"use strict";
/*
* Copyright The OpenTelemetry Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
Object.defineProperty(exports, "__esModule", { value: true });
exports.unrefTimer = exports.SDK_INFO = exports.otperformance = 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("./globalThis");
Object.defineProperty(exports, "_globalThis", { enumerable: true, get: function () { return globalThis_1._globalThis; } });
var performance_1 = require("./performance");
Object.defineProperty(exports, "otperformance", { enumerable: true, get: function () { return performance_1.otperformance; } });
var sdk_info_1 = require("./sdk-info");
Object.defineProperty(exports, "SDK_INFO", { enumerable: true, get: function () { return sdk_info_1.SDK_INFO; } });
var timer_util_1 = require("./timer-util");
Object.defineProperty(exports, "unrefTimer", { enumerable: true, get: function () { return timer_util_1.unrefTimer; } });
//# sourceMappingURL=index.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/platform/node/index.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG;;;AAEH,6CAKuB;AAJrB,+GAAA,gBAAgB,OAAA;AAChB,gHAAA,iBAAiB,OAAA;AACjB,+GAAA,gBAAgB,OAAA;AAChB,mHAAA,oBAAoB,OAAA;AAEtB,2CAA2C;AAAlC,yGAAA,WAAW,OAAA;AACpB,6CAA8C;AAArC,4GAAA,aAAa,OAAA;AACtB,uCAAsC;AAA7B,oGAAA,QAAQ,OAAA;AACjB,2CAA0C;AAAjC,wGAAA,UAAU,OAAA","sourcesContent":["/*\n * Copyright The OpenTelemetry Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nexport {\n getStringFromEnv,\n getBooleanFromEnv,\n getNumberFromEnv,\n getStringListFromEnv,\n} from './environment';\nexport { _globalThis } from './globalThis';\nexport { otperformance } from './performance';\nexport { SDK_INFO } from './sdk-info';\nexport { unrefTimer } from './timer-util';\n"]}

View File

@@ -0,0 +1,3 @@
/// <reference types="node" />
export declare const otperformance: import("perf_hooks").Performance;
//# sourceMappingURL=performance.d.ts.map

View File

@@ -0,0 +1,21 @@
"use strict";
/*
* Copyright The OpenTelemetry Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
Object.defineProperty(exports, "__esModule", { value: true });
exports.otperformance = void 0;
const perf_hooks_1 = require("perf_hooks");
exports.otperformance = perf_hooks_1.performance;
//# sourceMappingURL=performance.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"performance.js","sourceRoot":"","sources":["../../../../src/platform/node/performance.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG;;;AAEH,2CAAyC;AAE5B,QAAA,aAAa,GAAG,wBAAW,CAAC","sourcesContent":["/*\n * Copyright The OpenTelemetry Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { performance } from 'perf_hooks';\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": string;
"telemetry.sdk.version": string;
};
//# sourceMappingURL=sdk-info.d.ts.map

View File

@@ -0,0 +1,28 @@
"use strict";
/*
* Copyright The OpenTelemetry Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
Object.defineProperty(exports, "__esModule", { value: true });
exports.SDK_INFO = void 0;
const version_1 = require("../../version");
const semantic_conventions_1 = require("@opentelemetry/semantic-conventions");
/** Constants describing the SDK in use */
exports.SDK_INFO = {
[semantic_conventions_1.SEMRESATTRS_TELEMETRY_SDK_NAME]: 'opentelemetry',
[semantic_conventions_1.SEMRESATTRS_PROCESS_RUNTIME_NAME]: 'node',
[semantic_conventions_1.SEMRESATTRS_TELEMETRY_SDK_LANGUAGE]: semantic_conventions_1.TELEMETRYSDKLANGUAGEVALUES_NODEJS,
[semantic_conventions_1.SEMRESATTRS_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;;;;;;;;;;;;;;GAcG;;;AAEH,2CAAwC;AACxC,8EAM6C;AAE7C,0CAA0C;AAC7B,QAAA,QAAQ,GAAG;IACtB,CAAC,qDAA8B,CAAC,EAAE,eAAe;IACjD,CAAC,uDAAgC,CAAC,EAAE,MAAM;IAC1C,CAAC,yDAAkC,CAAC,EAAE,wDAAiC;IACvE,CAAC,wDAAiC,CAAC,EAAE,iBAAO;CAC7C,CAAC","sourcesContent":["/*\n * Copyright The OpenTelemetry Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { VERSION } from '../../version';\nimport {\n SEMRESATTRS_TELEMETRY_SDK_NAME,\n SEMRESATTRS_PROCESS_RUNTIME_NAME,\n SEMRESATTRS_TELEMETRY_SDK_LANGUAGE,\n TELEMETRYSDKLANGUAGEVALUES_NODEJS,\n SEMRESATTRS_TELEMETRY_SDK_VERSION,\n} from '@opentelemetry/semantic-conventions';\n\n/** Constants describing the SDK in use */\nexport const SDK_INFO = {\n [SEMRESATTRS_TELEMETRY_SDK_NAME]: 'opentelemetry',\n [SEMRESATTRS_PROCESS_RUNTIME_NAME]: 'node',\n [SEMRESATTRS_TELEMETRY_SDK_LANGUAGE]: TELEMETRYSDKLANGUAGEVALUES_NODEJS,\n [SEMRESATTRS_TELEMETRY_SDK_VERSION]: VERSION,\n};\n"]}

View File

@@ -0,0 +1,3 @@
/// <reference types="node" />
export declare function unrefTimer(timer: NodeJS.Timer): void;
//# sourceMappingURL=timer-util.d.ts.map

View File

@@ -0,0 +1,23 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.unrefTimer = void 0;
/*
* Copyright The OpenTelemetry Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
function unrefTimer(timer) {
timer.unref();
}
exports.unrefTimer = unrefTimer;
//# sourceMappingURL=timer-util.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"timer-util.js","sourceRoot":"","sources":["../../../../src/platform/node/timer-util.ts"],"names":[],"mappings":";;;AAAA;;;;;;;;;;;;;;GAcG;AACH,SAAgB,UAAU,CAAC,KAAmB;IAC5C,KAAK,CAAC,KAAK,EAAE,CAAC;AAChB,CAAC;AAFD,gCAEC","sourcesContent":["/*\n * Copyright The OpenTelemetry Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nexport function unrefTimer(timer: NodeJS.Timer): void {\n timer.unref();\n}\n"]}

View File

@@ -0,0 +1,43 @@
import { 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,81 @@
"use strict";
/*
* Copyright The OpenTelemetry Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
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

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,22 @@
import * 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,103 @@
"use strict";
/*
* Copyright The OpenTelemetry Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
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 { 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,104 @@
"use strict";
/*
* Copyright The OpenTelemetry Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
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 { 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,37 @@
"use strict";
/*
* Copyright The OpenTelemetry Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
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;;;;;;;;;;;;;;GAcG;;;AAEH,4CAAqE;AAErE,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 *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { Context, createContextKey, Span } 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 { 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,33 @@
"use strict";
/*
* Copyright The OpenTelemetry Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
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;;;;;;;;;;;;;;GAcG;;;AAEH,4CAA+D;AAE/D,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 *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { Context, 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 _callback;
private _that;
private _isCalled;
private _deferred;
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,52 @@
"use strict";
/*
* Copyright The OpenTelemetry Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
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 {
_callback;
_that;
_isCalled = false;
_deferred = new promise_1.Deferred();
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;;;;;;;;;;;;;;GAcG;;;AAEH,uCAAqC;AAErC;;GAEG;AACH,MAAa,cAAc;IAQf;IACA;IAJF,SAAS,GAAG,KAAK,CAAC;IAClB,SAAS,GAAG,IAAI,kBAAQ,EAAK,CAAC;IACtC,YACU,SAAY,EACZ,KAAW;QADX,cAAS,GAAT,SAAS,CAAG;QACZ,UAAK,GAAL,KAAK,CAAM;IAClB,CAAC;IAEJ,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;AAlCD,wCAkCC","sourcesContent":["/*\n * Copyright The OpenTelemetry Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\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 constructor(\n private _callback: T,\n private _that: This\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,46 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.diagLogLevelFromString = void 0;
/*
* Copyright The OpenTelemetry Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
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;;;;;;;;;;;;;;GAcG;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 *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\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

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