From 6439be3b43ab6c352ce944ede8d2653122cfced0 Mon Sep 17 00:00:00 2001 From: Daniel Dyla Date: Thu, 15 Sep 2022 17:40:20 -0400 Subject: [PATCH 01/10] Add API to lerna --- api/karma.conf.js | 24 +++++++++ api/karma.worker.js | 24 +++++++++ api/package.json | 54 +++++++++---------- api/test/diag/consoleLogger.test.ts | 6 ++- api/tsconfig.all.json | 9 ++++ api/tsconfig.esm.json | 11 ++++ api/tsconfig.esnext.json | 11 ++++ api/tsconfig.json | 13 +++++ experimental/packages/api-logs/tsconfig.json | 5 ++ .../exporter-trace-otlp-grpc/tsconfig.json | 3 ++ .../exporter-trace-otlp-http/tsconfig.json | 3 ++ .../exporter-trace-otlp-proto/tsconfig.json | 3 ++ .../opentelemetry-api-metrics/tsconfig.json | 5 ++ .../tsconfig.json | 3 ++ .../tsconfig.json | 3 ++ .../tsconfig.json | 3 ++ .../tsconfig.json | 3 ++ .../tsconfig.json | 3 ++ .../tsconfig.json | 3 ++ .../tsconfig.json | 3 ++ .../tsconfig.json | 3 ++ .../tsconfig.json | 3 ++ .../opentelemetry-sdk-metrics/tsconfig.json | 3 ++ .../opentelemetry-sdk-node/tsconfig.json | 3 ++ .../packages/otlp-exporter-base/tsconfig.json | 3 ++ .../otlp-grpc-exporter-base/tsconfig.json | 3 ++ .../otlp-proto-exporter-base/tsconfig.json | 3 ++ .../packages/otlp-transformer/tsconfig.json | 3 ++ .../tsconfig.json | 3 ++ lerna.json | 1 + .../tsconfig.json | 5 ++ .../tsconfig.json | 5 ++ packages/opentelemetry-core/tsconfig.json | 3 ++ .../tsconfig.json | 3 ++ .../tsconfig.json | 3 ++ .../opentelemetry-propagator-b3/tsconfig.json | 3 ++ .../tsconfig.json | 3 ++ .../opentelemetry-resources/tsconfig.json | 3 ++ .../tsconfig.json | 3 ++ .../tsconfig.json | 3 ++ .../opentelemetry-sdk-trace-web/tsconfig.json | 3 ++ .../tsconfig.json | 3 ++ tsconfig.json | 4 ++ 43 files changed, 233 insertions(+), 31 deletions(-) create mode 100644 api/karma.conf.js create mode 100644 api/karma.worker.js create mode 100644 api/tsconfig.all.json create mode 100644 api/tsconfig.esm.json create mode 100644 api/tsconfig.esnext.json create mode 100644 api/tsconfig.json diff --git a/api/karma.conf.js b/api/karma.conf.js new file mode 100644 index 00000000000..5f7d9f888d3 --- /dev/null +++ b/api/karma.conf.js @@ -0,0 +1,24 @@ +/*! + * Copyright The 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. + */ + +const karmaWebpackConfig = require('../karma.webpack'); +const karmaBaseConfig = require('../karma.base'); + +module.exports = (config) => { + config.set(Object.assign({}, karmaBaseConfig, { + webpack: karmaWebpackConfig, + })) +}; diff --git a/api/karma.worker.js b/api/karma.worker.js new file mode 100644 index 00000000000..7917d5a000f --- /dev/null +++ b/api/karma.worker.js @@ -0,0 +1,24 @@ +/*! + * Copyright The 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. + */ + +const karmaWebpackConfig = require('../karma.webpack'); +const karmaBaseConfig = require('../karma.worker'); + +module.exports = (config) => { + config.set(Object.assign({}, karmaBaseConfig, { + webpack: karmaWebpackConfig, + })) +}; diff --git a/api/package.json b/api/package.json index c0a475d8904..15fcae3c6cc 100644 --- a/api/package.json +++ b/api/package.json @@ -12,10 +12,11 @@ }, "repository": "https://github.com/open-telemetry/opentelemetry-js-api.git", "scripts": { - "clean": "tsc --build --clean tsconfig.json tsconfig.esm.json", - "codecov:browser": "nyc report --reporter=json && codecov -f coverage/*.json -p .", - "codecov": "nyc report --reporter=json && codecov -f coverage/*.json -p .", - "precompile": "npm run version", + "clean": "tsc --build --clean", + "codecov:browser": "nyc report --reporter=json && codecov -f coverage/*.json -p ../", + "codecov:webworker": "nyc report --reporter=json && codecov -f coverage/*.json -p ../", + "codecov": "nyc report --reporter=json && codecov -f coverage/*.json -p ../", + "precompile": "lerna run version --scope $(npm pkg get name) --include-dependencies", "compile": "tsc --build tsconfig.json tsconfig.esm.json", "docs": "typedoc", "docs:deploy": "gh-pages --dist docs/out", @@ -24,10 +25,12 @@ "lint": "eslint src test --ext .ts", "test:browser": "nyc karma start --single-run", "test": "nyc ts-mocha -p tsconfig.json test/**/*.test.ts", + "test:webworker": "nyc karma start karma.worker.js --single-run", "cycle-check": "dpdm --exit-code circular:1 src/index.ts", - "version": "node scripts/version-update.js", - "prewatch": "npm run version", - "watch": "tsc --build --watch" + "version": "node ../scripts/version-update.js", + "prewatch": "npm run precompile", + "watch": "tsc --build --watch", + "peer-api-check": "node ../scripts/peer-api-check.js" }, "keywords": [ "opentelemetry", @@ -57,34 +60,27 @@ "access": "public" }, "devDependencies": { - "@types/mocha": "8.2.2", - "@types/node": "14.17.4", - "@types/sinon": "10.0.2", - "@types/webpack-env": "1.16.0", - "@typescript-eslint/eslint-plugin": "5.0.0", - "@typescript-eslint/parser": "5.0.0", - "codecov": "3.8.2", - "dpdm": "3.7.1", - "eslint": "7.32.0", - "eslint-plugin-header": "3.1.1", - "eslint-plugin-node": "11.1.0", - "gh-pages": "3.2.0", + "@types/mocha": "9.1.1", + "@types/node": "18.6.5", + "@types/sinon": "10.0.13", + "@types/webpack-env": "1.16.3", + "codecov": "3.8.3", + "dpdm": "3.10.0", "istanbul-instrumenter-loader": "3.0.1", - "karma": "5.2.3", + "karma": "6.3.16", "karma-chrome-launcher": "3.1.0", "karma-coverage-istanbul-reporter": "3.0.3", "karma-mocha": "2.0.1", + "karma-mocha-webworker": "1.3.0", "karma-spec-reporter": "0.0.32", "karma-webpack": "4.0.2", - "lerna-changelog": "1.0.1", - "linkinator": "2.13.6", - "mocha": "7.2.0", + "mocha": "10.0.0", "nyc": "15.1.0", - "sinon": "11.1.1", - "ts-loader": "8.2.0", - "ts-mocha": "8.0.0", - "typedoc": "0.21.2", - "typescript": "4.3.5", + "sinon": "14.0.0", + "ts-loader": "8.4.0", + "ts-mocha": "10.0.0", + "typescript": "4.4.4", "webpack": "4.46.0" - } + }, + "homepage": "https://github.com/open-telemetry/opentelemetry-js/tree/main/api" } diff --git a/api/test/diag/consoleLogger.test.ts b/api/test/diag/consoleLogger.test.ts index 2210a7c68b7..51064fb4560 100644 --- a/api/test/diag/consoleLogger.test.ts +++ b/api/test/diag/consoleLogger.test.ts @@ -27,14 +27,14 @@ export const diagLoggerFunctions = [ 'error', ] as const; -const consoleFuncs: Array = [ +const consoleFuncs = [ 'debug', 'info', 'warn', 'error', 'log', 'trace', -]; +] as const; const expectedConsoleMap: { [n: string]: keyof Console } = { error: 'error', @@ -127,6 +127,7 @@ describe('DiagConsoleLogger', () => { consoleFuncs.forEach(cName => { it(`should log ${fName} message even when console doesn't support ${cName} call before construction`, () => { + // @ts-ignore removing a console property is not allowed by types console[cName] = undefined; const consoleLogger: any = new DiagConsoleLogger(); consoleLogger[fName](`${fName} called %s`, 'param1'); @@ -142,6 +143,7 @@ describe('DiagConsoleLogger', () => { it(`should log ${fName} message even when console doesn't support ${cName} call after construction`, () => { const consoleLogger: any = new DiagConsoleLogger(); + // @ts-ignore removing a console property is not allowed by types console[cName] = undefined; consoleLogger[fName](`${fName} called %s`, 'param1'); if (cName !== expectedConsoleMap[fName]) { diff --git a/api/tsconfig.all.json b/api/tsconfig.all.json new file mode 100644 index 00000000000..4aa747e89fb --- /dev/null +++ b/api/tsconfig.all.json @@ -0,0 +1,9 @@ +{ + "extends": "../tsconfig.base.json", + "files": [], + "references": [ + { "path": "./tsconfig.json" }, + { "path": "./tsconfig.esm.json" }, + { "path": "./tsconfig.esnext.json" } + ] +} diff --git a/api/tsconfig.esm.json b/api/tsconfig.esm.json new file mode 100644 index 00000000000..50611a86af1 --- /dev/null +++ b/api/tsconfig.esm.json @@ -0,0 +1,11 @@ +{ + "extends": "../tsconfig.base.esm.json", + "compilerOptions": { + "rootDir": "src", + "outDir": "build/esm", + "tsBuildInfoFile": "build/esm/tsconfig.esm.tsbuildinfo" + }, + "include": [ + "src/**/*.ts" + ] +} diff --git a/api/tsconfig.esnext.json b/api/tsconfig.esnext.json new file mode 100644 index 00000000000..0e3427cbc12 --- /dev/null +++ b/api/tsconfig.esnext.json @@ -0,0 +1,11 @@ +{ + "extends": "../tsconfig.base.esnext.json", + "compilerOptions": { + "rootDir": "src", + "outDir": "build/esnext", + "tsBuildInfoFile": "build/esnext/tsconfig.esnext.tsbuildinfo" + }, + "include": [ + "src/**/*.ts" + ] +} diff --git a/api/tsconfig.json b/api/tsconfig.json new file mode 100644 index 00000000000..088086278b7 --- /dev/null +++ b/api/tsconfig.json @@ -0,0 +1,13 @@ +{ + "extends": "../tsconfig.base.json", + "compilerOptions": { + "rootDir": ".", + "outDir": "build" + }, + "include": [ + "src/**/*.ts", + "test/**/*.ts" + ], + "references": [ + ] +} diff --git a/experimental/packages/api-logs/tsconfig.json b/experimental/packages/api-logs/tsconfig.json index ed9d0830bdd..e22548584a7 100644 --- a/experimental/packages/api-logs/tsconfig.json +++ b/experimental/packages/api-logs/tsconfig.json @@ -7,5 +7,10 @@ "include": [ "src/**/*.ts", "test/**/*.ts" + ], + "references": [ + { + "path": "../../../api" + } ] } diff --git a/experimental/packages/exporter-trace-otlp-grpc/tsconfig.json b/experimental/packages/exporter-trace-otlp-grpc/tsconfig.json index 94d47b6e191..abde2bfde94 100644 --- a/experimental/packages/exporter-trace-otlp-grpc/tsconfig.json +++ b/experimental/packages/exporter-trace-otlp-grpc/tsconfig.json @@ -9,6 +9,9 @@ "test/**/*.ts" ], "references": [ + { + "path": "../../../api" + }, { "path": "../../../packages/opentelemetry-core" }, diff --git a/experimental/packages/exporter-trace-otlp-http/tsconfig.json b/experimental/packages/exporter-trace-otlp-http/tsconfig.json index 087c804079c..bb73fd2a342 100644 --- a/experimental/packages/exporter-trace-otlp-http/tsconfig.json +++ b/experimental/packages/exporter-trace-otlp-http/tsconfig.json @@ -9,6 +9,9 @@ "test/**/*.ts" ], "references": [ + { + "path": "../../../api" + }, { "path": "../../../packages/opentelemetry-core" }, diff --git a/experimental/packages/exporter-trace-otlp-proto/tsconfig.json b/experimental/packages/exporter-trace-otlp-proto/tsconfig.json index 3324a8a5298..9b6c50baef8 100644 --- a/experimental/packages/exporter-trace-otlp-proto/tsconfig.json +++ b/experimental/packages/exporter-trace-otlp-proto/tsconfig.json @@ -9,6 +9,9 @@ "test/**/*.ts" ], "references": [ + { + "path": "../../../api" + }, { "path": "../../../packages/opentelemetry-core" }, diff --git a/experimental/packages/opentelemetry-api-metrics/tsconfig.json b/experimental/packages/opentelemetry-api-metrics/tsconfig.json index ed9d0830bdd..e22548584a7 100644 --- a/experimental/packages/opentelemetry-api-metrics/tsconfig.json +++ b/experimental/packages/opentelemetry-api-metrics/tsconfig.json @@ -7,5 +7,10 @@ "include": [ "src/**/*.ts", "test/**/*.ts" + ], + "references": [ + { + "path": "../../../api" + } ] } diff --git a/experimental/packages/opentelemetry-exporter-metrics-otlp-grpc/tsconfig.json b/experimental/packages/opentelemetry-exporter-metrics-otlp-grpc/tsconfig.json index b6a4e457480..1be23dd8b28 100644 --- a/experimental/packages/opentelemetry-exporter-metrics-otlp-grpc/tsconfig.json +++ b/experimental/packages/opentelemetry-exporter-metrics-otlp-grpc/tsconfig.json @@ -9,6 +9,9 @@ "test/**/*.ts" ], "references": [ + { + "path": "../../../api" + }, { "path": "../../../packages/opentelemetry-core" }, diff --git a/experimental/packages/opentelemetry-exporter-metrics-otlp-http/tsconfig.json b/experimental/packages/opentelemetry-exporter-metrics-otlp-http/tsconfig.json index 132af2033a1..1f981132baf 100644 --- a/experimental/packages/opentelemetry-exporter-metrics-otlp-http/tsconfig.json +++ b/experimental/packages/opentelemetry-exporter-metrics-otlp-http/tsconfig.json @@ -9,6 +9,9 @@ "test/**/*.ts" ], "references": [ + { + "path": "../../../api" + }, { "path": "../../../packages/opentelemetry-core" }, diff --git a/experimental/packages/opentelemetry-exporter-metrics-otlp-proto/tsconfig.json b/experimental/packages/opentelemetry-exporter-metrics-otlp-proto/tsconfig.json index be2921b2fd5..63e825da3fe 100644 --- a/experimental/packages/opentelemetry-exporter-metrics-otlp-proto/tsconfig.json +++ b/experimental/packages/opentelemetry-exporter-metrics-otlp-proto/tsconfig.json @@ -9,6 +9,9 @@ "test/**/*.ts" ], "references": [ + { + "path": "../../../api" + }, { "path": "../../../packages/opentelemetry-core" }, diff --git a/experimental/packages/opentelemetry-exporter-prometheus/tsconfig.json b/experimental/packages/opentelemetry-exporter-prometheus/tsconfig.json index b9a0327885e..138ffc3aad4 100644 --- a/experimental/packages/opentelemetry-exporter-prometheus/tsconfig.json +++ b/experimental/packages/opentelemetry-exporter-prometheus/tsconfig.json @@ -9,6 +9,9 @@ "test/**/*.ts" ], "references": [ + { + "path": "../../../api" + }, { "path": "../../../packages/opentelemetry-core" }, diff --git a/experimental/packages/opentelemetry-instrumentation-fetch/tsconfig.json b/experimental/packages/opentelemetry-instrumentation-fetch/tsconfig.json index b228a2080af..9b921df4d9c 100644 --- a/experimental/packages/opentelemetry-instrumentation-fetch/tsconfig.json +++ b/experimental/packages/opentelemetry-instrumentation-fetch/tsconfig.json @@ -10,6 +10,9 @@ "test/**/*.ts" ], "references": [ + { + "path": "../../../api" + }, { "path": "../../../packages/opentelemetry-context-zone" }, diff --git a/experimental/packages/opentelemetry-instrumentation-grpc/tsconfig.json b/experimental/packages/opentelemetry-instrumentation-grpc/tsconfig.json index 8b4ba562f1c..c21412396f3 100644 --- a/experimental/packages/opentelemetry-instrumentation-grpc/tsconfig.json +++ b/experimental/packages/opentelemetry-instrumentation-grpc/tsconfig.json @@ -9,6 +9,9 @@ "test/**/*.ts" ], "references": [ + { + "path": "../../../api" + }, { "path": "../../../packages/opentelemetry-context-async-hooks" }, diff --git a/experimental/packages/opentelemetry-instrumentation-http/tsconfig.json b/experimental/packages/opentelemetry-instrumentation-http/tsconfig.json index 034c613b3e6..94828c26dad 100644 --- a/experimental/packages/opentelemetry-instrumentation-http/tsconfig.json +++ b/experimental/packages/opentelemetry-instrumentation-http/tsconfig.json @@ -9,6 +9,9 @@ "test/**/*.ts" ], "references": [ + { + "path": "../../../api" + }, { "path": "../../../packages/opentelemetry-context-async-hooks" }, diff --git a/experimental/packages/opentelemetry-instrumentation-xml-http-request/tsconfig.json b/experimental/packages/opentelemetry-instrumentation-xml-http-request/tsconfig.json index b228a2080af..9b921df4d9c 100644 --- a/experimental/packages/opentelemetry-instrumentation-xml-http-request/tsconfig.json +++ b/experimental/packages/opentelemetry-instrumentation-xml-http-request/tsconfig.json @@ -10,6 +10,9 @@ "test/**/*.ts" ], "references": [ + { + "path": "../../../api" + }, { "path": "../../../packages/opentelemetry-context-zone" }, diff --git a/experimental/packages/opentelemetry-instrumentation/tsconfig.json b/experimental/packages/opentelemetry-instrumentation/tsconfig.json index 948abef3ceb..af53bd1755d 100644 --- a/experimental/packages/opentelemetry-instrumentation/tsconfig.json +++ b/experimental/packages/opentelemetry-instrumentation/tsconfig.json @@ -9,6 +9,9 @@ "test/**/*.ts" ], "references": [ + { + "path": "../../../api" + }, { "path": "../opentelemetry-api-metrics" } diff --git a/experimental/packages/opentelemetry-sdk-metrics/tsconfig.json b/experimental/packages/opentelemetry-sdk-metrics/tsconfig.json index 53d44a09df6..c56be210db7 100644 --- a/experimental/packages/opentelemetry-sdk-metrics/tsconfig.json +++ b/experimental/packages/opentelemetry-sdk-metrics/tsconfig.json @@ -9,6 +9,9 @@ "test/**/*.ts" ], "references": [ + { + "path": "../../../api" + }, { "path": "../../../packages/opentelemetry-core" }, diff --git a/experimental/packages/opentelemetry-sdk-node/tsconfig.json b/experimental/packages/opentelemetry-sdk-node/tsconfig.json index 8249dd1ce64..3d1db307391 100644 --- a/experimental/packages/opentelemetry-sdk-node/tsconfig.json +++ b/experimental/packages/opentelemetry-sdk-node/tsconfig.json @@ -9,6 +9,9 @@ "test/**/*.ts" ], "references": [ + { + "path": "../../../api" + }, { "path": "../../../packages/opentelemetry-context-async-hooks" }, diff --git a/experimental/packages/otlp-exporter-base/tsconfig.json b/experimental/packages/otlp-exporter-base/tsconfig.json index 3e284c16fce..fbb799ec145 100644 --- a/experimental/packages/otlp-exporter-base/tsconfig.json +++ b/experimental/packages/otlp-exporter-base/tsconfig.json @@ -9,6 +9,9 @@ "test/**/*.ts" ], "references": [ + { + "path": "../../../api" + }, { "path": "../../../packages/opentelemetry-core" } diff --git a/experimental/packages/otlp-grpc-exporter-base/tsconfig.json b/experimental/packages/otlp-grpc-exporter-base/tsconfig.json index 087c804079c..bb73fd2a342 100644 --- a/experimental/packages/otlp-grpc-exporter-base/tsconfig.json +++ b/experimental/packages/otlp-grpc-exporter-base/tsconfig.json @@ -9,6 +9,9 @@ "test/**/*.ts" ], "references": [ + { + "path": "../../../api" + }, { "path": "../../../packages/opentelemetry-core" }, diff --git a/experimental/packages/otlp-proto-exporter-base/tsconfig.json b/experimental/packages/otlp-proto-exporter-base/tsconfig.json index 3e05eef24c0..b0fd3b0b551 100644 --- a/experimental/packages/otlp-proto-exporter-base/tsconfig.json +++ b/experimental/packages/otlp-proto-exporter-base/tsconfig.json @@ -11,6 +11,9 @@ "test/**/*.ts" ], "references": [ + { + "path": "../../../api" + }, { "path": "../../../packages/opentelemetry-core" }, diff --git a/experimental/packages/otlp-transformer/tsconfig.json b/experimental/packages/otlp-transformer/tsconfig.json index a396bcb48fa..e06d7404a5e 100644 --- a/experimental/packages/otlp-transformer/tsconfig.json +++ b/experimental/packages/otlp-transformer/tsconfig.json @@ -9,6 +9,9 @@ "test/**/*.ts" ], "references": [ + { + "path": "../../../api" + }, { "path": "../../../packages/opentelemetry-core" }, diff --git a/integration-tests/propagation-validation-server/tsconfig.json b/integration-tests/propagation-validation-server/tsconfig.json index eb74c6b4c63..7b374cea7b0 100644 --- a/integration-tests/propagation-validation-server/tsconfig.json +++ b/integration-tests/propagation-validation-server/tsconfig.json @@ -6,6 +6,9 @@ }, "include": [], "references": [ + { + "path": "../../api" + }, { "path": "../../packages/opentelemetry-context-async-hooks" }, diff --git a/lerna.json b/lerna.json index 04c90d0ef0f..5c0f76b9c2a 100644 --- a/lerna.json +++ b/lerna.json @@ -2,6 +2,7 @@ "version": "independent", "npmClient": "npm", "packages": [ + "api", "packages/*", "experimental/packages/*", "experimental/backwards-compatability/*", diff --git a/packages/opentelemetry-context-async-hooks/tsconfig.json b/packages/opentelemetry-context-async-hooks/tsconfig.json index bdc94d22137..b1ea0838e6f 100644 --- a/packages/opentelemetry-context-async-hooks/tsconfig.json +++ b/packages/opentelemetry-context-async-hooks/tsconfig.json @@ -7,5 +7,10 @@ "include": [ "src/**/*.ts", "test/**/*.ts" + ], + "references": [ + { + "path": "../../api" + } ] } diff --git a/packages/opentelemetry-context-zone-peer-dep/tsconfig.json b/packages/opentelemetry-context-zone-peer-dep/tsconfig.json index 479d4bc0d2e..da6d2b64867 100644 --- a/packages/opentelemetry-context-zone-peer-dep/tsconfig.json +++ b/packages/opentelemetry-context-zone-peer-dep/tsconfig.json @@ -11,5 +11,10 @@ "include": [ "src/**/*.ts", "test/**/*.ts" + ], + "references": [ + { + "path": "../../api" + } ] } diff --git a/packages/opentelemetry-core/tsconfig.json b/packages/opentelemetry-core/tsconfig.json index 0717beecbfb..101baf4195b 100644 --- a/packages/opentelemetry-core/tsconfig.json +++ b/packages/opentelemetry-core/tsconfig.json @@ -9,6 +9,9 @@ "test/**/*.ts" ], "references": [ + { + "path": "../../api" + }, { "path": "../opentelemetry-semantic-conventions" } diff --git a/packages/opentelemetry-exporter-jaeger/tsconfig.json b/packages/opentelemetry-exporter-jaeger/tsconfig.json index 8b45d214a9a..ce2661c050f 100644 --- a/packages/opentelemetry-exporter-jaeger/tsconfig.json +++ b/packages/opentelemetry-exporter-jaeger/tsconfig.json @@ -9,6 +9,9 @@ "test/**/*.ts" ], "references": [ + { + "path": "../../api" + }, { "path": "../opentelemetry-core" }, diff --git a/packages/opentelemetry-exporter-zipkin/tsconfig.json b/packages/opentelemetry-exporter-zipkin/tsconfig.json index 8b45d214a9a..ce2661c050f 100644 --- a/packages/opentelemetry-exporter-zipkin/tsconfig.json +++ b/packages/opentelemetry-exporter-zipkin/tsconfig.json @@ -9,6 +9,9 @@ "test/**/*.ts" ], "references": [ + { + "path": "../../api" + }, { "path": "../opentelemetry-core" }, diff --git a/packages/opentelemetry-propagator-b3/tsconfig.json b/packages/opentelemetry-propagator-b3/tsconfig.json index 789e61fc86b..f60209f8c4c 100644 --- a/packages/opentelemetry-propagator-b3/tsconfig.json +++ b/packages/opentelemetry-propagator-b3/tsconfig.json @@ -9,6 +9,9 @@ "test/**/*.ts" ], "references": [ + { + "path": "../../api" + }, { "path": "../opentelemetry-core" } diff --git a/packages/opentelemetry-propagator-jaeger/tsconfig.json b/packages/opentelemetry-propagator-jaeger/tsconfig.json index a6c0bb26171..a942b2b6aae 100644 --- a/packages/opentelemetry-propagator-jaeger/tsconfig.json +++ b/packages/opentelemetry-propagator-jaeger/tsconfig.json @@ -9,6 +9,9 @@ "test/**/*.ts" ], "references": [ + { + "path": "../../api" + }, { "path": "../opentelemetry-core" } diff --git a/packages/opentelemetry-resources/tsconfig.json b/packages/opentelemetry-resources/tsconfig.json index 51dcc3ed88e..bbd7dbbe437 100644 --- a/packages/opentelemetry-resources/tsconfig.json +++ b/packages/opentelemetry-resources/tsconfig.json @@ -9,6 +9,9 @@ "test/**/*.ts" ], "references": [ + { + "path": "../../api" + }, { "path": "../opentelemetry-core" }, diff --git a/packages/opentelemetry-sdk-trace-base/tsconfig.json b/packages/opentelemetry-sdk-trace-base/tsconfig.json index b16c7037b42..fa14714abdc 100644 --- a/packages/opentelemetry-sdk-trace-base/tsconfig.json +++ b/packages/opentelemetry-sdk-trace-base/tsconfig.json @@ -9,6 +9,9 @@ "test/**/*.ts" ], "references": [ + { + "path": "../../api" + }, { "path": "../opentelemetry-core" }, diff --git a/packages/opentelemetry-sdk-trace-node/tsconfig.json b/packages/opentelemetry-sdk-trace-node/tsconfig.json index 5894551b3d8..837d89d421d 100644 --- a/packages/opentelemetry-sdk-trace-node/tsconfig.json +++ b/packages/opentelemetry-sdk-trace-node/tsconfig.json @@ -9,6 +9,9 @@ "test/**/*.ts" ], "references": [ + { + "path": "../../api" + }, { "path": "../opentelemetry-context-async-hooks" }, diff --git a/packages/opentelemetry-sdk-trace-web/tsconfig.json b/packages/opentelemetry-sdk-trace-web/tsconfig.json index f317cb38d10..09ac19a176d 100644 --- a/packages/opentelemetry-sdk-trace-web/tsconfig.json +++ b/packages/opentelemetry-sdk-trace-web/tsconfig.json @@ -10,6 +10,9 @@ "test/**/*.ts" ], "references": [ + { + "path": "../../api" + }, { "path": "../opentelemetry-context-zone" }, diff --git a/packages/opentelemetry-shim-opentracing/tsconfig.json b/packages/opentelemetry-shim-opentracing/tsconfig.json index a2567652957..0e01f631845 100644 --- a/packages/opentelemetry-shim-opentracing/tsconfig.json +++ b/packages/opentelemetry-shim-opentracing/tsconfig.json @@ -9,6 +9,9 @@ "test/**/*.ts" ], "references": [ + { + "path": "../../api" + }, { "path": "../opentelemetry-core" }, diff --git a/tsconfig.json b/tsconfig.json index 9f3cd60df89..10419db907e 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -4,6 +4,7 @@ "typedocOptions": { "entryPointStrategy": "packages", "entryPoints": [ + "api", "experimental/packages/exporter-trace-otlp-grpc", "experimental/packages/exporter-trace-otlp-http", "experimental/packages/exporter-trace-otlp-proto", @@ -49,6 +50,9 @@ "excludePrivate": true }, "references": [ + { + "path": "api" + }, { "path": "packages/opentelemetry-context-async-hooks" }, From 9bc66f8c406bd2b5bb1b7cd4a30a64cec1cf92d0 Mon Sep 17 00:00:00 2001 From: Daniel Dyla Date: Fri, 16 Sep 2022 07:56:28 -0400 Subject: [PATCH 02/10] Update todo --- api/TODO.md | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/api/TODO.md b/api/TODO.md index 53f2b1c282a..30f67e54ec4 100644 --- a/api/TODO.md +++ b/api/TODO.md @@ -3,9 +3,9 @@ These tasks must be completed before the API package can be released from this repository. - [x] remove files specific to the API git repo -- [ ] add to lerna monorepo - - [ ] add tsconfig files - - [ ] add web testing - - [ ] build esm versions +- [x] add to lerna monorepo + - [x] add tsconfig files + - [x] add web testing + - [x] build esm versions - [ ] test node versions 8, 10, and 12 -- [ ] add to auto published docs +- [x] add to auto published docs From b9e677b7791bf201f1ceac0ad5d175aea851469f Mon Sep 17 00:00:00 2001 From: Daniel Dyla Date: Mon, 19 Sep 2022 16:08:37 -0400 Subject: [PATCH 03/10] Expect instead of ignore error --- api/test/diag/consoleLogger.test.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/api/test/diag/consoleLogger.test.ts b/api/test/diag/consoleLogger.test.ts index 51064fb4560..fd57f118365 100644 --- a/api/test/diag/consoleLogger.test.ts +++ b/api/test/diag/consoleLogger.test.ts @@ -127,7 +127,7 @@ describe('DiagConsoleLogger', () => { consoleFuncs.forEach(cName => { it(`should log ${fName} message even when console doesn't support ${cName} call before construction`, () => { - // @ts-ignore removing a console property is not allowed by types + // @ts-expect-error removing a console property is not allowed by types console[cName] = undefined; const consoleLogger: any = new DiagConsoleLogger(); consoleLogger[fName](`${fName} called %s`, 'param1'); @@ -143,7 +143,7 @@ describe('DiagConsoleLogger', () => { it(`should log ${fName} message even when console doesn't support ${cName} call after construction`, () => { const consoleLogger: any = new DiagConsoleLogger(); - // @ts-ignore removing a console property is not allowed by types + // @ts-expect-error removing a console property is not allowed by types console[cName] = undefined; consoleLogger[fName](`${fName} called %s`, 'param1'); if (cName !== expectedConsoleMap[fName]) { From 1a32670f9130054d70593e71415aba903b5c05ff Mon Sep 17 00:00:00 2001 From: Daniel Dyla Date: Mon, 19 Sep 2022 16:10:49 -0400 Subject: [PATCH 04/10] Add webpack test context --- api/test/index-webpack.worker.ts | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 api/test/index-webpack.worker.ts diff --git a/api/test/index-webpack.worker.ts b/api/test/index-webpack.worker.ts new file mode 100644 index 00000000000..4ee65b7b123 --- /dev/null +++ b/api/test/index-webpack.worker.ts @@ -0,0 +1,18 @@ +/* + * Copyright The 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 + * + * https://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. + */ + +const testsContext = require.context('./', false, /test$/); +testsContext.keys().forEach(testsContext); From f2f8e847150fac67cf3d4fe05b6f6962658ab260 Mon Sep 17 00:00:00 2001 From: Daniel Dyla Date: Mon, 19 Sep 2022 16:51:42 -0400 Subject: [PATCH 05/10] Block scope test variables --- api/test/index-webpack.ts | 12 ++++++++---- api/test/index-webpack.worker.ts | 7 ++++--- 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/api/test/index-webpack.ts b/api/test/index-webpack.ts index 061a48ccfa7..1d39d663fe4 100644 --- a/api/test/index-webpack.ts +++ b/api/test/index-webpack.ts @@ -13,8 +13,12 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -const testsContext = require.context('.', true, /test$/); -testsContext.keys().forEach(testsContext); +{ + const testsContext = require.context('.', true, /test$/); + testsContext.keys().forEach(testsContext); +} -const srcContext = require.context('.', true, /src$/); -srcContext.keys().forEach(srcContext); +{ + const srcContext = require.context('.', true, /src$/); + srcContext.keys().forEach(srcContext); +} \ No newline at end of file diff --git a/api/test/index-webpack.worker.ts b/api/test/index-webpack.worker.ts index 4ee65b7b123..5e97a801878 100644 --- a/api/test/index-webpack.worker.ts +++ b/api/test/index-webpack.worker.ts @@ -13,6 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - -const testsContext = require.context('./', false, /test$/); -testsContext.keys().forEach(testsContext); +{ + const testsContext = require.context('./', false, /test$/); + testsContext.keys().forEach(testsContext); +} \ No newline at end of file From a518ca79a38188ade0c75362c0d629fbd2a52205 Mon Sep 17 00:00:00 2001 From: Daniel Dyla Date: Mon, 19 Sep 2022 17:08:45 -0400 Subject: [PATCH 06/10] Fix linting --- api/.eslintrc.js | 8 ++++++++ api/package.json | 4 ++-- 2 files changed, 10 insertions(+), 2 deletions(-) create mode 100644 api/.eslintrc.js diff --git a/api/.eslintrc.js b/api/.eslintrc.js new file mode 100644 index 00000000000..b9004d20258 --- /dev/null +++ b/api/.eslintrc.js @@ -0,0 +1,8 @@ +module.exports = { + "env": { + "mocha": true, + "commonjs": true, + "shared-node-browser": true + }, + ...require('../../../eslint.config.js') +} diff --git a/api/package.json b/api/package.json index 15fcae3c6cc..012fd629ef4 100644 --- a/api/package.json +++ b/api/package.json @@ -21,8 +21,8 @@ "docs": "typedoc", "docs:deploy": "gh-pages --dist docs/out", "docs:test": "linkinator docs/out --silent && linkinator docs/*.md *.md --markdown --silent", - "lint:fix": "eslint src test --ext .ts --fix", - "lint": "eslint src test --ext .ts", + "lint:fix": "eslint . --ext .ts --fix", + "lint": "eslint . --ext .ts", "test:browser": "nyc karma start --single-run", "test": "nyc ts-mocha -p tsconfig.json test/**/*.test.ts", "test:webworker": "nyc karma start karma.worker.js --single-run", From 235d6dac56e4827fd14febe091f498b5afd2e4c2 Mon Sep 17 00:00:00 2001 From: Daniel Dyla Date: Mon, 19 Sep 2022 17:16:07 -0400 Subject: [PATCH 07/10] Fix lining path --- api/.eslintrc.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/api/.eslintrc.js b/api/.eslintrc.js index b9004d20258..7d5c10c7f97 100644 --- a/api/.eslintrc.js +++ b/api/.eslintrc.js @@ -4,5 +4,5 @@ module.exports = { "commonjs": true, "shared-node-browser": true }, - ...require('../../../eslint.config.js') + ...require('../eslint.config.js') } From 3a3e5fe445d06e9b99f58248cb9477e4bbdc1afb Mon Sep 17 00:00:00 2001 From: Daniel Dyla Date: Tue, 20 Sep 2022 08:10:43 -0400 Subject: [PATCH 08/10] Fix lint --- api/src/platform/browser/globalThis.ts | 6 +++--- api/test/api/api.test.ts | 2 +- api/test/index-webpack.ts | 10 +++++----- api/test/index-webpack.worker.ts | 6 +++--- 4 files changed, 12 insertions(+), 12 deletions(-) diff --git a/api/src/platform/browser/globalThis.ts b/api/src/platform/browser/globalThis.ts index ebea1f48c59..68ca8ac5ff9 100644 --- a/api/src/platform/browser/globalThis.ts +++ b/api/src/platform/browser/globalThis.ts @@ -29,7 +29,7 @@ // eslint-disable-next-line node/no-unsupported-features/es-builtins, no-undef export const _globalThis: typeof globalThis = typeof globalThis === 'object' ? globalThis : - typeof self === 'object' ? self : - typeof window === 'object' ? window : - typeof global === 'object' ? global : + typeof self === 'object' ? self : + typeof window === 'object' ? window : + typeof global === 'object' ? global : {} as typeof globalThis; diff --git a/api/test/api/api.test.ts b/api/test/api/api.test.ts index 4f51462a18d..9b5570b7634 100644 --- a/api/test/api/api.test.ts +++ b/api/test/api/api.test.ts @@ -56,7 +56,7 @@ describe('API', () => { const span = new NonRecordingSpan(); const ctx = trace.setSpan(ROOT_CONTEXT, span); context.setGlobalContextManager({ active: () => ctx, disable: () => {} } as any); - + const active = trace.getActiveSpan(); assert.strictEqual(active, span); diff --git a/api/test/index-webpack.ts b/api/test/index-webpack.ts index 1d39d663fe4..856be100b22 100644 --- a/api/test/index-webpack.ts +++ b/api/test/index-webpack.ts @@ -14,11 +14,11 @@ * limitations under the License. */ { - const testsContext = require.context('.', true, /test$/); - testsContext.keys().forEach(testsContext); + const testsContext = require.context('.', true, /test$/); + testsContext.keys().forEach(testsContext); } { - const srcContext = require.context('.', true, /src$/); - srcContext.keys().forEach(srcContext); -} \ No newline at end of file + const srcContext = require.context('.', true, /src$/); + srcContext.keys().forEach(srcContext); +} diff --git a/api/test/index-webpack.worker.ts b/api/test/index-webpack.worker.ts index 5e97a801878..8fbdecb6a1b 100644 --- a/api/test/index-webpack.worker.ts +++ b/api/test/index-webpack.worker.ts @@ -14,6 +14,6 @@ * limitations under the License. */ { - const testsContext = require.context('./', false, /test$/); - testsContext.keys().forEach(testsContext); -} \ No newline at end of file + const testsContext = require.context('./', false, /test$/); + testsContext.keys().forEach(testsContext); +} From 03fc3898c0e3195dbdf67aaa53b14a3208a87cfb Mon Sep 17 00:00:00 2001 From: Daniel Dyla Date: Tue, 20 Sep 2022 08:19:16 -0400 Subject: [PATCH 09/10] Fix lint --- api/src/platform/browser/globalThis.ts | 6 +++--- api/src/trace/NoopTracer.ts | 8 ++++---- api/test/api/api.test.ts | 2 +- api/test/index-webpack.ts | 10 +++++----- api/test/index-webpack.worker.ts | 6 +++--- 5 files changed, 16 insertions(+), 16 deletions(-) diff --git a/api/src/platform/browser/globalThis.ts b/api/src/platform/browser/globalThis.ts index ebea1f48c59..68ca8ac5ff9 100644 --- a/api/src/platform/browser/globalThis.ts +++ b/api/src/platform/browser/globalThis.ts @@ -29,7 +29,7 @@ // eslint-disable-next-line node/no-unsupported-features/es-builtins, no-undef export const _globalThis: typeof globalThis = typeof globalThis === 'object' ? globalThis : - typeof self === 'object' ? self : - typeof window === 'object' ? window : - typeof global === 'object' ? global : + typeof self === 'object' ? self : + typeof window === 'object' ? window : + typeof global === 'object' ? global : {} as typeof globalThis; diff --git a/api/src/trace/NoopTracer.ts b/api/src/trace/NoopTracer.ts index d1db93e9cfe..7e9aa65a482 100644 --- a/api/src/trace/NoopTracer.ts +++ b/api/src/trace/NoopTracer.ts @@ -24,7 +24,7 @@ import { SpanOptions } from './SpanOptions'; import { SpanContext } from './span_context'; import { Tracer } from './tracer'; -const context = ContextAPI.getInstance(); +const contextApi = ContextAPI.getInstance(); /** * No-op implementations of {@link Tracer}. @@ -87,15 +87,15 @@ export class NoopTracer implements Tracer { fn = arg4 as F; } - const parentContext = ctx ?? context.active(); + const parentContext = ctx ?? contextApi.active(); const span = this.startSpan(name, opts, parentContext); const contextWithSpanSet = setSpan(parentContext, span); - return context.with(contextWithSpanSet, fn, undefined, span); + return contextApi.with(contextWithSpanSet, fn, undefined, span); } } -function isSpanContext(spanContext: any): spanContext is SpanContext { +function isSpanContext(spanContext: unknown): spanContext is SpanContext { return ( typeof spanContext === 'object' && typeof spanContext['spanId'] === 'string' && diff --git a/api/test/api/api.test.ts b/api/test/api/api.test.ts index 4f51462a18d..9b5570b7634 100644 --- a/api/test/api/api.test.ts +++ b/api/test/api/api.test.ts @@ -56,7 +56,7 @@ describe('API', () => { const span = new NonRecordingSpan(); const ctx = trace.setSpan(ROOT_CONTEXT, span); context.setGlobalContextManager({ active: () => ctx, disable: () => {} } as any); - + const active = trace.getActiveSpan(); assert.strictEqual(active, span); diff --git a/api/test/index-webpack.ts b/api/test/index-webpack.ts index 1d39d663fe4..856be100b22 100644 --- a/api/test/index-webpack.ts +++ b/api/test/index-webpack.ts @@ -14,11 +14,11 @@ * limitations under the License. */ { - const testsContext = require.context('.', true, /test$/); - testsContext.keys().forEach(testsContext); + const testsContext = require.context('.', true, /test$/); + testsContext.keys().forEach(testsContext); } { - const srcContext = require.context('.', true, /src$/); - srcContext.keys().forEach(srcContext); -} \ No newline at end of file + const srcContext = require.context('.', true, /src$/); + srcContext.keys().forEach(srcContext); +} diff --git a/api/test/index-webpack.worker.ts b/api/test/index-webpack.worker.ts index 5e97a801878..8fbdecb6a1b 100644 --- a/api/test/index-webpack.worker.ts +++ b/api/test/index-webpack.worker.ts @@ -14,6 +14,6 @@ * limitations under the License. */ { - const testsContext = require.context('./', false, /test$/); - testsContext.keys().forEach(testsContext); -} \ No newline at end of file + const testsContext = require.context('./', false, /test$/); + testsContext.keys().forEach(testsContext); +} From 6224c992d5dbf14acfc2858b0303d7bb423bbe12 Mon Sep 17 00:00:00 2001 From: Nev <54870357+MSNev@users.noreply.github.com> Date: Wed, 21 Sep 2022 09:59:33 -0700 Subject: [PATCH 10/10] Update index-webpack.worker.ts --- api/test/index-webpack.worker.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/api/test/index-webpack.worker.ts b/api/test/index-webpack.worker.ts index 8fbdecb6a1b..d568d570b16 100644 --- a/api/test/index-webpack.worker.ts +++ b/api/test/index-webpack.worker.ts @@ -14,6 +14,6 @@ * limitations under the License. */ { - const testsContext = require.context('./', false, /test$/); + const testsContext = require.context('./', true, /test$/); testsContext.keys().forEach(testsContext); }