Skip to content

Commit

Permalink
Add BaseScopeManager interface (open-telemetry#66)
Browse files Browse the repository at this point in the history
* Add context-base and context-asynchooks packages

* add BaseScopeManager interface open-telemetry#46
  • Loading branch information
vmarchaud authored and mayurkale22 committed Jul 11, 2019
1 parent 14310c3 commit 9d41576
Show file tree
Hide file tree
Showing 7 changed files with 57 additions and 5 deletions.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
OpenTelemetry ContextManager API
OpenTelemetry Base Scope Manager
======================================================

TODO
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
{
"name": "@opentelemetry/context-base",
"name": "@opentelemetry/scope-base",
"version": "0.0.1",
"description": "OpenTelemetry ContextManager API",
"description": "OpenTelemetry Base Scope Management",
"main": "build/src/index.js",
"types": "build/src/index.d.ts",
"repository": "open-telemetry/opentelemetry-js",
"scripts": {
"test": "nyc ts-mocha -p tsconfig.json test/**/*.ts",
"tdd": "yarn test -- --watch-extensions ts --watch",
"test": "nyc ts-mocha -p ./tsconfig.json test/**/*.ts",
"tdd": "yarn run test -- --watch-extensions ts --watch",
"codecov": "nyc report --reporter=json && codecov -f coverage/*.json",
"clean": "rimraf build/*",
"check": "gts check",
"compile": "tsc -p .",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,5 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/

export * from './types';
49 changes: 49 additions & 0 deletions packages/opentelemetry-scope-base/src/types.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
/**
* Copyright 2019, 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
*
* http://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.
*/

export interface BaseScopeManager {
/**
* Get the current active scope
*/
active(): unknown;

/**
* Run the fn callback with object set as the current active scope
* @param scope Any object to set as the current active scope
* @param fn A callback to be imediately run within a specific scope
*/
with<T extends (...args: unknown[]) => unknown>(
scope: unknown,
fn: T
): ReturnType<T>;

/**
* Bind an object as the current scope (or a specific one)
* @param object Object to which a scope need to be set
* @param [scope] Optionaly specify the scope which you want to assign
*/
bind<T>(object: T, scope?: unknown): T;

/**
* Enable scope management
*/
enable(): this;

/**
* Disable scope management
*/
disable(): void;
}

0 comments on commit 9d41576

Please sign in to comment.