Skip to content

feat: update proto to 1.7.0 #5643

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 48 commits into from
May 28, 2025
Merged
Show file tree
Hide file tree
Changes from 47 commits
Commits
Show all changes
48 commits
Select commit Hold shift + click to select a range
b94565c
Update proto to v1.6.0
dyladan May 2, 2025
5c9c43e
Docs and changelog
dyladan May 2, 2025
f16c665
Add e2e tests
dyladan May 23, 2025
95a11bc
Run e2e tests in workflow
dyladan May 23, 2025
0b555a9
Remove unused test script
dyladan May 23, 2025
d082b54
More specific changelog
dyladan May 23, 2025
eb0784e
Setup node before tests
dyladan May 23, 2025
381f4ad
cd to e2e
dyladan May 23, 2025
221c2c9
Use working dir instead of cd
dyladan May 23, 2025
1cc9d6a
Don't use docker in github
dyladan May 23, 2025
494f569
Use relative path for output json
dyladan May 23, 2025
59f13d9
Kill collector before jq
dyladan May 23, 2025
1641815
Ignore blank lines
dyladan May 23, 2025
1916a45
Use relative path
dyladan May 23, 2025
d13b863
Use cat for output
dyladan May 23, 2025
742afa4
fix tests and add deps
dyladan May 23, 2025
27c3346
Verify metric value
dyladan May 23, 2025
2c6824c
Test metric value
dyladan May 23, 2025
65d27fe
Merge branch 'main' into update-proto
dyladan May 23, 2025
5e1a34d
Update to 1.7.0 and remove unused submodules.md
dyladan May 27, 2025
e04a0d7
Merge branch 'update-proto' of github.com:dynatrace-oss-contrib/opent…
dyladan May 27, 2025
d604d80
Bump protocol version in readme
dyladan May 27, 2025
b2eee2b
Use log record processor instead of provider
dyladan May 27, 2025
b517b7f
Wording nit
dyladan May 27, 2025
34564a4
Use js for verify
dyladan May 27, 2025
ad1531d
File extension
dyladan May 27, 2025
172da95
Clean up configs
dyladan May 27, 2025
c57025b
Delete old file
dyladan May 27, 2025
2880c16
Remove unsafe perm env
dyladan May 27, 2025
709b63d
Merge branch 'main' into update-proto
dyladan May 27, 2025
0221020
Changelog update
dyladan May 27, 2025
d0c1855
Rename dir e2e-tests
dyladan May 27, 2025
3b9dbde
Verify after make all
dyladan May 27, 2025
f34e854
Lint verification script
dyladan May 27, 2025
a940403
Add e2e test script
dyladan May 27, 2025
ee8d136
2 space indent
dyladan May 27, 2025
9c0382f
Merge branch 'update-proto' of github.com:dynatrace-oss-contrib/opent…
dyladan May 27, 2025
3f4d9fe
Fix package-lock
dyladan May 27, 2025
5dcbc9b
Fix package name
dyladan May 27, 2025
35e3724
Pin versions for tests
dyladan May 27, 2025
733a3f8
Update experimental/CHANGELOG.md
pichlermarc May 28, 2025
5af0a0c
Add readme for e2e tests
dyladan May 28, 2025
7a75cfe
Merge branch 'update-proto' of github.com:dynatrace-oss-contrib/opent…
dyladan May 28, 2025
eee1171
Lint
dyladan May 28, 2025
1197cd7
Merge remote-tracking branch 'origin/main' into update-proto
dyladan May 28, 2025
e3a3702
Convert makefile to npm scripts
dyladan May 28, 2025
8fded0f
Col not running in docker in actions
dyladan May 28, 2025
4833cea
Remove make references from readme
dyladan May 28, 2025
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
73 changes: 73 additions & 0 deletions .github/workflows/e2e.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
name: E2E Tests

on:
push:
branches: [main]
pull_request:

jobs:
e2e-tests:
strategy:
fail-fast: false
matrix:
node_version:
- "18.19.0"
- "18"
- "20.6.0"
- "20"
- "22"
- "23"
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- uses: actions/setup-node@v4
with:
cache: 'npm'
cache-dependency-path: |
package-lock.json
node-version: ${{ matrix.node_version }}

# npm@11.0.0 drops support for Node.js v18
# Install the latest npm compatible with this version of Node.js
# - npm@11.1.0 supports: {"node":"^20.17.0 || >=22.9.0"}
- run: npm install -g npm@"<11.0.0"
if: ${{
matrix.node_version == '18.19.0' ||
matrix.node_version == '18' ||
matrix.node_version == '20.6.0'
}}
- run: npm install -g npm@latest
if: ${{
matrix.node_version == '20' ||
matrix.node_version == '22' ||
matrix.node_version == '23'
}}

