platformatic icon indicating copy to clipboard operation
platformatic copied to clipboard

Telemetry in runtime with node app emits a warning which show as an error in logs.

Open marcopiraccini opened this issue 8 months ago • 1 comments

To reproduce add telemetry to a runtime with a node service. Will start correctly, but emitting this warning which appears in the log as error (because is sent to stderr)

[19:53:38.774] ERROR (express:0/2056772) <STDERR>: (node:2056772) ExperimentalWarning: `--experimental-loader` may be removed in the future; instead use `register()`:
--import 'data:text/javascript,import { register } from "node:module"; import { pathToFileURL } from "node:url"; register("%40opentelemetry/instrumentation/hook.mjs", pathToFileURL("./"));'
(Use `node --trace-warnings ...` to show where the warning was created)

This happens because: https://github.com/platformatic/platformatic/blob/main/packages/runtime/lib/runtime.js#L1074 Which is necesary because of: https://github.com/open-telemetry/opentelemetry-js/blob/main/doc/esm-support.md#instrumentation-hook-required-for-esm

A solution could be to catch the event emitted on the process and log them correctly as warning. Or hide it, since the user cannot really do anything about that, and it's expected.

marcopiraccini avatar Mar 31 '25 18:03 marcopiraccini

We could also just create our own wrapper around that to use --import instead, since we're not supporting old versions. See: https://github.com/open-telemetry/opentelemetry-js/issues/4933

Qard avatar Apr 01 '25 13:04 Qard

This is not actual anymore after the otel upgrades, closing.

marcopiraccini avatar Nov 06 '25 10:11 marcopiraccini