diff --git a/.github/ISSUE_TEMPLATE/bug_report.yaml b/.github/ISSUE_TEMPLATE/bug_report.yaml index f50009ef60..5cadb10953 100644 --- a/.github/ISSUE_TEMPLATE/bug_report.yaml +++ b/.github/ISSUE_TEMPLATE/bug_report.yaml @@ -84,7 +84,7 @@ body: "start": "node -r tracing.js app.js" }, "dependencies": { - "@opentelemetry/api": "^1.2.0", + "@opentelemetry/api": "^1.3.0", "@opentelemetry/sdk-trace-base": "~1.3.1", ... } diff --git a/.github/workflows/close-stale.yml b/.github/workflows/close-stale.yml index 122ab1c931..c26c21ca56 100644 --- a/.github/workflows/close-stale.yml +++ b/.github/workflows/close-stale.yml @@ -7,7 +7,7 @@ jobs: stale: runs-on: ubuntu-latest steps: - - uses: actions/stale@v5 + - uses: actions/stale@v6 with: days-before-stale: 60 days-before-close: 14 diff --git a/.github/workflows/peer-api.yml b/.github/workflows/peer-api.yml index 47daa6f20f..d3239068d5 100644 --- a/.github/workflows/peer-api.yml +++ b/.github/workflows/peer-api.yml @@ -10,7 +10,7 @@ jobs: peer-api-check: runs-on: ubuntu-latest container: - image: node:14 + image: node:18 steps: - name: Checkout uses: actions/checkout@v3 diff --git a/.github/workflows/unit-test.yml b/.github/workflows/unit-test.yml index 21c99fbf5e..618e168e1e 100644 --- a/.github/workflows/unit-test.yml +++ b/.github/workflows/unit-test.yml @@ -47,16 +47,19 @@ jobs: - name: Build 🔧 run: | - npm run compile + npx lerna run compile - name: Unit tests - run: npm run test + run: | + # TODO(legendecas): webpack https://stackoverflow.com/questions/69692842/error-message-error0308010cdigital-envelope-routinesunsupported + if [ "${{ matrix.node_version }}" = "18" ]; then + export NODE_OPTIONS=--openssl-legacy-provider + fi + npm run test - name: Report Coverage run: npm run codecov if: ${{ matrix.node_version == '14' }} node-windows-tests: - strategy: - fail-fast: false runs-on: windows-latest env: NPM_CONFIG_UNSAFE_PERM: true @@ -90,22 +93,23 @@ jobs: - name: Build 🔧 run: | - npm run compile + npm config set script-shell "C:\\Program Files\\git\\bin\\bash.exe" + npx lerna run compile - name: Unit tests run: npm run test browser-tests: runs-on: ubuntu-latest - container: - image: circleci/node:16-browsers env: NPM_CONFIG_UNSAFE_PERM: true steps: - - name: Permission Setup - run: sudo chmod -R 777 /github /__w - name: Checkout uses: actions/checkout@v3 + - uses: actions/setup-node@v3 + with: + node-version: 16 + - name: restore lerna id: cache uses: actions/cache@v3 @@ -126,8 +130,6 @@ jobs: - name: Build 🔧 run: | - npm run compile - # run additional compilation variants npx lerna run compile - name: Unit tests @@ -136,15 +138,14 @@ jobs: run: npm run codecov:browser webworker-tests: runs-on: ubuntu-latest - container: - image: circleci/node:16-browsers env: NPM_CONFIG_UNSAFE_PERM: true steps: - - name: Permission Setup - run: sudo chmod -R 777 /github /__w - name: Checkout - uses: actions/checkout@v3 + uses: actions/checkout@v3.0.2 + - uses: actions/setup-node@v3 + with: + node-version: 16 - name: restore lerna id: cache @@ -166,11 +167,37 @@ jobs: - name: Build 🔧 run: | - npm run compile - # run additional compilation variants npx lerna run compile - name: Unit tests run: npm run test:webworker - name: Report Coverage run: npm run codecov:webworker + api-eol-node-test: + strategy: + fail-fast: false + matrix: + node_version: + - "8" + - "10" + - "12" + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v3 + + - uses: actions/setup-node@v3 + with: + node-version: ${{ matrix.node_version }} + + - name: Build + working-directory: ./api + run: | + npm install --ignore-scripts + npm install @types/mocha@^7 mocha@^7 ts-loader@^8 ts-mocha@^8 + node ../scripts/version-update.js + tsc --build tsconfig.json tsconfig.esm.json + + - name: Test + working-directory: ./api + run: npm test diff --git a/.github/workflows/w3c-integration-test.yml b/.github/workflows/w3c-integration-test.yml index c2be63b9df..971ea6ee7f 100644 --- a/.github/workflows/w3c-integration-test.yml +++ b/.github/workflows/w3c-integration-test.yml @@ -13,6 +13,10 @@ jobs: - name: Checkout 🛎️ uses: actions/checkout@v3 + - uses: actions/setup-node@v3 + with: + node-version: '16' + - name: restore lock files uses: actions/cache@master # must use unreleased master to cache multiple paths id: cache diff --git a/CHANGELOG.md b/CHANGELOG.md index bc6d92008d..ab76cfe617 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,25 +2,97 @@ All notable changes to this project will be documented in this file. +For API changes, see the [API CHANGELOG](api/CHANGELOG.md). +For experimental package changes, see the [experimental CHANGELOG](experimental/CHANGELOG.md). + ## Unreleased ### :boom: Breaking Change ### :rocket: (Enhancement) +* feat(api): add `getActiveBaggage` API [#3385](https://github.com/open-telemetry/opentelemetry-js/pull/3385) + ### :bug: (Bug Fix) -* fix(instrumentation-xhr): http.url attribute should be absolute [#3200](https://github.com/open-telemetry/opentelemetry-js/pull/3200) @t2t2 +* fix(sdk-metrics): use default Resource to comply with semantic conventions [#3411](https://github.com/open-telemetry/opentelemetry-js/pull/3411) @pichlermarc + * Metrics exported by the SDK now contain the following resource attributes by default: + * `service.name` + * `telemetry.sdk.name` + * `telemetry.sdk.language` + * `telemetry.sdk.version` ### :books: (Refine Doc) ### :house: (Internal) +## 1.8.0 + +* `@opentelemetry/sdk-metrics` has been promoted to stable +* `@opentelemetry/api-metrics` has been merged into `@opentelemetry/api` and deprecated + +### :boom: Breaking Change + +* feat(api): merge api-metrics into api [#3374](https://github.com/open-telemetry/opentelemetry-js/pull/3374) @legendecas + +### :rocket: (Enhancement) + +* feat(sdk-trace): re-export sdk-trace-base in sdk-trace-node and web [#3319](https://github.com/open-telemetry/opentelemetry-js/pull/3319) @legendecas +* feat: enable tree shaking [#3329](https://github.com/open-telemetry/opentelemetry-js/pull/3329) @pkanal + +### :bug: (Bug Fix) + +* fix(sdk-trace): enforce consistent span durations + [#3327](https://github.com/open-telemetry/opentelemetry-js/pull/3327) @dyladan +* fix(resources): fix EnvDetector throwing errors when attribute values contain spaces + [#3295](https://github.com/open-telemetry/opentelemetry-js/issues/3295) +* fix(trace): fix an issue which caused negative span durations in web based spans + [#3359](https://github.com/open-telemetry/opentelemetry-js/pull/3359) @dyladan +* fix(resources): strict OTEL_RESOURCE_ATTRIBUTES baggage octet decoding + [#3341](https://github.com/open-telemetry/opentelemetry-js/pull/3341) @legendecas + +### :books: (Refine Doc) + +* doc: Added Metrics documentation [#3360](https://github.com/open-telemetry/opentelemetry-js/pull/3360) @weyert +* docs(api): fix counter negative value wording [#3396](https://github.com/open-telemetry/opentelemetry-js/pull/3396) @legendecas + +### :house: (Internal) + +* ci: run browser tests without circle [#3328](https://github.com/open-telemetry/opentelemetry-js/pull/3328) @dyladan + +## Metrics API 1.0.0 + +Metrics API is now stable and generally available. +There are no changes between 1.0.0 and the previous 0.33.0 version. + +### :boom: Breaking Change + +* Add semver check to metrics API [#3357](https://github.com/open-telemetry/opentelemetry-js/pull/3357) @dyladan + * Previously API versions were only considered compatible if the API was exactly the same + +## 1.7.0 + +### :bug: (Bug Fix) + +* fix(sdk-trace-base): make span start times resistant to hrtime clock drift + [#3129](https://github.com/open-telemetry/opentelemetry-js/issues/3129) + +* fix(sdk-trace-base): validate maxExportBatchSize in BatchSpanProcessorBase + [#3232](https://github.com/open-telemetry/opentelemetry-js/issues/3232) + +### :books: (Refine Doc) + +* docs(metrics): add missing metrics packages to SDK reference documentation [#3239](https://github.com/open-telemetry/opentelemetry-js/pull/3239) @dyladan + +### :house: (Internal) + +* deps: update markdownlint-cli to 0.32.2 [#3253](https://github.com/open-telemetry/opentelemetry-js/pull/3253) @pichlermarc + ## 1.6.0 ### :rocket: (Enhancement) -* perf(opentelemetry-core): improve hexToBase64 performance [#3178](https://github.com/open-telemetry/opentelemetry-js/pull/3178) +* perf(opentelemetry-core): improve hexToBase64 performance [#3178](https://github.com/open-telemetry/opentelemetry-js/pull/3178) @seemk * feat(sdk-trace-base): move Sampler declaration into sdk-trace-base [#3088](https://github.com/open-telemetry/opentelemetry-js/pull/3088) @legendecas * fix(grpc-instrumentation): added grpc attributes in instrumentation [#3127](https://github.com/open-telemetry/opentelemetry-js/pull/3127) @andrewzenkov * feat: support latest `@opentelemetry/api` [#3177](https://github.com/open-telemetry/opentelemetry-js/pull/3177) @dyladan @@ -35,8 +107,6 @@ All notable changes to this project will be documented in this file. * chore: update trace-web example and rename it to opentelemetry-web [#3145](https://github.com/open-telemetry/opentelemetry-js/pull/3145) @pichlermarc * chore: update https example [#3152](https://github.com/open-telemetry/opentelemetry-js/pull/3152) @pichlermarc -### :house: (Internal) - ## 1.5.0 ### :rocket: (Enhancement) diff --git a/README.md b/README.md index f52b0a4ad2..c4561df9c0 100644 --- a/README.md +++ b/README.md @@ -4,9 +4,7 @@ Getting Started • - API Reference - • - SDK Reference + API and SDK Reference
@@ -41,42 +39,15 @@ This is the JavaScript version of [OpenTelemetry](https://opentelemetry.io/), a framework for collecting traces and metrics from applications. -## Compatibility Matrix - -| API Version | Core version | Experimental Packages | -| ----------- | ------------ | --------------------- | -| 1.2.x | 1.6.x | 0.32.x | -| 1.1.x | 1.5.x | 0.31.x | -| 1.1.x | 1.4.x | 0.30.x | -| 1.1.x | 1.2.x, 1.3.x | 0.29.x | -| 1.1.x | 1.1.x | 0.28.x | -| 1.0.x | 1.0.x | 0.26.x, 0.27.x | -| 1.0.x | 0.26.x | ----- | -| 1.0.x | 0.25.x | ----- | -| 1.0.x | 0.24.x | ----- | -| 1.0.x | 0.23.x | ----- | -| 1.0.x | 0.22.x | ----- | -| 0.21.x | 0.21.x | ----- | -| 0.20.x | 0.20.x | ----- | -| v1.0.0-rc.3 | 0.19.x | ----- | -| 0.18.x | 0.18.x | ----- | -| | 0.17.x | ----- | -| | 0.16.x | ----- | -| | 0.15.x | ----- | -| | 0.14.x | ----- | -| | 0.13.x | ----- | -| | 0.12.x | ----- | -| | 0.11.x | ----- | - -## Versioning - -The current version for each package can be found in the respective `package.json` file for that module. For additional details see the [versioning and stability][spec-versioning] document in the specification. +## Quick Start -## Quick start +The following describes how to set up tracing for a basic web application. +For more detailed documentation, see the website at+ +API Reference + • +Documentation + + + + + +
+ +This package provides everything needed to interact with the OpenTelemetry API, including all TypeScript interfaces, enums, and no-op implementations. It is intended for use both on the server and in the browser. + +The methods in this package perform no operations by default. This means they can be safely called by a library or end-user application whether there is an SDK registered or not. In order to generate and export telemetry data, you will also need an SDK such as the [OpenTelemetry JS SDK][opentelemetry-js]. + +## Tracing Quick Start + +### You Will Need + +- An application you wish to instrument +- [OpenTelemetry JS SDK][opentelemetry-js] +- Node.js >=8.5.0 (14+ is preferred) or an ECMAScript 5+ compatible browser + +**Note:** ECMAScript 5+ compatibility is for this package only. Please refer to the documentation for the SDK you are using to determine its minimum ECMAScript version. + +**Note for library authors:** Only your end users will need an OpenTelemetry SDK. If you wish to support OpenTelemetry in your library, you only need to use the OpenTelemetry API. For more information, please read the [tracing documentation][docs-tracing]. + +### Install Dependencies + +```sh +npm install @opentelemetry/api @opentelemetry/sdk-trace-base +``` + +### Trace Your Application + +In order to get started with tracing, you will need to first register an SDK. The SDK you are using may provide a convenience method which calls the registration methods for you, but if you would like to call them directly they are documented here: [sdk registration methods][docs-sdk-registration]. + +Once you have registered an SDK, you can start and end spans. A simple example of basic SDK registration and tracing a simple operation is below. The example should export spans to the console once per second. For more information, see the [tracing documentation][docs-tracing]. + +```javascript +const { trace } = require("@opentelemetry/api"); +const { BasicTracerProvider, ConsoleSpanExporter, SimpleSpanProcessor } = require("@opentelemetry/sdk-trace-base"); + +// Create and register an SDK +const provider = new BasicTracerProvider(); +provider.addSpanProcessor(new SimpleSpanProcessor(new ConsoleSpanExporter())); +trace.setGlobalTracerProvider(provider); + +// Acquire a tracer from the global tracer provider which will be used to trace the application +const name = 'my-application-name'; +const version = '0.1.0'; +const tracer = trace.getTracer(name, version); + +// Trace your application by creating spans +async function operation() { + const span = tracer.startSpan("do operation"); + + // mock some work by sleeping 1 second + await new Promise((resolve, reject) => { + setTimeout(resolve, 1000); + }) + + span.end(); +} + +async function main() { + while (true) { + await operation(); + } +} + +main(); +``` + +## Version Compatibility + +Because the npm installer and node module resolution algorithm could potentially allow two or more copies of any given package to exist within the same `node_modules` structure, the OpenTelemetry API takes advantage of a variable on the `global` object to store the global API. When an API method in the API package is called, it checks if this `global` API exists and proxies calls to it if and only if it is a compatible API version. This means if a package has a dependency on an OpenTelemetry API version which is not compatible with the API used by the end user, the package will receive a no-op implementation of the API. + +## Upgrade Guidelines + +### 0.21.0 to 1.0.0 + +No breaking changes + +### 0.20.0 to 0.21.0 + +- [#78](https://github.com/open-telemetry/opentelemetry-js-api/issues/78) `api.context.bind` arguments reversed and `context` is now a required argument. +- [#46](https://github.com/open-telemetry/opentelemetry-js-api/issues/46) Noop classes and singletons are no longer exported. To create a noop span it is recommended to use `api.trace.wrapSpanContext` with `INVALID_SPAN_CONTEXT` instead of using the `NOOP_TRACER`. + +### 1.0.0-rc.3 to 0.20.0 + +- Removing `TimedEvent` which was not part of spec +- `HttpBaggage` renamed to `HttpBaggagePropagator` +- [#45](https://github.com/open-telemetry/opentelemetry-js-api/pull/45) `Span#context` renamed to `Span#spanContext` +- [#47](https://github.com/open-telemetry/opentelemetry-js-api/pull/47) `getSpan`/`setSpan`/`getSpanContext`/`setSpanContext` moved to `trace` namespace +- [#55](https://github.com/open-telemetry/opentelemetry-js-api/pull/55) `getBaggage`/`setBaggage`/`createBaggage` moved to `propagation` namespace + +## Useful links + +- For more information on OpenTelemetry, visit: