Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/backcompat.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020 # v7.0.0
uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7.1.0
with:
node-version: ${{ matrix.node-version }}
- run: npm i
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ jobs:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- run: openssl req -x509 -nodes -newkey rsa -keyout ./test/certs/server-key.pem -out ./test/certs/server-cert.pem -days 1 -subj "/C=CL/ST=RM/L=OpenTelemetryTest/O=Root/OU=Test/CN=ca"
- name: Use Node.js ${{ matrix.node-version.version }}
uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020 # v7.0.0
uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7.1.0
with:
node-version: ${{ matrix.node-version.version }}
- run: npm i
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/node.js-linux-arm64.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ jobs:
openssl req -x509 -nodes -newkey rsa:2048 -keyout ./test/certs/server-key.pem -out ./test/certs/server-cert.pem -days 1 -subj "/C=CL/ST=RM/L=OpenTelemetryTest/O=Root/OU=Test/CN=ca"

- name: Use Node.js ${{ matrix.node-version.version }}
uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020 # v7.0.0
uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7.1.0
with:
node-version: ${{ matrix.node-version.version }}

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/node.js-windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ jobs:
Set-Content -Path "$certsDir\server-key.pem" -Value "-----BEGIN PRIVATE KEY-----`r`n$randomKeyContent`r`n-----END PRIVATE KEY-----"

- name: Use Node.js ${{ matrix.node-version.version }}
uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020 # v7.0.0
uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7.1.0
with:
node-version: ${{ matrix.node-version.version }}

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/node.js.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ jobs:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- run: openssl req -x509 -nodes -newkey rsa -keyout ./test/certs/server-key.pem -out ./test/certs/server-cert.pem -days 1 -subj "/C=CL/ST=RM/L=OpenTelemetryTest/O=Root/OU=Test/CN=ca"
- name: (${{ matrix.os }}) on Node.js ${{ matrix.node-version.version }}
uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020 # v7.0.0
uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7.1.0
with:
node-version: ${{ matrix.node-version.version }}
- run: npm run clean
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/npm-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020 # v7.0.0
- uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7.1.0
with:
node-version: '22.23.4'
- run: npm ci
Expand All @@ -25,7 +25,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020 # v7.0.0
- uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7.1.0
with:
node-version: '22.23.4'
registry-url: https://registry.npmjs.org/
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/performance-comment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ jobs:
- name: Check out base repository (trusted)
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1

- uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020 # v7.0.0
- uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7.1.0
with:
node-version: '22.23.4'

Expand All @@ -50,7 +50,7 @@ jobs:
# Don't fail this job if the upstream Performance run was cancelled
# or failed before producing the artifact — we just skip posting.
continue-on-error: true
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8.0.2
with:
name: perf-results
path: perf-results
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/performance.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ jobs:
ref: ${{ github.event.pull_request.base.ref }}
path: baseline

- uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020 # v7.0.0
- uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7.1.0
with:
node-version: ${{ env.NODE_VERSION }}

Expand Down Expand Up @@ -76,9 +76,9 @@ jobs:
working-directory: pr/test/performanceTests
run: npm install --no-save --no-package-lock "$GITHUB_WORKSPACE/candidate.tgz"

- name: Build perf harness (TS -> dist-esm)
- name: Build perf harness and check memory usage
working-directory: pr/test/performanceTests
run: npm run build
run: npm run test:memory

- name: Run candidate benchmarks
working-directory: pr/test/performanceTests
Expand Down Expand Up @@ -118,7 +118,7 @@ jobs:

- name: Upload perf results artifact
if: always()
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2
with:
name: perf-results
path: |
Expand Down
15 changes: 12 additions & 3 deletions test/performanceTests/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,20 @@ Only **gating** scenarios block CI on regression. Upstream-OTel scenarios are
reported as a reference for like-for-like comparison and are not owned by this
repo, so they are never used for gate-fail decisions.

The upstream-OTel scenarios keep their simple processors but export to a
synchronous discard sink. This measures SDK processing without retaining every
span or log record, or accumulating timer-backed export callbacks, across warmup
and samples. Scenario failures still fail the benchmark run regardless of tier.

Run `npm run test:memory` from this directory to check that both upstream-OTel
scenarios complete warmup and three samples with a 64 MiB old-space limit.

#### Regression CI

