From 6bc6c007fe68fc9b0ece28ef08e7a75582afe44c Mon Sep 17 00:00:00 2001 From: vmarchaud Date: Thu, 27 Jun 2019 14:22:02 +0200 Subject: [PATCH] add BaseScopeManager interface #46 --- .../.npmignore | 0 .../LICENSE | 0 .../README.md | 2 +- .../package.json | 4 +- .../src/index.ts | 2 + .../opentelemetry-scope-base/src/types.ts | 49 +++++++++++++++++++ .../tsconfig.json | 0 7 files changed, 54 insertions(+), 3 deletions(-) rename packages/{opentelemetry-context-base => opentelemetry-scope-base}/.npmignore (100%) rename packages/{opentelemetry-context-base => opentelemetry-scope-base}/LICENSE (100%) rename packages/{opentelemetry-context-base => opentelemetry-scope-base}/README.md (64%) rename packages/{opentelemetry-context-base => opentelemetry-scope-base}/package.json (91%) rename packages/{opentelemetry-context-base => opentelemetry-scope-base}/src/index.ts (95%) create mode 100644 packages/opentelemetry-scope-base/src/types.ts rename packages/{opentelemetry-context-base => opentelemetry-scope-base}/tsconfig.json (100%) diff --git a/packages/opentelemetry-context-base/.npmignore b/packages/opentelemetry-scope-base/.npmignore similarity index 100% rename from packages/opentelemetry-context-base/.npmignore rename to packages/opentelemetry-scope-base/.npmignore diff --git a/packages/opentelemetry-context-base/LICENSE b/packages/opentelemetry-scope-base/LICENSE similarity index 100% rename from packages/opentelemetry-context-base/LICENSE rename to packages/opentelemetry-scope-base/LICENSE diff --git a/packages/opentelemetry-context-base/README.md b/packages/opentelemetry-scope-base/README.md similarity index 64% rename from packages/opentelemetry-context-base/README.md rename to packages/opentelemetry-scope-base/README.md index f722b5aba9..78f2ffb794 100644 --- a/packages/opentelemetry-context-base/README.md +++ b/packages/opentelemetry-scope-base/README.md @@ -1,4 +1,4 @@ -OpenTelemetry ContextManager API +OpenTelemetry Base Scope Manager ====================================================== TODO diff --git a/packages/opentelemetry-context-base/package.json b/packages/opentelemetry-scope-base/package.json similarity index 91% rename from packages/opentelemetry-context-base/package.json rename to packages/opentelemetry-scope-base/package.json index 41dbf4e757..5cb7668fa5 100644 --- a/packages/opentelemetry-context-base/package.json +++ b/packages/opentelemetry-scope-base/package.json @@ -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", diff --git a/packages/opentelemetry-context-base/src/index.ts b/packages/opentelemetry-scope-base/src/index.ts similarity index 95% rename from packages/opentelemetry-context-base/src/index.ts rename to packages/opentelemetry-scope-base/src/index.ts index 6acf3afa4e..f21192eb00 100644 --- a/packages/opentelemetry-context-base/src/index.ts +++ b/packages/opentelemetry-scope-base/src/index.ts @@ -13,3 +13,5 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + +export * from './types'; diff --git a/packages/opentelemetry-scope-base/src/types.ts b/packages/opentelemetry-scope-base/src/types.ts new file mode 100644 index 0000000000..0cc18e8912 --- /dev/null +++ b/packages/opentelemetry-scope-base/src/types.ts @@ -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 unknown>( + scope: unknown, + fn: T + ): ReturnType; + + /** + * 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(object: T, scope?: unknown): T; + + /** + * Enable scope management + */ + enable(): this; + + /** + * Disable scope management + */ + disable(): void; +} diff --git a/packages/opentelemetry-context-base/tsconfig.json b/packages/opentelemetry-scope-base/tsconfig.json similarity index 100% rename from packages/opentelemetry-context-base/tsconfig.json rename to packages/opentelemetry-scope-base/tsconfig.json