Skip to content
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

fix(otlp-exporter-base): use dynamic import instead of require in esm/esnext build #5220

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
3 changes: 3 additions & 0 deletions experimental/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ All notable changes to experimental packages in this project will be documented

### :bug: (Bug Fix)

* fix(otlp-exporter-base): use dynamic imports over require for lazy-loading http transport utils [#5220](https://github.com/open-telemetry/opentelemetry-js/pull/5220) @pichlermarc
* enables bundling of Node.js HTTP exporters with rollup
* Limitation: if a single-file bundle is built the dynamically loaded file needs to be inlined via rollup's `inlineDynamicImports: true` setting. However, doing so may lead to `@opentelemetry/instrumentation-http` not generating telemetry.
* fix(exporter-metrics-otlp-http): browser OTLPMetricExporter was not passing config to OTLPMetricExporterBase super class [#5331](https://github.com/open-telemetry/opentelemetry-js/pull/5331) @trentm

### :books: (Refine Doc)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,9 @@
async send(data: Uint8Array, timeoutMillis: number): Promise<ExportResponse> {
if (this._send == null) {
// Lazy require to ensure that http/https is not required before instrumentations can wrap it.
const {
sendWithHttp,
createHttpAgent,
// eslint-disable-next-line @typescript-eslint/no-var-requires
} = require('./http-transport-utils');
const { sendWithHttp, createHttpAgent } = await import(
'./http-transport-utils'

Check failure on line 39 in experimental/packages/otlp-exporter-base/src/transport/http-exporter-transport.ts

View workflow job for this annotation

GitHub Actions / build

Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Did you mean './http-transport-utils.js'?

Check failure on line 39 in experimental/packages/otlp-exporter-base/src/transport/http-exporter-transport.ts

View workflow job for this annotation

GitHub Actions / build

Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Did you mean './http-transport-utils.js'?

Check failure on line 39 in experimental/packages/otlp-exporter-base/src/transport/http-exporter-transport.ts

View workflow job for this annotation

GitHub Actions / build

Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Did you mean './http-transport-utils.js'?

Check failure on line 39 in experimental/packages/otlp-exporter-base/src/transport/http-exporter-transport.ts

View workflow job for this annotation

GitHub Actions / browser-tests

Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Did you mean './http-transport-utils.js'?

Check failure on line 39 in experimental/packages/otlp-exporter-base/src/transport/http-exporter-transport.ts

View workflow job for this annotation

GitHub Actions / browser-tests

Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Did you mean './http-transport-utils.js'?

Check failure on line 39 in experimental/packages/otlp-exporter-base/src/transport/http-exporter-transport.ts

View workflow job for this annotation

GitHub Actions / browser-tests

Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Did you mean './http-transport-utils.js'?

Check failure on line 39 in experimental/packages/otlp-exporter-base/src/transport/http-exporter-transport.ts

View workflow job for this annotation

GitHub Actions / node-tests (18)

Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Did you mean './http-transport-utils.js'?

Check failure on line 39 in experimental/packages/otlp-exporter-base/src/transport/http-exporter-transport.ts

View workflow job for this annotation

GitHub Actions / node-tests (18)

Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Did you mean './http-transport-utils.js'?

Check failure on line 39 in experimental/packages/otlp-exporter-base/src/transport/http-exporter-transport.ts

View workflow job for this annotation

GitHub Actions / node-tests (18)

Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Did you mean './http-transport-utils.js'?

Check failure on line 39 in experimental/packages/otlp-exporter-base/src/transport/http-exporter-transport.ts

View workflow job for this annotation

GitHub Actions / node-windows-tests

Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Did you mean './http-transport-utils.js'?

Check failure on line 39 in experimental/packages/otlp-exporter-base/src/transport/http-exporter-transport.ts

View workflow job for this annotation

GitHub Actions / node-windows-tests

Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Did you mean './http-transport-utils.js'?

Check failure on line 39 in experimental/packages/otlp-exporter-base/src/transport/http-exporter-transport.ts

View workflow job for this annotation

GitHub Actions / node-windows-tests

Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Did you mean './http-transport-utils.js'?

Check failure on line 39 in experimental/packages/otlp-exporter-base/src/transport/http-exporter-transport.ts

View workflow job for this annotation

GitHub Actions / node-tests (20)

Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Did you mean './http-transport-utils.js'?

Check failure on line 39 in experimental/packages/otlp-exporter-base/src/transport/http-exporter-transport.ts

View workflow job for this annotation

GitHub Actions / node-tests (20)

Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Did you mean './http-transport-utils.js'?

Check failure on line 39 in experimental/packages/otlp-exporter-base/src/transport/http-exporter-transport.ts

View workflow job for this annotation

GitHub Actions / node-tests (20)

Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Did you mean './http-transport-utils.js'?

Check failure on line 39 in experimental/packages/otlp-exporter-base/src/transport/http-exporter-transport.ts

View workflow job for this annotation

GitHub Actions / node-tests (22)

Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Did you mean './http-transport-utils.js'?

Check failure on line 39 in experimental/packages/otlp-exporter-base/src/transport/http-exporter-transport.ts

View workflow job for this annotation

GitHub Actions / node-tests (22)

Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Did you mean './http-transport-utils.js'?

Check failure on line 39 in experimental/packages/otlp-exporter-base/src/transport/http-exporter-transport.ts

View workflow job for this annotation

GitHub Actions / node-tests (22)

Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Did you mean './http-transport-utils.js'?

Check failure on line 39 in experimental/packages/otlp-exporter-base/src/transport/http-exporter-transport.ts

View workflow job for this annotation

GitHub Actions / webworker-tests

Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Did you mean './http-transport-utils.js'?

Check failure on line 39 in experimental/packages/otlp-exporter-base/src/transport/http-exporter-transport.ts

View workflow job for this annotation

GitHub Actions / webworker-tests

Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Did you mean './http-transport-utils.js'?

Check failure on line 39 in experimental/packages/otlp-exporter-base/src/transport/http-exporter-transport.ts

View workflow job for this annotation

GitHub Actions / webworker-tests

Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Did you mean './http-transport-utils.js'?
);
this._agent = createHttpAgent(
this._parameters.url,
this._parameters.agentOptions
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
"compilerOptions": {
"outDir": "build/esm",
"rootDir": "src",
"tsBuildInfoFile": "build/esm/tsconfig.esm.tsbuildinfo"
"tsBuildInfoFile": "build/esm/tsconfig.esm.tsbuildinfo",
"module": "es2020"
},
"include": [
"src/**/*.ts"
Expand Down
Loading