- name: Bootstrap
run: npm ci

- name: Build 🔧
run: npm run compile

- name: Install collector
run: |
curl -sSL -o otelcol-contrib.tar.gz https://github.com/open-telemetry/opentelemetry-collector-releases/releases/download/v0.126.0/otelcol-contrib_0.126.0_linux_amd64.tar.gz
tar -xzf otelcol-contrib.tar.gz
working-directory: e2e-tests
- name: run collector in background
run: |
./otelcol-contrib --config collector-config.yaml &
working-directory: e2e-tests
- name: Export telemetry to collector
run: npm run export-telemetry
working-directory: e2e-tests
- name: stop collector
run: pkill -f otelcol-contrib
working-directory: e2e-tests
- name: Print output
run: cat collector-output.json
working-directory: e2e-tests
- name: verify exported telemetry
run: npm run verify
working-directory: e2e-tests
25 changes: 25 additions & 0 deletions e2e-tests/.eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
/*
* 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.
*/

module.exports = {
env: {
node: true,
},
...require('../eslint.base.js'),
rules: {
'no-console': 'off',
},
};
2 changes: 2 additions & 0 deletions e2e-tests/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# collector output file
collector-output.json
44 changes: 44 additions & 0 deletions e2e-tests/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
# OpenTelemetry JS End-to-End Tests

This directory contains end-to-end (E2E) tests for the OpenTelemetry JavaScript project. These tests verify the integration of OpenTelemetry components with a real OpenTelemetry Collector.

## Prerequisites