`.github/workflows/performance.yml` runs on every PR. It packs both the PR and
the base branch as tarballs, installs each in turn under the PR's perf harness,
runs the benchmark suite, and fails the job (blocking merge when set as a
`.github/workflows/performance.yml` runs the memory checks and benchmarks on
every PR. It packs both the PR and the base branch as tarballs, installs each
in turn under the PR's perf harness, runs the benchmark suite, and fails the
job (blocking merge when set as a
required check) if any gating scenario regresses beyond
`PERF_REGRESSION_THRESHOLD` percent (default 15%). All benchmark results are
uploaded as the `perf-results` artifact.
Expand Down
45 changes: 45 additions & 0 deletions test/performanceTests/benchmarkMemory.test.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.

import assert from "node:assert/strict";
import { spawnSync } from "node:child_process";
import { mkdtempSync, readFileSync, rmSync } from "node:fs";
import { tmpdir } from "node:os";
import { join } from "node:path";
import { test } from "node:test";
import { fileURLToPath } from "node:url";

for (const scenario of ["OtelSpanTest", "OtelLogTest"]) {
test(`${scenario} completes multiple samples with a bounded heap`, () => {
const tmp = mkdtempSync(join(tmpdir(), "perf-memory-"));
try {
const out = join(tmp, "samples.json");
const child = spawnSync(
process.execPath,
[
"--max-old-space-size=64",
fileURLToPath(new URL("./bench.mjs", import.meta.url)),
"--scenario", scenario,
"--samples", "3",
"--duration", "1",
"--warmup", "1",
"--out", out,
],
{ encoding: "utf8", timeout: 30000 },
);
assert.ifError(child.error);
assert.equal(child.signal, null, child.stderr);
assert.equal(child.status, 0, child.stderr);
const result = JSON.parse(readFileSync(out, "utf8"));
assert.equal(result.scenario, scenario);
assert.equal(result.samples.length, 3);
for (const sample of result.samples) {
assert.ok(sample.ops > 0);
assert.ok(sample.elapsedMs >= 1000);
assert.ok(Number.isFinite(sample.opsPerSec) && sample.opsPerSec > 0);
}
} finally {
rmSync(tmp, { recursive: true, force: true });
}
});
}
1 change: 1 addition & 0 deletions test/performanceTests/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions test/performanceTests/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
"@azure-tools/test-perf": "^1.0.0",
"@opentelemetry/api": "^1.9.1",
"@opentelemetry/api-logs": "^0.221.0",
"@opentelemetry/core": "^2.10.0",
"@opentelemetry/sdk-logs": "^0.221.0",
"@opentelemetry/sdk-trace-base": "^2.10.0",
"applicationinsights": "^3.16.0",
Expand All @@ -32,6 +33,7 @@
"perf-test:node": "npm run build && node dist-esm/index.spec.js",
"perf:benchmark": "npm run build && node runBenchmarks.mjs",
"perf:compare": "node comparePerf.mjs",
"test:memory": "npm run build && node --test benchmarkMemory.test.mjs",
"audit": "node ../../../common/scripts/rush-audit.js && rimraf node_modules package-lock.json && npm i --package-lock-only 2>&1 && npm audit",
"build": "npm run clean && tsc -p .",
"build:samples": "echo skipped",
Expand Down
24 changes: 24 additions & 0 deletions test/performanceTests/test/discardingExporter.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.

import { ExportResultCode, type ExportResult } from "@opentelemetry/core";
import type { LogRecordExporter, ReadableLogRecord } from "@opentelemetry/sdk-logs";
import type { ReadableSpan, SpanExporter } from "@opentelemetry/sdk-trace-base";

export class DiscardingExporter implements SpanExporter, LogRecordExporter {
export(
_items: ReadableSpan[] | ReadableLogRecord[],
resultCallback: (result: ExportResult) => void,
): void {
// Retain neither telemetry nor timer callbacks across benchmark samples.
resultCallback({ code: ExportResultCode.SUCCESS });
}

forceFlush(): Promise<void> {
return Promise.resolve();
}

shutdown(): Promise<void> {
return Promise.resolve();
}
}
4 changes: 2 additions & 2 deletions test/performanceTests/test/otelLog.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ import type { Logger } from "@opentelemetry/api-logs";
import {
LoggerProvider,
SimpleLogRecordProcessor,
InMemoryLogRecordExporter,
} from "@opentelemetry/sdk-logs";
import { DiscardingExporter } from "./discardingExporter.js";

type OtelLogOptions = Record<string, unknown>;

Expand All @@ -24,7 +24,7 @@ function ensureProvider(): Logger {
return logger;
}
const provider = new LoggerProvider({
processors: [new SimpleLogRecordProcessor({ exporter: new InMemoryLogRecordExporter() })],
processors: [new SimpleLogRecordProcessor({ exporter: new DiscardingExporter() })],
});
logger = provider.getLogger("perf-otel-log");
return logger;
Expand Down
4 changes: 2 additions & 2 deletions test/performanceTests/test/otelSpan.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ import type { Tracer } from "@opentelemetry/api";
import {
BasicTracerProvider,
SimpleSpanProcessor,
InMemorySpanExporter,
} from "@opentelemetry/sdk-trace-base";
import { DiscardingExporter } from "./discardingExporter.js";

type OtelSpanOptions = Record<string, unknown>;

Expand All @@ -24,7 +24,7 @@ function ensureProvider(): Tracer {
return tracer;
}
const provider = new BasicTracerProvider({
spanProcessors: [new SimpleSpanProcessor(new InMemorySpanExporter())],
spanProcessors: [new SimpleSpanProcessor(new DiscardingExporter())],
});
tracer = provider.getTracer("perf-otel-span");
return tracer;
Expand Down
Loading