@opentelemetry/context-base
Advanced tools
Comparing version 0.11.1-alpha.48 to 0.12.1-alpha.54
@@ -1,15 +0,5 @@ | ||
export declare class Context { | ||
import { Context } from './types'; | ||
export declare class BaseContext implements Context { | ||
private _currentContext; | ||
/** The root context is used as the default parent context when there is no active context */ | ||
static readonly ROOT_CONTEXT: Context; | ||
/** | ||
* This is another identifier to the root context which allows developers to easily search the | ||
* codebase for direct uses of context which need to be removed in later PRs. | ||
* | ||
* It's existence is temporary and it should be removed when all references are fixed. | ||
*/ | ||
static readonly TODO: Context; | ||
/** Get a key to uniquely identify a context value */ | ||
static createKey(description: string): symbol; | ||
/** | ||
* Construct a new context which inherits values from an optional parent context. | ||
@@ -19,3 +9,3 @@ * | ||
*/ | ||
private constructor(); | ||
constructor(parentContext?: Map<symbol, unknown>); | ||
/** | ||
@@ -43,2 +33,6 @@ * Get a value from the context. | ||
} | ||
/** The root context is used as the default parent context when there is no active context */ | ||
export declare const ROOT_CONTEXT: Context; | ||
/** Get a key to uniquely identify a context value */ | ||
export declare function createContextKey(description: string): symbol; | ||
//# sourceMappingURL=context.d.ts.map |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.Context = void 0; | ||
/* | ||
@@ -19,3 +17,5 @@ * Copyright The OpenTelemetry Authors | ||
*/ | ||
var Context = /** @class */ (function () { | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.createContextKey = exports.ROOT_CONTEXT = exports.BaseContext = void 0; | ||
var BaseContext = /** @class */ (function () { | ||
/** | ||
@@ -26,9 +26,5 @@ * Construct a new context which inherits values from an optional parent context. | ||
*/ | ||
function Context(parentContext) { | ||
function BaseContext(parentContext) { | ||
this._currentContext = parentContext ? new Map(parentContext) : new Map(); | ||
} | ||
/** Get a key to uniquely identify a context value */ | ||
Context.createKey = function (description) { | ||
return Symbol.for(description); | ||
}; | ||
/** | ||
@@ -39,3 +35,3 @@ * Get a value from the context. | ||
*/ | ||
Context.prototype.getValue = function (key) { | ||
BaseContext.prototype.getValue = function (key) { | ||
return this._currentContext.get(key); | ||
@@ -50,4 +46,4 @@ }; | ||
*/ | ||
Context.prototype.setValue = function (key, value) { | ||
var context = new Context(this._currentContext); | ||
BaseContext.prototype.setValue = function (key, value) { | ||
var context = new BaseContext(this._currentContext); | ||
context._currentContext.set(key, value); | ||
@@ -62,19 +58,17 @@ return context; | ||
*/ | ||
Context.prototype.deleteValue = function (key) { | ||
var context = new Context(this._currentContext); | ||
BaseContext.prototype.deleteValue = function (key) { | ||
var context = new BaseContext(this._currentContext); | ||
context._currentContext.delete(key); | ||
return context; | ||
}; | ||
/** The root context is used as the default parent context when there is no active context */ | ||
Context.ROOT_CONTEXT = new Context(); | ||
/** | ||
* This is another identifier to the root context which allows developers to easily search the | ||
* codebase for direct uses of context which need to be removed in later PRs. | ||
* | ||
* It's existence is temporary and it should be removed when all references are fixed. | ||
*/ | ||
Context.TODO = Context.ROOT_CONTEXT; | ||
return Context; | ||
return BaseContext; | ||
}()); | ||
exports.Context = Context; | ||
exports.BaseContext = BaseContext; | ||
/** The root context is used as the default parent context when there is no active context */ | ||
exports.ROOT_CONTEXT = new BaseContext(); | ||
/** Get a key to uniquely identify a context value */ | ||
function createContextKey(description) { | ||
return Symbol.for(description); | ||
} | ||
exports.createContextKey = createContextKey; | ||
//# sourceMappingURL=context.js.map |
@@ -0,4 +1,4 @@ | ||
export { createContextKey, ROOT_CONTEXT } from './context'; | ||
export * from './NoopContextManager'; | ||
export * from './types'; | ||
export * from './context'; | ||
export * from './NoopContextManager'; | ||
//# sourceMappingURL=index.d.ts.map |
@@ -28,5 +28,7 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var context_1 = require("./context"); | ||
Object.defineProperty(exports, "createContextKey", { enumerable: true, get: function () { return context_1.createContextKey; } }); | ||
Object.defineProperty(exports, "ROOT_CONTEXT", { enumerable: true, get: function () { return context_1.ROOT_CONTEXT; } }); | ||
__exportStar(require("./NoopContextManager"), exports); | ||
__exportStar(require("./types"), exports); | ||
__exportStar(require("./context"), exports); | ||
__exportStar(require("./NoopContextManager"), exports); | ||
//# sourceMappingURL=index.js.map |
import * as types from './types'; | ||
import { Context } from './context'; | ||
export declare class NoopContextManager implements types.ContextManager { | ||
active(): Context; | ||
with<T extends (...args: unknown[]) => ReturnType<T>>(context: Context, fn: T): ReturnType<T>; | ||
bind<T>(target: T, context?: Context): T; | ||
active(): types.Context; | ||
with<T extends (...args: unknown[]) => ReturnType<T>>(context: types.Context, fn: T): ReturnType<T>; | ||
bind<T>(target: T, context?: types.Context): T; | ||
enable(): this; | ||
@@ -8,0 +7,0 @@ disable(): this; |
@@ -24,3 +24,3 @@ "use strict"; | ||
NoopContextManager.prototype.active = function () { | ||
return context_1.Context.ROOT_CONTEXT; | ||
return context_1.ROOT_CONTEXT; | ||
}; | ||
@@ -27,0 +27,0 @@ NoopContextManager.prototype.with = function (context, fn) { |
@@ -1,2 +0,24 @@ | ||
import { Context } from './context'; | ||
export interface Context { | ||
/** | ||
* Get a value from the context. | ||
* | ||
* @param key key which identifies a context value | ||
*/ | ||
getValue(key: symbol): unknown; | ||
/** | ||
* Create a new context which inherits from this context and has | ||
* the given key set to the given value. | ||
* | ||
* @param key context key for which to set the value | ||
* @param value value to set for the given key | ||
*/ | ||
setValue(key: symbol, value: unknown): Context; | ||
/** | ||
* Return a new context which inherits from this context but does | ||
* not contain a value for the given key. | ||
* | ||
* @param key context key for which to clear a value | ||
*/ | ||
deleteValue(key: symbol): Context; | ||
} | ||
export interface ContextManager { | ||
@@ -3,0 +25,0 @@ /** |
@@ -1,2 +0,2 @@ | ||
export declare const VERSION = "0.11.1-alpha.48+15174c6"; | ||
export declare const VERSION = "0.12.1-alpha.54+3f72613a"; | ||
//# sourceMappingURL=version.d.ts.map |
@@ -20,3 +20,3 @@ "use strict"; | ||
// this is autogenerated file, see scripts/version-update.js | ||
exports.VERSION = '0.11.1-alpha.48+15174c6'; | ||
exports.VERSION = '0.12.1-alpha.54+3f72613a'; | ||
//# sourceMappingURL=version.js.map |
{ | ||
"name": "@opentelemetry/context-base", | ||
"version": "0.11.1-alpha.48+15174c6", | ||
"version": "0.12.1-alpha.54+3f72613a", | ||
"description": "OpenTelemetry Base Context Manager", | ||
@@ -55,6 +55,6 @@ "main": "build/src/index.js", | ||
"ts-mocha": "7.0.0", | ||
"ts-node": "8.10.2", | ||
"ts-node": "9.0.0", | ||
"typescript": "3.9.7" | ||
}, | ||
"gitHead": "15174c6647ab9863dfc1424412fa60f2fddb3351" | ||
"gitHead": "3f72613a36b6f97555a0fa7481755cf8b6cce1a7" | ||
} |
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
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
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
28748
273