Skip to content

Commit

Permalink
Merge branch 'open-telemetry:main' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
Annosha authored Oct 19, 2024
2 parents c395222 + be1737f commit 383220c
Show file tree
Hide file tree
Showing 12 changed files with 96 additions and 31 deletions.
1 change: 0 additions & 1 deletion .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ jobs:
run: |
npm run lint
npm run lint:examples
npm run lint:markdown
- name: Lint doc files
run: |
Expand Down
31 changes: 31 additions & 0 deletions .github/workflows/publish-to-npm.yml
Original file line number Diff line number Diff line change
@@ -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
6 changes: 6 additions & 0 deletions .github/workflows/unit-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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:
Expand All @@ -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:
Expand Down
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
34 changes: 26 additions & 8 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@ detailed instructions, see [development](#development) below.
```sh
git clone https://github.com/open-telemetry/opentelemetry-js.git
cd opentelemetry-js
npm install
npm ci
npm run compile
npm test
npm run test
```

## Pull Request Merge Guidelines
Expand Down Expand Up @@ -164,7 +164,7 @@ Most of the commands needed for development are accessed as [npm scripts](https:
This will install all dependencies for the root project and all modules managed by `npm workspaces`.

```sh
npm install
npm ci
```

### Compile modules
Expand Down Expand Up @@ -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.
Expand All @@ -247,13 +257,21 @@ cd packages/opentelemetry-module-name
npm run lint:fix
```

Similarly, Markdown files (such as README.md files) can be linted:
The default lint command will check majority of files, including Markdown files (such as README.md files), but you
also have the option to check just the Markdown files with:

```sh
npm run lint:markdown
npm run lint:markdown:fix # can automatically fix some Markdown rules
```

The default command doesn't check the examples folder. To lint just the examples, use the script:

```sh
npm run lint:examples
npm run lint:examples:fix # can automatically fix some errors
```

### Generating docs

We use [typedoc](https://www.npmjs.com/package/typedoc) to generate the api documentation.
Expand Down Expand Up @@ -293,10 +311,10 @@ export const _globalThis = typeof globalThis === 'object' ? globalThis : global;
/// packages/opentelemetry-core/src/platform/browser/globalThis.ts
export const _globalThis: typeof globalThis =
typeof globalThis === 'object' ? globalThis :
typeof self === 'object' ? self :
typeof window === 'object' ? window :
typeof global === 'object' ? global :
{} as typeof globalThis;
typeof self === 'object' ? self :
typeof window === 'object' ? window :
typeof global === 'object' ? global :
{} as typeof globalThis;
```

Even though the implementation may differ, the exported names must be aligned.
Expand Down
30 changes: 16 additions & 14 deletions experimental/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,21 @@ All notable changes to experimental packages in this project will be documented

### :boom: Breaking Change

* feat(exporter-*-otlp-*)!: rewrite exporter config logic for testability [#4971](https://github.com/open-telemetry/opentelemetry-js/pull/4971) @pichlermarc
* (user-facing) `getDefaultUrl` was intended for internal use has been removed from all exporters
* (user-facing) `getUrlFromConfig` was intended for internal use and has been removed from all exporters
* (user-facing) `hostname` was intended for internal use and has been removed from all exporters
* (user-facing) `url` was intended for internal use and has been removed from all exporters
* (user-facing) `timeoutMillis` was intended for internal use and has been removed from all exporters
* (user-facing) `onInit` was intended for internal use and has been removed from all exporters
* feat(otlp-exporter-base)!: do not export functions that are intended for internal use [#4971](https://github.com/open-telemetry/opentelemetry-js/pull/4971) @pichlermarc
* Drops the following functions and types that were intended for internal use from the package exports:
* `parseHeaders`
* `appendResourcePathToUrl`
* `appendResourcePathToUrlIfNeeded`
* `configureExporterTimeout`
* `invalidTimeout`

### :rocket: (Enhancement)

* feat(api-logs): Add delegating no-op logger provider [#4861](https://github.com/open-telemetry/opentelemetry-js/pull/4861) @hectorhdzg
Expand All @@ -22,13 +37,6 @@ All notable changes to experimental packages in this project will be documented
* fix(sdk-events): remove devDependencies to old `@opentelemetry/[email protected]`, `@opentelemetry/[email protected]` packages [#5013](https://github.com/open-telemetry/opentelemetry-js/pull/5013) @pichlermarc
* fix(sdk-logs): remove devDependencies to old `@opentelemetry/[email protected]` [#5013](https://github.com/open-telemetry/opentelemetry-js/pull/5013) @pichlermarc
* fix(sdk-logs): align LogRecord#setAttribute type with types from `@opentelemetry/[email protected]` [#5013](https://github.com/open-telemetry/opentelemetry-js/pull/5013) @pichlermarc
* feat(exporter-*-otlp-*)!: rewrite exporter config logic for testability [#4971](https://github.com/open-telemetry/opentelemetry-js/pull/4971) @pichlermarc
* (user-facing) `getDefaultUrl` was intended for internal use has been removed from all exporters
* (user-facing) `getUrlFromConfig` was intended for internal use and has been removed from all exporters
* (user-facing) `hostname` was intended for internal use and has been removed from all exporters
* (user-facing) `url` was intended for internal use and has been removed from all exporters
* (user-facing) `timeoutMillis` was intended for internal use and has been removed from all exporters
* (user-facing) `onInit` was intended for internal use and has been removed from all exporters
* fix(exporter-*-otlp-*): fixes a bug where signal-specific environment variables would not be applied and the trace-specific one was used instead [#4971](https://github.com/open-telemetry/opentelemetry-js/pull/4971) @pichlermarc
* Fixes:
* `OTEL_EXPORTER_OTLP_METRICS_COMPRESSION`
Expand All @@ -39,14 +47,8 @@ All notable changes to experimental packages in this project will be documented
* `OTEL_EXPORTER_OTLP_LOGS_CLIENT_KEY`
* `OTEL_EXPORTER_OTLP_METRICS_INSECURE`
* `OTEL_EXPORTER_OTLP_LOGS_INSECURE`
* feat(otlp-exporter-base)!: do not export functions that are intended for internal use [#4971](https://github.com/open-telemetry/opentelemetry-js/pull/4971) @pichlermarc
* Drops the following functions and types that were intended for internal use from the package exports:
* `parseHeaders`
* `appendResourcePathToUrl`
* `appendResourcePathToUrlIfNeeded`
* `configureExporterTimeout`
* `invalidTimeout`
* 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)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@
*/

import {
OTLPExporterConfigBase,
OTLPExporterNodeBase,
OTLPExporterNodeConfigBase,
} from '@opentelemetry/otlp-exporter-base';
import {
IExportLogsServiceResponse,
Expand All @@ -37,7 +37,7 @@ export class OTLPLogExporter
extends OTLPExporterNodeBase<ReadableLogRecord, IExportLogsServiceResponse>
implements LogRecordExporter
{
constructor(config: OTLPExporterConfigBase = {}) {
constructor(config: OTLPExporterNodeConfigBase = {}) {
super(
config,
ProtobufLogsSerializer,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import {
createSslCredentials,
} from '../../src/grpc-exporter-transport';
import * as fs from 'fs';
import { VERSION } from '../../src/version';

describe('mergeOtlpGrpcConfigurationWithDefaults', function () {
describe('metadata', function () {
Expand Down Expand Up @@ -56,7 +57,7 @@ describe('mergeOtlpGrpcConfigurationWithDefaults', function () {
foo: 'foo-user', // does not use fallback if the user has set something
bar: 'bar-fallback', // uses fallback if there is no value set
baz: 'baz-user', // does not drop user-set metadata if there is no fallback for it
'user-agent': 'OTel-OTLP-Exporter-JavaScript/0.53.0',
'user-agent': 'OTel-OTLP-Exporter-JavaScript/' + VERSION,
});
});

Expand All @@ -81,7 +82,7 @@ describe('mergeOtlpGrpcConfigurationWithDefaults', function () {
);

assert.deepStrictEqual(config.metadata().getMap(), {
'user-agent': 'OTel-OTLP-Exporter-JavaScript/0.53.0',
'user-agent': 'OTel-OTLP-Exporter-JavaScript/' + VERSION,
});
});

Expand All @@ -94,7 +95,7 @@ describe('mergeOtlpGrpcConfigurationWithDefaults', function () {
);

assert.deepStrictEqual(config.metadata().getMap(), {
'user-agent': 'OTel-OTLP-Exporter-JavaScript/0.53.0',
'user-agent': 'OTel-OTLP-Exporter-JavaScript/' + VERSION,
});
});
});
Expand Down
2 changes: 2 additions & 0 deletions integration-tests/tracecontext-integration-test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ mkdir -p target
rm -rf ./target/trace-context
git clone https://github.com/w3c/trace-context ./target/trace-context
cd ./target/trace-context && git checkout $TRACECONTEXT_GIT_TAG && cd -
python3 -m venv ./.venv
source ./.venv/bin/activate
pip3 install setuptools;
pip3 install aiohttp;
node ./integration-tests/propagation-validation-server/validation-server.js 1>&2 &
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@
"docs": "typedoc --readme none && touch docs/.nojekyll",
"docs-deploy": "gh-pages --dotfiles --dist docs",
"docs:test": "linkinator docs --silent --retry && linkinator doc/*.md --skip http://localhost:3000 --skip http://localhost:9464 --silent --retry",
"lint": "lerna run lint",
"lint": "lerna run lint && npm run lint:markdown",
"lint:changed": "lerna run --concurrency 1 --stream lint --since HEAD --exclude-dependents",
"lint:fix": "lerna run lint:fix",
"lint:fix": "lerna run lint:fix && npm run lint:markdown:fix",
"lint:fix:changed": "lerna run --concurrency 1 --stream lint:fix --since HEAD --exclude-dependents",
"lint:examples": "eslint --no-error-on-unmatched-pattern ./examples/**/*.js",
"lint:examples:fix": "eslint --no-error-on-unmatched-pattern ./examples/**/*.js --fix",
Expand Down
1 change: 1 addition & 0 deletions packages/opentelemetry-resources/src/detect-resources.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ export const detectResourcesSync = (
if (isPromiseLike<Resource>(resourceOrPromise)) {
const createPromise = async () => {
const resolvedResource = await resourceOrPromise;
await resolvedResource.waitForAsyncAttributes?.();
return resolvedResource.attributes;
};
resource = new Resource({}, createPromise());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,10 @@ describe('detectResourcesSync', () => {
it('handles resource detectors which return Promise<Resource>', async () => {
const detector: Detector = {
async detect() {
return new Resource({ sync: 'fromsync' });
return new Resource(
{ sync: 'fromsync' },
Promise.resolve().then(() => ({ async: 'fromasync' }))
);
},
};
const resource = detectResourcesSync({
Expand All @@ -38,6 +41,7 @@ describe('detectResourcesSync', () => {
await resource.waitForAsyncAttributes?.();
assert.deepStrictEqual(resource.attributes, {
sync: 'fromsync',
async: 'fromasync',
});
});

Expand Down

0 comments on commit 383220c

Please sign in to comment.