Skip to content

Commit

Permalink
add ContextManager interface #46
Browse files Browse the repository at this point in the history
  • Loading branch information
vmarchaud committed Jul 8, 2019
1 parent c3ac018 commit 921366f
Show file tree
Hide file tree
Showing 7 changed files with 51 additions and 3 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,7 +1,7 @@
{
"name": "@opentelemetry/context-base",
"name": "@opentelemetry/scope-base",
"version": "0.0.1",
"description": "OpenTelemetry Default Context Propagation",
"description": "OpenTelemetry Base Scope Management",
"main": "build/src/index.js",
"types": "build/src/index.d.ts",
"repository": "open-telemetry/opentelemetry-js",
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';
46 changes: 46 additions & 0 deletions packages/opentelemetry-scope-base/src/types.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
/**
* 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>(scope: unknown, fn: T): void;

/**
* 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(): void;

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

0 comments on commit 921366f

Please sign in to comment.