-
Notifications
You must be signed in to change notification settings - Fork 897
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
dyladan
merged 48 commits into
open-telemetry:main
from
dynatrace-oss-contrib:update-proto
May 28, 2025
Merged
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 5c9c43e
Docs and changelog
dyladan f16c665
Add e2e tests
dyladan 95a11bc
Run e2e tests in workflow
dyladan 0b555a9
Remove unused test script
dyladan d082b54
More specific changelog
dyladan eb0784e
Setup node before tests
dyladan 381f4ad
cd to e2e
dyladan 221c2c9
Use working dir instead of cd
dyladan 1cc9d6a
Don't use docker in github
dyladan 494f569
Use relative path for output json
dyladan 59f13d9
Kill collector before jq
dyladan 1641815
Ignore blank lines
dyladan 1916a45
Use relative path
dyladan d13b863
Use cat for output
dyladan 742afa4
fix tests and add deps
dyladan 27c3346
Verify metric value
dyladan 2c6824c
Test metric value
dyladan 65d27fe
Merge branch 'main' into update-proto
dyladan 5e1a34d
Update to 1.7.0 and remove unused submodules.md
dyladan e04a0d7
Merge branch 'update-proto' of github.com:dynatrace-oss-contrib/opent…
dyladan d604d80
Bump protocol version in readme
dyladan b2eee2b
Use log record processor instead of provider
dyladan b517b7f
Wording nit
dyladan 34564a4
Use js for verify
dyladan ad1531d
File extension
dyladan 172da95
Clean up configs
dyladan c57025b
Delete old file
dyladan 2880c16
Remove unsafe perm env
dyladan 709b63d
Merge branch 'main' into update-proto
dyladan 0221020
Changelog update
dyladan d0c1855
Rename dir e2e-tests
dyladan 3b9dbde
Verify after make all
dyladan f34e854
Lint verification script
dyladan a940403
Add e2e test script
dyladan ee8d136
2 space indent
dyladan 9c0382f
Merge branch 'update-proto' of github.com:dynatrace-oss-contrib/opent…
dyladan 3f4d9fe
Fix package-lock
dyladan 5dcbc9b
Fix package name
dyladan 35e3724
Pin versions for tests
dyladan 733a3f8
Update experimental/CHANGELOG.md
pichlermarc 5af0a0c
Add readme for e2e tests
dyladan 7a75cfe
Merge branch 'update-proto' of github.com:dynatrace-oss-contrib/opent…
dyladan eee1171
Lint
dyladan 1197cd7
Merge remote-tracking branch 'origin/main' into update-proto
dyladan e3a3702
Convert makefile to npm scripts
dyladan 8fded0f
Col not running in docker in actions
dyladan 4833cea
Remove make references from readme
dyladan File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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', | ||
}, | ||
}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
# collector output file | ||
collector-output.json |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
dyladan marked this conversation as resolved.
Show resolved
Hide resolved
|
||
``` | ||
|
||
### Additional Make Targets | ||
dyladan marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
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. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" | ||
} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.