- [Node.js](https://nodejs.org/) (version as required by the root project)
- [Docker](https://www.docker.com/) (for running the OpenTelemetry Collector)

## Installation

Install dependencies:

```sh
npm install
```

## Running Tests

The default Make target runs the collector in docker, executes the tests, and verifies the results:

```sh
make
```

### Additional Make Targets

Each step of the tests can also be run separately:

#### `npm run test:e2e`

Runs the full E2E test workflow in sequence: prepares the output file, starts the Collector, runs the tests, stops the Collector, and verifies the results.

#### `npm run run-collector`

Starts the OpenTelemetry Collector in a Docker container and mounts the output file for results. Waits 5 seconds for the Collector to be ready.

#### `npm run stop-collector`

Stops the Docker container running the Collector if it’s running.

#### `npm run verify`

Runs the verification script (`verify.mjs`) to check the contents of `collector-output.json` for expected results.
21 changes: 21 additions & 0 deletions e2e-tests/collector-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
receivers:
otlp:
protocols:
http:
endpoint: 0.0.0.0:4318

exporters:
file:
path: ./collector-output.json

service:
pipelines:
traces:
receivers: [otlp]
exporters: [file]
metrics:
receivers: [otlp]
exporters: [file]
logs:
receivers: [otlp]
exporters: [file]
27 changes: 27 additions & 0 deletions e2e-tests/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
{
"name": "@opentelemetry/e2e-test",
"private": true,
"description": "End-to-end tests for OpenTelemetry JS",
"version": "0.0.0",
"scripts": {
"test:e2e": "npm run run-collector && npm run export-telemetry && npm run verify && npm run stop-collector",
"lint": "eslint . --ext .mjs",
"lint:fix": "eslint . --ext .mjs --fix",
"run-collector": "docker run -d --rm --name otelcol-e2e -v $(pwd)/collector-config.yaml:/etc/otelcol/config.yaml -v $(pwd)/collector-output.json:/tmp/collector-output.json -p 4317:4317 -p 4318:4318 -w /tmp otel/opentelemetry-collector-contrib:latest --config /etc/otelcol/config.yaml && sleep 5",
"export-telemetry": "node test.mjs",
"prerun-collector": "node -e \"require('fs').writeFileSync('collector-output.json', '')\"",
"stop-collector": "docker stop otelcol-e2e",
"verify": "node verify.mjs"
},
"dependencies": {
"@opentelemetry/api": "^1.3.0",
"@opentelemetry/api-logs": "~0.201.1",
"@opentelemetry/sdk-node": "0.201.1",
"@opentelemetry/exporter-trace-otlp-proto": "0.201.1",
"@opentelemetry/exporter-metrics-otlp-proto": "0.201.1",
"@opentelemetry/exporter-logs-otlp-proto": "0.201.1",
"@opentelemetry/sdk-metrics": "2.0.1",
"@opentelemetry/sdk-logs": "0.201.1",
"@opentelemetry/sdk-trace-base": "2.0.1"
}
}
95 changes: 95 additions & 0 deletions e2e-tests/test.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
/*
* 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.
*/
import { NodeSDK } from '@opentelemetry/sdk-node';
import { OTLPTraceExporter } from '@opentelemetry/exporter-trace-otlp-proto';
import { OTLPMetricExporter } from '@opentelemetry/exporter-metrics-otlp-proto';
import { PeriodicExportingMetricReader } from '@opentelemetry/sdk-metrics';
import { OTLPLogExporter } from '@opentelemetry/exporter-logs-otlp-proto';
import { SimpleLogRecordProcessor } from '@opentelemetry/sdk-logs';
import { SimpleSpanProcessor } from '@opentelemetry/sdk-trace-base';
import {
diag,
DiagConsoleLogger,
DiagLogLevel,
trace,
metrics,
} from '@opentelemetry/api';
import { logs } from '@opentelemetry/api-logs';

// Enable diagnostic logging (optional)
diag.setLogger(new DiagConsoleLogger(), DiagLogLevel.INFO);

const collectorUrl = 'http://localhost:4318/v1';

// Set up trace exporter with SimpleSpanProcessor
const traceExporter = new OTLPTraceExporter({
url: `${collectorUrl}/traces`,
});
const spanProcessors = [new SimpleSpanProcessor(traceExporter)];

// Set up metric exporter
const metricExporter = new OTLPMetricExporter({
url: `${collectorUrl}/metrics`,
});
const metricReader = new PeriodicExportingMetricReader({
exporter: metricExporter,
exportIntervalMillis: 1000,
exportTimeoutMillis: 1000,
});

// Set up log exporter
const logExporter = new OTLPLogExporter({
url: `${collectorUrl}/logs`,
});
const logRecordProcessors = [new SimpleLogRecordProcessor(logExporter)];

// Set up OpenTelemetry SDK
const sdk = new NodeSDK({
spanProcessors,
metricReader,
logRecordProcessors,
});

async function main() {
sdk.start();

// Create a span
const tracer = trace.getTracer('example-tracer');
const span = tracer.startSpan('example-span');
span.setAttribute('example-attribute', 'value');
span.end();

// Create a metric
const meter = metrics.getMeter('example-meter');
const counter = meter.createUpDownCounter('example_counter');
counter.add(42, { foo: 'bar' });

// Create a log
const logger = logs.getLogger('example-logger');
logger.emit({
severityText: 'INFO',
body: 'test-log-body',
attributes: { foo: 'bar' },
});

// flushes exporters and shuts down the SDK
await sdk.shutdown();
}

main().catch(err => {
console.error('Error running example:', err);
process.exit(1);
});
97 changes: 97 additions & 0 deletions e2e-tests/verify.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
/*
* 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.
*/
'use strict';

import fs from 'fs';

const data = fs.readFileSync('collector-output.json', 'utf8');

let verifiedSpan = false;
let verifiedMetric = false;
let verifiedLog = false;

const lines = data.split('\n').filter(Boolean);
for (const line of lines) {
const parsed = JSON.parse(line);
if (parsed.resourceSpans) {
console.log('found span');
verifySpan(parsed.resourceSpans[0].scopeSpans[0].spans[0]);
verifiedSpan = true;
}
if (parsed.resourceMetrics) {
console.log('found metric');
verifyMetric(parsed.resourceMetrics[0].scopeMetrics[0].metrics[0]);
verifiedMetric = true;
}
if (parsed.resourceLogs) {
console.log('found log');
verifyLog(parsed.resourceLogs[0].scopeLogs[0].logRecords[0]);
verifiedLog = true;
}
}

if (!verifiedSpan) {
console.error('No spans found in the output');
process.exit(1);
}
if (!verifiedMetric) {
console.error('No metrics found in the output');
process.exit(1);
}
if (!verifiedLog) {
console.error('No logs found in the output');
process.exit(1);
}

function verifySpan(span) {
const expectedName = 'example-span';
if (span.name !== expectedName) {
console.error(`Expected span name ${expectedName}, but got '${span.name}'`);
process.exit(1);
}
}

function verifyMetric(metric) {
const expectedName = 'example_counter';
const expectedValue = 42;

if (metric.name !== expectedName) {
console.error(
`Expected metric name ${expectedName}, but got '${metric.name}'`
);
process.exit(1);
}
if (
metric.sum &&
metric.sum.dataPoints &&
metric.sum.dataPoints[0].asDouble !== expectedValue
) {
console.error(
`Expected metric value ${expectedValue}, but got '${metric.sum.dataPoints[0].asDouble}'`
);
process.exit(1);
}
}

function verifyLog(log) {
const expectedBody = 'test-log-body';
if (log.body && log.body.stringValue !== expectedBody) {
console.error(
`Expected log body '${expectedBody}', but got '${log.body.stringValue}'`
);
process.exit(1);
}
}
Loading