@opentelemetry/core
Advanced tools
Comparing version 0.10.3-canary.0 to 0.11.0
@@ -8,2 +8,7 @@ import { Span, SpanContext } from '@opentelemetry/api'; | ||
/** | ||
* Shared key for indicating if instrumentation should be suppressed beyond | ||
* this current scope. | ||
*/ | ||
export declare const SUPPRESS_INSTRUMENTATION_KEY: symbol; | ||
/** | ||
* Return the active span if one exists | ||
@@ -42,2 +47,23 @@ * | ||
export declare function getParentSpanContext(context: Context): SpanContext | undefined; | ||
/** | ||
* Sets value on context to indicate that instrumentation should | ||
* be suppressed beyond this current scope. | ||
* | ||
* @param context context to set the suppress instrumentation value on. | ||
*/ | ||
export declare function suppressInstrumentation(context: Context): Context; | ||
/** | ||
* Sets value on context to indicate that instrumentation should | ||
* no-longer be suppressed beyond this current scope. | ||
* | ||
* @param context context to set the suppress instrumentation value on. | ||
*/ | ||
export declare function unsuppressInstrumentation(context: Context): Context; | ||
/** | ||
* Return current suppress instrumentation value for the given context, | ||
* if it exists. | ||
* | ||
* @param context context check for the suppress instrumentation value. | ||
*/ | ||
export declare function isInstrumentationSuppressed(context: Context): boolean; | ||
//# sourceMappingURL=context.d.ts.map |
@@ -18,3 +18,3 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.getParentSpanContext = exports.setExtractedSpanContext = exports.getExtractedSpanContext = exports.setActiveSpan = exports.getActiveSpan = exports.ACTIVE_SPAN_KEY = void 0; | ||
exports.isInstrumentationSuppressed = exports.unsuppressInstrumentation = exports.suppressInstrumentation = exports.getParentSpanContext = exports.setExtractedSpanContext = exports.getExtractedSpanContext = exports.setActiveSpan = exports.getActiveSpan = exports.SUPPRESS_INSTRUMENTATION_KEY = exports.ACTIVE_SPAN_KEY = void 0; | ||
const context_base_1 = require("@opentelemetry/context-base"); | ||
@@ -27,2 +27,7 @@ /** | ||
/** | ||
* Shared key for indicating if instrumentation should be suppressed beyond | ||
* this current scope. | ||
*/ | ||
exports.SUPPRESS_INSTRUMENTATION_KEY = context_base_1.Context.createKey('OpenTelemetry Context Key SUPPRESS_INSTRUMENTATION'); | ||
/** | ||
* Return the active span if one exists | ||
@@ -77,2 +82,32 @@ * | ||
exports.getParentSpanContext = getParentSpanContext; | ||
/** | ||
* Sets value on context to indicate that instrumentation should | ||
* be suppressed beyond this current scope. | ||
* | ||
* @param context context to set the suppress instrumentation value on. | ||
*/ | ||
function suppressInstrumentation(context) { | ||
return context.setValue(exports.SUPPRESS_INSTRUMENTATION_KEY, true); | ||
} | ||
exports.suppressInstrumentation = suppressInstrumentation; | ||
/** | ||
* Sets value on context to indicate that instrumentation should | ||
* no-longer be suppressed beyond this current scope. | ||
* | ||
* @param context context to set the suppress instrumentation value on. | ||
*/ | ||
function unsuppressInstrumentation(context) { | ||
return context.setValue(exports.SUPPRESS_INSTRUMENTATION_KEY, false); | ||
} | ||
exports.unsuppressInstrumentation = unsuppressInstrumentation; | ||
/** | ||
* Return current suppress instrumentation value for the given context, | ||
* if it exists. | ||
* | ||
* @param context context check for the suppress instrumentation value. | ||
*/ | ||
function isInstrumentationSuppressed(context) { | ||
return Boolean(context.getValue(exports.SUPPRESS_INSTRUMENTATION_KEY)); | ||
} | ||
exports.isInstrumentationSuppressed = isInstrumentationSuppressed; | ||
//# sourceMappingURL=context.js.map |
@@ -1,2 +0,2 @@ | ||
import { Context, GetterFunction, HttpTextPropagator, SetterFunction } from '@opentelemetry/api'; | ||
import { Context, GetterFunction, TextMapPropagator, SetterFunction } from '@opentelemetry/api'; | ||
export declare const X_B3_TRACE_ID = "x-b3-traceid"; | ||
@@ -13,3 +13,3 @@ export declare const X_B3_SPAN_ID = "x-b3-spanid"; | ||
*/ | ||
export declare class B3Propagator implements HttpTextPropagator { | ||
export declare class B3Propagator implements TextMapPropagator { | ||
inject(context: Context, carrier: unknown, setter: SetterFunction): void; | ||
@@ -16,0 +16,0 @@ extract(context: Context, carrier: unknown, getter: GetterFunction): Context; |
@@ -1,5 +0,5 @@ | ||
import { Context, GetterFunction, HttpTextPropagator, SetterFunction } from '@opentelemetry/api'; | ||
import { Context, GetterFunction, TextMapPropagator, SetterFunction } from '@opentelemetry/api'; | ||
import { CompositePropagatorConfig } from './types'; | ||
/** Combines multiple propagators into a single propagator. */ | ||
export declare class CompositePropagator implements HttpTextPropagator { | ||
export declare class CompositePropagator implements TextMapPropagator { | ||
private readonly _propagators; | ||
@@ -6,0 +6,0 @@ private readonly _logger; |
@@ -1,2 +0,2 @@ | ||
import { Context, GetterFunction, HttpTextPropagator, SetterFunction, SpanContext } from '@opentelemetry/api'; | ||
import { Context, GetterFunction, TextMapPropagator, SetterFunction, SpanContext } from '@opentelemetry/api'; | ||
export declare const TRACE_PARENT_HEADER = "traceparent"; | ||
@@ -21,3 +21,3 @@ export declare const TRACE_STATE_HEADER = "tracestate"; | ||
*/ | ||
export declare class HttpTraceContext implements HttpTextPropagator { | ||
export declare class HttpTraceContext implements TextMapPropagator { | ||
inject(context: Context, carrier: unknown, setter: SetterFunction): void; | ||
@@ -24,0 +24,0 @@ extract(context: Context, carrier: unknown, getter: GetterFunction): Context; |
@@ -24,4 +24,8 @@ "use strict"; | ||
exports.TRACE_STATE_HEADER = 'tracestate'; | ||
const VALID_TRACE_PARENT_REGEX = /^(?!ff)[\da-f]{2}-([\da-f]{32})-([\da-f]{16})-([\da-f]{2})(-|$)/; | ||
const VERSION = '00'; | ||
const VERSION_PART_COUNT = 4; // Version 00 only allows the specific 4 fields. | ||
const VERSION_REGEX = /^(?!ff)[\da-f]{2}$/; | ||
const TRACE_ID_REGEX = /^(?![0]{32})[\da-f]{32}$/; | ||
const PARENT_ID_REGEX = /^(?![0]{16})[\da-f]{16}$/; | ||
const FLAGS_REGEX = /^[\da-f]{2}$/; | ||
/** | ||
@@ -38,12 +42,22 @@ * Parses information from the [traceparent] span tag and converts it into {@link SpanContext} | ||
function parseTraceParent(traceParent) { | ||
const match = traceParent.match(VALID_TRACE_PARENT_REGEX); | ||
if (!match || | ||
match[1] === '00000000000000000000000000000000' || | ||
match[2] === '0000000000000000') { | ||
const trimmed = traceParent.trim(); | ||
const traceParentParts = trimmed.split('-'); | ||
// Current version must be structured correctly. | ||
// For future versions, we can grab just the parts we do support. | ||
if (traceParentParts[0] === VERSION && | ||
traceParentParts.length !== VERSION_PART_COUNT) { | ||
return null; | ||
} | ||
const [version, traceId, parentId, flags] = traceParentParts; | ||
const isValidParent = VERSION_REGEX.test(version) && | ||
TRACE_ID_REGEX.test(traceId) && | ||
PARENT_ID_REGEX.test(parentId) && | ||
FLAGS_REGEX.test(flags); | ||
if (!isValidParent) { | ||
return null; | ||
} | ||
return { | ||
traceId: match[1], | ||
spanId: match[2], | ||
traceFlags: parseInt(match[3], 16), | ||
traceId: traceId, | ||
spanId: parentId, | ||
traceFlags: parseInt(flags, 16), | ||
}; | ||
@@ -50,0 +64,0 @@ } |
@@ -1,2 +0,2 @@ | ||
import { HttpTextPropagator, Logger } from '@opentelemetry/api'; | ||
import { TextMapPropagator, Logger } from '@opentelemetry/api'; | ||
/** Configuration object for composite propagator */ | ||
@@ -9,3 +9,3 @@ export interface CompositePropagatorConfig { | ||
*/ | ||
propagators?: HttpTextPropagator[]; | ||
propagators?: TextMapPropagator[]; | ||
/** Instance of logger */ | ||
@@ -12,0 +12,0 @@ logger?: Logger; |
@@ -1,2 +0,2 @@ | ||
import { Context, GetterFunction, HttpTextPropagator, SetterFunction } from '@opentelemetry/api'; | ||
import { Context, GetterFunction, TextMapPropagator, SetterFunction } from '@opentelemetry/api'; | ||
export declare const CORRELATION_CONTEXT_HEADER = "otcorrelations"; | ||
@@ -12,3 +12,3 @@ export declare const MAX_NAME_VALUE_PAIRS = 180; | ||
*/ | ||
export declare class HttpCorrelationContext implements HttpTextPropagator { | ||
export declare class HttpCorrelationContext implements TextMapPropagator { | ||
inject(context: Context, carrier: unknown, setter: SetterFunction): void; | ||
@@ -15,0 +15,0 @@ private _serializeKeyPairs; |
@@ -70,4 +70,2 @@ "use strict"; | ||
const pairs = headerValue.split(ITEMS_SEPARATOR); | ||
if (pairs.length == 1) | ||
return context; | ||
pairs.forEach(entry => { | ||
@@ -79,2 +77,5 @@ const keyPair = this._parsePairKeyValue(entry); | ||
}); | ||
if (Object.entries(correlationContext).length === 0) { | ||
return context; | ||
} | ||
return correlation_context_1.setCorrelationContext(context, correlationContext); | ||
@@ -90,3 +91,3 @@ } | ||
const keyPair = keyPairPart.split(KEY_PAIR_SEPARATOR); | ||
if (keyPair.length <= 1) | ||
if (keyPair.length != 2) | ||
return; | ||
@@ -93,0 +94,0 @@ const key = decodeURIComponent(keyPair[0].trim()); |
@@ -20,3 +20,2 @@ export * from './common/ConsoleLogger'; | ||
export * from './trace/sampler/ProbabilitySampler'; | ||
export * from './trace/spancontext-utils'; | ||
export * from './trace/TraceState'; | ||
@@ -23,0 +22,0 @@ export * from './trace/IdGenerator'; |
@@ -47,3 +47,2 @@ "use strict"; | ||
__exportStar(require("./trace/sampler/ProbabilitySampler"), exports); | ||
__exportStar(require("./trace/spancontext-utils"), exports); | ||
__exportStar(require("./trace/TraceState"), exports); | ||
@@ -50,0 +49,0 @@ __exportStar(require("./trace/IdGenerator"), exports); |
@@ -8,2 +8,3 @@ export * from './BasePlugin'; | ||
export * from './timer-util'; | ||
export * from './ShutdownNotifier'; | ||
//# sourceMappingURL=index.d.ts.map |
@@ -35,2 +35,3 @@ "use strict"; | ||
__exportStar(require("./timer-util"), exports); | ||
__exportStar(require("./ShutdownNotifier"), exports); | ||
//# sourceMappingURL=index.js.map |
@@ -7,3 +7,3 @@ import { IdGenerator } from '../../trace/IdGenerator'; | ||
*/ | ||
generateTraceId(): string; | ||
generateTraceId: () => string; | ||
/** | ||
@@ -13,10 +13,4 @@ * Returns a random 8-byte span ID formatted/encoded as a 16 lowercase hex | ||
*/ | ||
generateSpanId(): string; | ||
/** | ||
* Get the hex string representation of a byte array | ||
* | ||
* @param byteArray | ||
*/ | ||
private toHex; | ||
generateSpanId: () => string; | ||
} | ||
//# sourceMappingURL=RandomIdGenerator.d.ts.map |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.RandomIdGenerator = void 0; | ||
const cryptoLib = window.crypto || window.msCrypto; | ||
const SPAN_ID_BYTES = 8; | ||
const TRACE_ID_BYTES = 16; | ||
const randomBytesArray = new Uint8Array(TRACE_ID_BYTES); | ||
class RandomIdGenerator { | ||
/** | ||
* Returns a random 16-byte trace ID formatted/encoded as a 32 lowercase hex | ||
* characters corresponding to 128 bits. | ||
*/ | ||
generateTraceId() { | ||
cryptoLib.getRandomValues(randomBytesArray); | ||
return this.toHex(randomBytesArray.slice(0, TRACE_ID_BYTES)); | ||
constructor() { | ||
/** | ||
* Returns a random 16-byte trace ID formatted/encoded as a 32 lowercase hex | ||
* characters corresponding to 128 bits. | ||
*/ | ||
this.generateTraceId = getIdGenerator(TRACE_ID_BYTES); | ||
/** | ||
* Returns a random 8-byte span ID formatted/encoded as a 16 lowercase hex | ||
* characters corresponding to 64 bits. | ||
*/ | ||
this.generateSpanId = getIdGenerator(SPAN_ID_BYTES); | ||
} | ||
/** | ||
* Returns a random 8-byte span ID formatted/encoded as a 16 lowercase hex | ||
* characters corresponding to 64 bits. | ||
*/ | ||
generateSpanId() { | ||
cryptoLib.getRandomValues(randomBytesArray); | ||
return this.toHex(randomBytesArray.slice(0, SPAN_ID_BYTES)); | ||
} | ||
/** | ||
* Get the hex string representation of a byte array | ||
* | ||
* @param byteArray | ||
*/ | ||
toHex(byteArray) { | ||
const chars = new Array(byteArray.length * 2); | ||
const alpha = 'a'.charCodeAt(0) - 10; | ||
const digit = '0'.charCodeAt(0); | ||
let p = 0; | ||
for (let i = 0; i < byteArray.length; i++) { | ||
let nibble = (byteArray[i] >>> 4) & 0xf; | ||
chars[p++] = nibble > 9 ? nibble + alpha : nibble + digit; | ||
nibble = byteArray[i] & 0xf; | ||
chars[p++] = nibble > 9 ? nibble + alpha : nibble + digit; | ||
} | ||
exports.RandomIdGenerator = RandomIdGenerator; | ||
const SHARED_CHAR_CODES_ARRAY = Array(32); | ||
function getIdGenerator(bytes) { | ||
return function generateId() { | ||
for (let i = 0; i < bytes * 2; i++) { | ||
SHARED_CHAR_CODES_ARRAY[i] = Math.floor(Math.random() * 16) + 48; | ||
// valid hex characters in the range 48-57 and 97-102 | ||
if (SHARED_CHAR_CODES_ARRAY[i] >= 58) { | ||
SHARED_CHAR_CODES_ARRAY[i] += 39; | ||
} | ||
} | ||
return String.fromCharCode.apply(null, chars); | ||
} | ||
return String.fromCharCode.apply(null, SHARED_CHAR_CODES_ARRAY.slice(0, bytes * 2)); | ||
}; | ||
} | ||
exports.RandomIdGenerator = RandomIdGenerator; | ||
//# sourceMappingURL=RandomIdGenerator.js.map |
@@ -8,2 +8,3 @@ export * from './BasePlugin'; | ||
export * from './timer-util'; | ||
export * from './ShutdownNotifier'; | ||
//# sourceMappingURL=index.d.ts.map |
@@ -35,2 +35,3 @@ "use strict"; | ||
__exportStar(require("./timer-util"), exports); | ||
__exportStar(require("./ShutdownNotifier"), exports); | ||
//# sourceMappingURL=index.js.map |
@@ -7,3 +7,3 @@ import { IdGenerator } from '../../trace/IdGenerator'; | ||
*/ | ||
generateTraceId(): string; | ||
generateTraceId: () => string; | ||
/** | ||
@@ -13,4 +13,4 @@ * Returns a random 8-byte span ID formatted/encoded as a 16 lowercase hex | ||
*/ | ||
generateSpanId(): string; | ||
generateSpanId: () => string; | ||
} | ||
//# sourceMappingURL=RandomIdGenerator.d.ts.map |
@@ -19,22 +19,39 @@ "use strict"; | ||
exports.RandomIdGenerator = void 0; | ||
const crypto = require("crypto"); | ||
const SPAN_ID_BYTES = 8; | ||
const TRACE_ID_BYTES = 16; | ||
class RandomIdGenerator { | ||
/** | ||
* Returns a random 16-byte trace ID formatted/encoded as a 32 lowercase hex | ||
* characters corresponding to 128 bits. | ||
*/ | ||
generateTraceId() { | ||
return crypto.randomBytes(TRACE_ID_BYTES).toString('hex'); | ||
constructor() { | ||
/** | ||
* Returns a random 16-byte trace ID formatted/encoded as a 32 lowercase hex | ||
* characters corresponding to 128 bits. | ||
*/ | ||
this.generateTraceId = getIdGenerator(TRACE_ID_BYTES); | ||
/** | ||
* Returns a random 8-byte span ID formatted/encoded as a 16 lowercase hex | ||
* characters corresponding to 64 bits. | ||
*/ | ||
this.generateSpanId = getIdGenerator(SPAN_ID_BYTES); | ||
} | ||
/** | ||
* Returns a random 8-byte span ID formatted/encoded as a 16 lowercase hex | ||
* characters corresponding to 64 bits. | ||
*/ | ||
generateSpanId() { | ||
return crypto.randomBytes(SPAN_ID_BYTES).toString('hex'); | ||
} | ||
} | ||
exports.RandomIdGenerator = RandomIdGenerator; | ||
const SHARED_BUFFER = Buffer.allocUnsafe(TRACE_ID_BYTES); | ||
function getIdGenerator(bytes) { | ||
return function generateId() { | ||
for (let i = 0; i < bytes / 4; i++) { | ||
// unsigned right shift drops decimal part of the number | ||
// it is required because if a number between 2**32 and 2**32 - 1 is generated, an out of range error is thrown by writeUInt32BE | ||
SHARED_BUFFER.writeUInt32BE((Math.random() * 2 ** 32) >>> 0, i * 4); | ||
} | ||
// If buffer is all 0, set the last byte to 1 to guarantee a valid w3c id is generated | ||
for (let i = 0; i < bytes; i++) { | ||
if (SHARED_BUFFER[i] > 0) { | ||
break; | ||
} | ||
else if (i === bytes - 1) { | ||
SHARED_BUFFER[bytes - 1] = 1; | ||
} | ||
} | ||
return SHARED_BUFFER.toString('hex', 0, bytes); | ||
}; | ||
} | ||
//# sourceMappingURL=RandomIdGenerator.js.map |
/// <reference types="node" /> | ||
export declare function unrefTimer(timer: NodeJS.Timeout): void; | ||
export declare function unrefTimer(timer: NodeJS.Timer): void; | ||
//# sourceMappingURL=timer-util.d.ts.map |
@@ -20,3 +20,2 @@ "use strict"; | ||
const api_1 = require("@opentelemetry/api"); | ||
const spancontext_utils_1 = require("../trace/spancontext-utils"); | ||
/** | ||
@@ -29,3 +28,3 @@ * The NoRecordingSpan extends the {@link NoopSpan}, making all operations no-op | ||
super(spanContext); | ||
this._context = spanContext || spancontext_utils_1.INVALID_SPAN_CONTEXT; | ||
this._context = spanContext || api_1.INVALID_SPAN_CONTEXT; | ||
} | ||
@@ -32,0 +31,0 @@ // Returns a SpanContext. |
@@ -67,6 +67,7 @@ "use strict"; | ||
.reduce((agg, part) => { | ||
const i = part.indexOf(LIST_MEMBER_KEY_VALUE_SPLITTER); | ||
const listMember = part.trim(); // Optional Whitespace (OWS) handling | ||
const i = listMember.indexOf(LIST_MEMBER_KEY_VALUE_SPLITTER); | ||
if (i !== -1) { | ||
const key = part.slice(0, i); | ||
const value = part.slice(i + 1, part.length); | ||
const key = listMember.slice(0, i); | ||
const value = listMember.slice(i + 1, part.length); | ||
if (validators_1.validateKey(key) && validators_1.validateValue(value)) { | ||
@@ -73,0 +74,0 @@ agg.set(key, value); |
@@ -1,2 +0,2 @@ | ||
export declare const VERSION = "0.10.3-canary.0+f4f2f84"; | ||
export declare const VERSION = "0.11.0"; | ||
//# sourceMappingURL=version.d.ts.map |
@@ -20,3 +20,3 @@ "use strict"; | ||
// this is autogenerated file, see scripts/version-update.js | ||
exports.VERSION = '0.10.3-canary.0+f4f2f84'; | ||
exports.VERSION = '0.11.0'; | ||
//# sourceMappingURL=version.js.map |
{ | ||
"name": "@opentelemetry/core", | ||
"version": "0.10.3-canary.0+f4f2f84", | ||
"version": "0.11.0", | ||
"description": "OpenTelemetry Core provides default and no-op implementations of the OpenTelemetry types for trace and metrics", | ||
@@ -55,5 +55,5 @@ "main": "build/src/index.js", | ||
"devDependencies": { | ||
"@types/mocha": "8.0.0", | ||
"@types/mocha": "8.0.2", | ||
"@types/node": "14.0.27", | ||
"@types/semver": "7.3.1", | ||
"@types/semver": "7.3.2", | ||
"@types/sinon": "9.0.4", | ||
@@ -73,4 +73,4 @@ "@types/webpack-env": "1.15.2", | ||
"rimraf": "3.0.2", | ||
"sinon": "9.0.2", | ||
"ts-loader": "8.0.1", | ||
"sinon": "9.0.3", | ||
"ts-loader": "8.0.2", | ||
"ts-mocha": "7.0.0", | ||
@@ -82,7 +82,7 @@ "ts-node": "8.10.2", | ||
"dependencies": { | ||
"@opentelemetry/api": "^0.10.3-canary.0+f4f2f84", | ||
"@opentelemetry/context-base": "^0.10.3-canary.0+f4f2f84", | ||
"@opentelemetry/api": "^0.11.0", | ||
"@opentelemetry/context-base": "^0.11.0", | ||
"semver": "^7.1.3" | ||
}, | ||
"gitHead": "f4f2f84bc087389b3206a2e17837b7b0b95fb2f2" | ||
"gitHead": "15174c6647ab9863dfc1424412fa60f2fddb3351" | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Manifest confusion
Supply chain riskThis package has inconsistent metadata. This could be malicious or caused by an error when publishing the package.
Found 1 instance in 1 package
165793
138
2675
+ Added@opentelemetry/api@0.11.0(transitive)
+ Added@opentelemetry/context-base@0.11.0(transitive)
- Removed@opentelemetry/api@0.10.3-canary.0(transitive)
- Removed@opentelemetry/context-base@0.10.3-canary.0(transitive)
Updated@opentelemetry/api@^0.11.0