diff --git a/CHANGELOG.md b/CHANGELOG.md index 887ccf13a3..b4b570dad4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -15,6 +15,11 @@ For experimental package changes, see the [experimental CHANGELOG](experimental/ ### :house: (Internal) +* chore: type reference on zone.js [#4257](https://github.com/open-telemetry/opentelemetry-js/pull/4257) @legendecas +* chore: no need for 'packages' in lerna.json [#4264](https://github.com/open-telemetry/opentelemetry-js/pull/4264) @trentm + +### :bug: (Bug Fix) + ## 1.18.1 ### :bug: (Bug Fix) diff --git a/experimental/packages/otlp-transformer/package.json b/experimental/packages/otlp-transformer/package.json index 7570d15051..04ee4c802e 100644 --- a/experimental/packages/otlp-transformer/package.json +++ b/experimental/packages/otlp-transformer/package.json @@ -21,6 +21,7 @@ "tdd": "npm run test -- --watch-extensions ts --watch", "test": "nyc ts-mocha -p tsconfig.json 'test/**/*.test.ts'", "test:browser": "karma start --single-run", + "test:bench": "node test/performance/benchmark/index.js | tee .benchmark-results.txt", "prewatch": "node ../../../scripts/version-update.js", "watch": "tsc --build -w tsconfig.json tsconfig.esm.json tsconfig.esnext.json", "peer-api-check": "node ../../../scripts/peer-api-check.js", diff --git a/experimental/packages/otlp-transformer/test/performance/benchmark/index.js b/experimental/packages/otlp-transformer/test/performance/benchmark/index.js new file mode 100644 index 0000000000..e110bbe784 --- /dev/null +++ b/experimental/packages/otlp-transformer/test/performance/benchmark/index.js @@ -0,0 +1,61 @@ +/* + * 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 Benchmark = require('benchmark'); +const { createExportTraceServiceRequest } = require('../../../build/src'); +const { BasicTracerProvider } = require('@opentelemetry/sdk-trace-base'); + +const tracerProvider = new BasicTracerProvider(); +const tracer = tracerProvider.getTracer('test') + +const suite = new Benchmark.Suite(); + +const span = createSpan(); +const spans = []; +for (let i = 0; i < 100; i++) { + spans.push(createSpan()); +} + +suite.on('cycle', event => { + console.log(String(event.target)); +}); + +suite.add('transform 1 span', function() { + createExportTraceServiceRequest([span]); +}); + +suite.add('transform 100 spans', function() { + createExportTraceServiceRequest(spans); +}); + +suite.run(); + +function createSpan() { + const span = tracer.startSpan('span'); + span.setAttribute('aaaaaaaaaaaaaaaaaaaa', 'aaaaaaaaaaaaaaaaaaaa'); + span.setAttribute('bbbbbbbbbbbbbbbbbbbb', 'bbbbbbbbbbbbbbbbbbbb'); + span.setAttribute('cccccccccccccccccccc', 'cccccccccccccccccccc'); + span.setAttribute('dddddddddddddddddddd', 'dddddddddddddddddddd'); + span.setAttribute('eeeeeeeeeeeeeeeeeeee', 'eeeeeeeeeeeeeeeeeeee'); + span.setAttribute('ffffffffffffffffffff', 'ffffffffffffffffffff'); + span.setAttribute('gggggggggggggggggggg', 'gggggggggggggggggggg'); + span.setAttribute('hhhhhhhhhhhhhhhhhhhh', 'hhhhhhhhhhhhhhhhhhhh'); + span.setAttribute('iiiiiiiiiiiiiiiiiiii', 'iiiiiiiiiiiiiiiiiiii'); + span.setAttribute('jjjjjjjjjjjjjjjjjjjj', 'jjjjjjjjjjjjjjjjjjjj'); + span.end(); + + return span; +} diff --git a/lerna.json b/lerna.json index 4e03ac4f79..336c3e85ca 100644 --- a/lerna.json +++ b/lerna.json @@ -1,20 +1,5 @@ { "version": "independent", "npmClient": "npm", - "useWorkspaces": true, - "// packages": "Please sync with package.json#workspaces", - "packages": [ - "api", - "packages/*", - "experimental/packages/*", - "experimental/examples/*", - "experimental/backwards-compatibility/*", - "integration-tests/*", - "selenium-tests", - "examples/otlp-exporter-node", - "examples/opentelemetry-web", - "examples/http", - "examples/https", - "examples/esm-http-ts" - ] + "useWorkspaces": true } diff --git a/package.json b/package.json index bfc13ff392..7e7cb81ade 100644 --- a/package.json +++ b/package.json @@ -102,7 +102,6 @@ }, "cacheDir": ".changelog" }, - "// workspaces": "Please sync with lerna.json#packages", "workspaces": [ "api", "packages/*", diff --git a/packages/opentelemetry-context-zone-peer-dep/src/ZoneContextManager.ts b/packages/opentelemetry-context-zone-peer-dep/src/ZoneContextManager.ts index 3f5c8c71c8..81042ac652 100644 --- a/packages/opentelemetry-context-zone-peer-dep/src/ZoneContextManager.ts +++ b/packages/opentelemetry-context-zone-peer-dep/src/ZoneContextManager.ts @@ -14,6 +14,7 @@ * limitations under the License. */ +/// import { Context, ContextManager, ROOT_CONTEXT } from '@opentelemetry/api'; import { TargetWithEvents } from './types'; import { isListenerObject } from './util'; diff --git a/packages/opentelemetry-context-zone-peer-dep/tsconfig.esm.json b/packages/opentelemetry-context-zone-peer-dep/tsconfig.esm.json index 971caf60aa..9d9e733405 100644 --- a/packages/opentelemetry-context-zone-peer-dep/tsconfig.esm.json +++ b/packages/opentelemetry-context-zone-peer-dep/tsconfig.esm.json @@ -5,9 +5,6 @@ "rootDir": "src", "tsBuildInfoFile": "build/esm/tsconfig.esm.tsbuildinfo" }, - "files": [ - "node_modules/zone.js/dist/zone.js.d.ts" - ], "include": [ "src/**/*.ts" ], diff --git a/packages/opentelemetry-context-zone-peer-dep/tsconfig.esnext.json b/packages/opentelemetry-context-zone-peer-dep/tsconfig.esnext.json index ff768ce18a..9f2935984e 100644 --- a/packages/opentelemetry-context-zone-peer-dep/tsconfig.esnext.json +++ b/packages/opentelemetry-context-zone-peer-dep/tsconfig.esnext.json @@ -5,9 +5,6 @@ "rootDir": "src", "tsBuildInfoFile": "build/esnext/tsconfig.esnext.tsbuildinfo" }, - "files": [ - "node_modules/zone.js/dist/zone.js.d.ts" - ], "include": [ "src/**/*.ts" ], diff --git a/packages/opentelemetry-context-zone-peer-dep/tsconfig.json b/packages/opentelemetry-context-zone-peer-dep/tsconfig.json index a4adfa3f7f..7e466ec926 100644 --- a/packages/opentelemetry-context-zone-peer-dep/tsconfig.json +++ b/packages/opentelemetry-context-zone-peer-dep/tsconfig.json @@ -4,9 +4,6 @@ "outDir": "build", "rootDir": "." }, - "files": [ - "node_modules/zone.js/dist/zone.js.d.ts" - ], "include": [ "src/**/*.ts", "test/**/*.ts" diff --git a/packages/opentelemetry-sdk-trace-base/test/performance/benchmark/BatchSpanProcessor.js b/packages/opentelemetry-sdk-trace-base/test/performance/benchmark/BatchSpanProcessor.js new file mode 100644 index 0000000000..ccdb82d481 --- /dev/null +++ b/packages/opentelemetry-sdk-trace-base/test/performance/benchmark/BatchSpanProcessor.js @@ -0,0 +1,64 @@ +/* + * 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 Benchmark = require('benchmark'); +const { BasicTracerProvider, BatchSpanProcessor } = require('../../../build/src'); +const { ExportResultCode } = require('@opentelemetry/core'); + +class NoopExporter { + export(spans, resultCallback) { + setTimeout(() => resultCallback({ code: ExportResultCode.SUCCESS }), 0); + } + + shutdown() { + return this.forceFlush(); + } + + forceFlush() { + return Promise.resolve(); + } +} + +function createSpan() { + const span = tracer.startSpan('span'); + span.setAttribute('aaaaaaaaaaaaaaaaaaaa', 'aaaaaaaaaaaaaaaaaaaa'); + span.setAttribute('bbbbbbbbbbbbbbbbbbbb', 'aaaaaaaaaaaaaaaaaaaa'); + span.setAttribute('cccccccccccccccccccc', 'aaaaaaaaaaaaaaaaaaaa'); + span.setAttribute('dddddddddddddddddddd', 'aaaaaaaaaaaaaaaaaaaa'); + span.setAttribute('eeeeeeeeeeeeeeeeeeee', 'aaaaaaaaaaaaaaaaaaaa'); + span.setAttribute('ffffffffffffffffffff', 'aaaaaaaaaaaaaaaaaaaa'); + span.setAttribute('gggggggggggggggggggg', 'aaaaaaaaaaaaaaaaaaaa'); + span.setAttribute('hhhhhhhhhhhhhhhhhhhh', 'aaaaaaaaaaaaaaaaaaaa'); + span.setAttribute('iiiiiiiiiiiiiiiiiiii', 'aaaaaaaaaaaaaaaaaaaa'); + span.setAttribute('jjjjjjjjjjjjjjjjjjjj', 'aaaaaaaaaaaaaaaaaaaa'); + span.end(); +} + +const tracerProvider = new BasicTracerProvider(); +tracerProvider.addSpanProcessor(new BatchSpanProcessor(new NoopExporter())); +const tracer = tracerProvider.getTracer('test') + +const suite = new Benchmark.Suite('BatchSpanProcessor'); + +suite.on('cycle', event => { + console.log(String(event.target)); +}); + +suite.add('BatchSpanProcessor process span', function() { + createSpan(); +}); + +suite.run(); diff --git a/packages/opentelemetry-sdk-trace-base/test/performance/benchmark/index.js b/packages/opentelemetry-sdk-trace-base/test/performance/benchmark/index.js index 83558ea01f..1307732495 100644 --- a/packages/opentelemetry-sdk-trace-base/test/performance/benchmark/index.js +++ b/packages/opentelemetry-sdk-trace-base/test/performance/benchmark/index.js @@ -15,3 +15,4 @@ */ require('./span'); +require('./BatchSpanProcessor'); diff --git a/packages/opentelemetry-sdk-trace-base/test/performance/benchmark/span.js b/packages/opentelemetry-sdk-trace-base/test/performance/benchmark/span.js index ac978a6140..851123c392 100644 --- a/packages/opentelemetry-sdk-trace-base/test/performance/benchmark/span.js +++ b/packages/opentelemetry-sdk-trace-base/test/performance/benchmark/span.js @@ -38,6 +38,7 @@ suite.add('create spans (10 attributes)', function() { span.setAttribute('hhhhhhhhhhhhhhhhhhhh', 'aaaaaaaaaaaaaaaaaaaa'); span.setAttribute('iiiiiiiiiiiiiiiiiiii', 'aaaaaaaaaaaaaaaaaaaa'); span.setAttribute('jjjjjjjjjjjjjjjjjjjj', 'aaaaaaaaaaaaaaaaaaaa'); + span.end(); }); suite.run(); diff --git a/scripts/update-ts-configs.js b/scripts/update-ts-configs.js index d437172181..bc3319f4de 100644 --- a/scripts/update-ts-configs.js +++ b/scripts/update-ts-configs.js @@ -71,23 +71,23 @@ main(); function main() { const pkgRoot = process.cwd(); const projectRoot = findProjectRoot(pkgRoot); - const lernaPackages = resolveLernaPackages(projectRoot); + const workspacePackages = resolveWorkspacePackages(projectRoot); - generateTsConfig(projectRoot, lernaPackages, pkgRoot, true); - for (const packageMeta of lernaPackages.values()) { - generateTsConfig(projectRoot, lernaPackages, path.join(projectRoot, packageMeta.dir), false, packageMeta); + generateTsConfig(projectRoot, workspacePackages, pkgRoot, true); + for (const packageMeta of workspacePackages.values()) { + generateTsConfig(projectRoot, workspacePackages, path.join(projectRoot, packageMeta.dir), false, packageMeta); } } -function generateTsConfig(projectRoot, lernaProjects, pkgRoot, isLernaRoot, packageMeta) { +function generateTsConfig(projectRoot, workspacePackages, pkgRoot, isLernaRoot, packageMeta) { // Root tsconfig.json if (isLernaRoot) { - writeRootTsConfigJson(pkgRoot, projectRoot, lernaProjects); + writeRootTsConfigJson(pkgRoot, projectRoot, workspacePackages); return; } const otelDependencies = getOtelDependencies(packageMeta.pkgJson); - const dependenciesDir = resolveDependencyDirs(lernaProjects, otelDependencies); + const dependenciesDir = resolveDependencyDirs(workspacePackages, otelDependencies); const references = dependenciesDir.map(it => path.relative(pkgRoot, path.join(projectRoot, it))).sort(); if (packageMeta.hasMultiTarget) { @@ -97,16 +97,16 @@ function generateTsConfig(projectRoot, lernaProjects, pkgRoot, isLernaRoot, pack writeSingleTargetTsConfig(pkgRoot, projectRoot, references); } -function writeRootTsConfigJson(pkgRoot, projectRoot, lernaProjects) { +function writeRootTsConfigJson(pkgRoot, projectRoot, workspacePackages) { const tsconfigPath = path.join(pkgRoot, 'tsconfig.json'); const tsconfig = readJSON(tsconfigPath); - const references = Array.from(lernaProjects.values()) + const references = Array.from(workspacePackages.values()) .filter(it => it.isTsProject) .map(it => toPosix(path.relative(pkgRoot, path.join(projectRoot, it.dir)))).sort(); tsconfig.references = references.map(path => { return { path: toPosix(path) } }); - tsconfig.typedocOptions.entryPoints = Array.from(lernaProjects.values()) + tsconfig.typedocOptions.entryPoints = Array.from(workspacePackages.values()) .filter(it => !it.private && it.isTsProject) .map(it => toPosix(path.relative(pkgRoot, path.join(projectRoot, it.dir)))).sort(); writeJSON(tsconfigPath, tsconfig, dryRun); @@ -114,7 +114,7 @@ function writeRootTsConfigJson(pkgRoot, projectRoot, lernaProjects) { for (const tsconfigName of ['tsconfig.esm.json', 'tsconfig.esnext.json']) { const tsconfigPath = path.join(pkgRoot, tsconfigName); const tsconfig = readJSON(tsconfigPath); - const references = Array.from(lernaProjects.values()) + const references = Array.from(workspacePackages.values()) .filter(it => it.isTsProject && it.hasMultiTarget) .map(it => toPosix(path.relative(pkgRoot, path.join(projectRoot, it.dir)))).sort(); tsconfig.references = references.map(pkgPath => { @@ -182,10 +182,10 @@ function getOtelDependencies(packageJson) { return Array.from(deps.values()); } -function resolveLernaPackages(projectRoot) { +function resolveWorkspacePackages(projectRoot) { const map = new Map(); - const lernaJson = readJSON(`${projectRoot}/lerna.json`); - for (const pkgDefinition of lernaJson.packages) { + const packageJson = readJSON(`${projectRoot}/package.json`); + for (const pkgDefinition of packageJson.workspaces) { if (ignoredLernaProjects.includes(pkgDefinition)) { continue; }