diff --git a/.github/workflows/publish-to-npm.yml b/.github/workflows/publish-to-npm.yml new file mode 100644 index 0000000000..b51678268a --- /dev/null +++ b/.github/workflows/publish-to-npm.yml @@ -0,0 +1,31 @@ +name: Publish packages to NPM + +on: + workflow_dispatch: + +jobs: + release-to-npm: + runs-on: ubuntu-latest + permissions: + id-token: write + steps: + - name: Checkout Repository + uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: Setup Node + uses: actions/setup-node@v4 + with: + node-version: 18 + registry-url: 'https://registry.npmjs.org' + + - run: npm ci + + - run: npm run compile + + - name: Publish to npm + env: + NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}} + NPM_CONFIG_PROVENANCE: true + run: npx lerna publish --concurrency 1 from-package --no-push --no-private --no-git-tag-version --no-verify-access --yes diff --git a/.github/workflows/unit-test.yml b/.github/workflows/unit-test.yml index 11bf4a9c7a..55db405284 100644 --- a/.github/workflows/unit-test.yml +++ b/.github/workflows/unit-test.yml @@ -48,6 +48,8 @@ jobs: run: npm run test - name: Report Coverage uses: codecov/codecov-action@v4 + env: + CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} with: verbose: true node-windows-tests: @@ -102,6 +104,8 @@ jobs: run: npm run test:browser - name: Report Coverage uses: codecov/codecov-action@v4 + env: + CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} with: verbose: true webworker-tests: @@ -128,6 +132,8 @@ jobs: run: npm run test:webworker - name: Report Coverage uses: codecov/codecov-action@v4 + env: + CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} with: verbose: true api-eol-node-test: diff --git a/CHANGELOG.md b/CHANGELOG.md index 7ad9ff304d..7194d8ba17 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -110,6 +110,7 @@ For semantic convention package changes, see the [semconv CHANGELOG](packages/se * fix(resources): prevent circular import (resource -> detector -> resource -> ...) [#4653](https://github.com/open-telemetry/opentelemetry-js/pull/4653) @pichlermarc * fixes a circular import warning which would appear in rollup when bundling `@opentelemetry/resources` * fix(exporter-metrics-otlp-grpc): add explicit otlp-exporter-base dependency to exporter-metrics-otlp-grpc [#4678](https://github.com/open-telemetry/opentelemetry-js/pull/4678) @AkselAllas +* fix(resources) wait for async attributes for detecting resources [#4687](https://github.com/open-telemetry/opentelemetry-js/pull/4687) @ziolekjj ## 1.24.0 diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 374f0470d0..3d78418a01 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -223,6 +223,16 @@ To run the unit tests continuously in watch mode while developing, use: npm run tdd ``` +Packages that are expected to run in the browser have browser specific tests: + +```sh +# Run browser-specific test +npm run test:browser + +# Run web worker test +npm run test:webworker +``` + ### Linting This project uses `eslint` to lint source code. Just like tests and compilation, linting can be done for all packages or only a single package. diff --git a/experimental/CHANGELOG.md b/experimental/CHANGELOG.md index 37d6318551..e0a1a1a5c3 100644 --- a/experimental/CHANGELOG.md +++ b/experimental/CHANGELOG.md @@ -48,6 +48,7 @@ All notable changes to experimental packages in this project will be documented * `OTEL_EXPORTER_OTLP_METRICS_INSECURE` * `OTEL_EXPORTER_OTLP_LOGS_INSECURE` * fix(sdk-node): use warn instead of error on unknown OTEL_NODE_RESOURCE_DETECTORS values [#5034](https://github.com/open-telemetry/opentelemetry-js/pull/5034) +* fix(exporter-logs-otlp-proto): Use correct config type in Node constructor ### :books: (Refine Doc) diff --git a/experimental/packages/exporter-logs-otlp-proto/src/platform/node/OTLPLogExporter.ts b/experimental/packages/exporter-logs-otlp-proto/src/platform/node/OTLPLogExporter.ts index 828a11cbc6..d897208389 100644 --- a/experimental/packages/exporter-logs-otlp-proto/src/platform/node/OTLPLogExporter.ts +++ b/experimental/packages/exporter-logs-otlp-proto/src/platform/node/OTLPLogExporter.ts @@ -15,8 +15,8 @@ */ import { - OTLPExporterConfigBase, OTLPExporterNodeBase, + OTLPExporterNodeConfigBase, } from '@opentelemetry/otlp-exporter-base'; import { IExportLogsServiceResponse, @@ -37,7 +37,7 @@ export class OTLPLogExporter extends OTLPExporterNodeBase implements LogRecordExporter { - constructor(config: OTLPExporterConfigBase = {}) { + constructor(config: OTLPExporterNodeConfigBase = {}) { super( config, ProtobufLogsSerializer, diff --git a/packages/opentelemetry-resources/src/detect-resources.ts b/packages/opentelemetry-resources/src/detect-resources.ts index 4fa477a4f8..0bfa13cac8 100644 --- a/packages/opentelemetry-resources/src/detect-resources.ts +++ b/packages/opentelemetry-resources/src/detect-resources.ts @@ -70,6 +70,7 @@ export const detectResourcesSync = ( if (isPromiseLike(resourceOrPromise)) { const createPromise = async () => { const resolvedResource = await resourceOrPromise; + await resolvedResource.waitForAsyncAttributes?.(); return resolvedResource.attributes; }; resource = new Resource({}, createPromise()); diff --git a/packages/opentelemetry-resources/test/detect-resources.test.ts b/packages/opentelemetry-resources/test/detect-resources.test.ts index 0db97057db..7c3b1a212c 100644 --- a/packages/opentelemetry-resources/test/detect-resources.test.ts +++ b/packages/opentelemetry-resources/test/detect-resources.test.ts @@ -28,7 +28,10 @@ describe('detectResourcesSync', () => { it('handles resource detectors which return Promise', async () => { const detector: Detector = { async detect() { - return new Resource({ sync: 'fromsync' }); + return new Resource( + { sync: 'fromsync' }, + Promise.resolve().then(() => ({ async: 'fromasync' })) + ); }, }; const resource = detectResourcesSync({ @@ -38,6 +41,7 @@ describe('detectResourcesSync', () => { await resource.waitForAsyncAttributes?.(); assert.deepStrictEqual(resource.attributes, { sync: 'fromsync', + async: 'fromasync', }); });