Skip to content

Commit

Permalink
Merge branch 'main' into docs-add-docker-compose-to-run-prometheus-fo…
Browse files Browse the repository at this point in the history
…r-experiemental-example
  • Loading branch information
pichlermarc authored Nov 9, 2023
2 parents 92fff02 + f2b447d commit 1cd8ff3
Show file tree
Hide file tree
Showing 13 changed files with 149 additions and 40 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
1 change: 1 addition & 0 deletions experimental/packages/otlp-transformer/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
}
17 changes: 1 addition & 16 deletions lerna.json
Original file line number Diff line number Diff line change
@@ -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
}
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,6 @@
},
"cacheDir": ".changelog"
},
"// workspaces": "Please sync with lerna.json#packages",
"workspaces": [
"api",
"packages/*",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
* limitations under the License.
*/

/// <reference types="zone.js" />
import { Context, ContextManager, ROOT_CONTEXT } from '@opentelemetry/api';
import { TargetWithEvents } from './types';
import { isListenerObject } from './util';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"
],
Expand Down
3 changes: 0 additions & 3 deletions packages/opentelemetry-context-zone-peer-dep/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,6 @@
"outDir": "build",
"rootDir": "."
},
"files": [
"node_modules/zone.js/dist/zone.js.d.ts"
],
"include": [
"src/**/*.ts",
"test/**/*.ts"
Expand Down
Original file line number Diff line number Diff line change
@@ -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();
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,4 @@
*/

require('./span');
require('./BatchSpanProcessor');
Original file line number Diff line number Diff line change
Expand Up @@ -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();
28 changes: 14 additions & 14 deletions scripts/update-ts-configs.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -97,24 +97,24 @@ 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);

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 => {
Expand Down Expand Up @@ -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;
}
Expand Down

0 comments on commit 1cd8ff3

Please sign in to comment.