open-telemetry / opentelemetry.io

The OpenTelemetry website and documentation
https://opentelemetry.io
Creative Commons Attribution 4.0 International
535 stars 1.17k forks source link

Node.js - v18.20.0 following example in Angular causes error #5474

Closed jscancella closed 1 hour ago

jscancella commented 4 hours ago

Hello,

While trying to follow https://opentelemetry.io/docs/languages/js/getting-started/nodejs/#setup in my own angular application I am getting compile errors. When I then try and install the missing dependencies, it continues to have the same compiler errors.

NPM version: 10.5.0 Node version: v18.20.0

Expected results: I include the same code as the example and get traces and metrics auto instrumented Actual results:

./node_modules/@grpc/grpc-js/build/src/call.js:24:17-34 - Error: Module not found: Error: Can't resolve 'stream' in 'C:\Users\jscancella\repos\tm-admin-console-ui\node_modules\@grpc\grpc-js\build\src'

BREAKING CHANGE: webpack < 5 used to include polyfills for node.js core modules by default.
This is no longer the case. Verify if you need this module and configure a polyfill for it.

If you want to include a polyfill, you need to:
        - add a fallback 'resolve.fallback: { "stream": require.resolve("stream-browserify") }'
        - install 'stream-browserify'
If you don't want to include a polyfill, you can use an empty module like this:
        resolve.fallback: { "stream": false }

./node_modules/@grpc/grpc-js/build/src/certificate-provider.js:23:11-24 - Error: Module not found: Error: Can't resolve 'fs' in 'C:\Users\jscancella\repos\tm-admin-console-ui\node_modules\@grpc\grpc-js\build\src'

./node_modules/@grpc/grpc-js/build/src/certificate-provider.js:26:15-30 - Error: Module not found: Error: Can't resolve 'util' in 'C:\Users\jscancella\repos\tm-admin-console-ui\node_modules\@grpc\grpc-js\build\src'

BREAKING CHANGE: webpack < 5 used to include polyfills for node.js core modules by default.
This is no longer the case. Verify if you need this module and configure a polyfill for it.

If you want to include a polyfill, you need to:
        - add a fallback 'resolve.fallback: { "util": require.resolve("util/") }'
        - install 'util'
If you don't want to include a polyfill, you can use an empty module like this:
        resolve.fallback: { "util": false }

./node_modules/@grpc/grpc-js/build/src/channel-credentials.js:23:14-28 - Error: Module not found: Error: Can't resolve 'tls' in 'C:\Users\jscancella\repos\tm-admin-console-ui\node_modules\@grpc\grpc-js\build\src'

./node_modules/@grpc/grpc-js/build/src/channelz.js:23:14-28 - Error: Module not found: Error: Can't resolve 'net' in 'C:\Users\jscancella\repos\tm-admin-console-ui\node_modules\@grpc\grpc-js\build\src'

./node_modules/@grpc/grpc-js/build/src/compression-filter.js:24:13-28 - Error: Module not found: Error: Can't resolve 'zlib' in 'C:\Users\jscancella\repos\tm-admin-console-ui\node_modules\@grpc\grpc-js\build\src'

BREAKING CHANGE: webpack < 5 used to include polyfills for node.js core modules by default.
This is no longer the case. Verify if you need this module and configure a polyfill for it.

If you want to include a polyfill, you need to:
        - add a fallback 'resolve.fallback: { "zlib": require.resolve("browserify-zlib") }'
        - install 'browserify-zlib'
If you don't want to include a polyfill, you can use an empty module like this:
        resolve.fallback: { "zlib": false }

./node_modules/@grpc/grpc-js/build/src/http_proxy.js:26:13-28 - Error: Module not found: Error: Can't resolve 'http' in 'C:\Users\jscancella\repos\tm-admin-console-ui\node_modules\@grpc\grpc-js\build\src'

BREAKING CHANGE: webpack < 5 used to include polyfills for node.js core modules by default.
This is no longer the case. Verify if you need this module and configure a polyfill for it.

If you want to include a polyfill, you need to:
        - add a fallback 'resolve.fallback: { "http": require.resolve("stream-http") }'
        - install 'stream-http'
If you don't want to include a polyfill, you can use an empty module like this:
        resolve.fallback: { "http": false }

./node_modules/@grpc/grpc-js/build/src/http_proxy.js:27:12-26 - Error: Module not found: Error: Can't resolve 'tls' in 'C:\Users\jscancella\repos\tm-admin-console-ui\node_modules\@grpc\grpc-js\build\src'

./node_modules/@grpc/grpc-js/build/src/http_proxy.js:31:14-28 - Error: Module not found: Error: Can't resolve 'url' in 'C:\Users\jscancella\repos\tm-admin-console-ui\node_modules\@grpc\grpc-js\build\src'

BREAKING CHANGE: webpack < 5 used to include polyfills for node.js core modules by default.
This is no longer the case. Verify if you need this module and configure a polyfill for it.

If you want to include a polyfill, you need to:
        - add a fallback 'resolve.fallback: { "url": require.resolve("url/") }'
        - install 'url'
If you don't want to include a polyfill, you can use an empty module like this:
        resolve.fallback: { "url": false }

./node_modules/@grpc/grpc-js/build/src/load-balancer-pick-first.js:30:14-28 - Error: Module not found: Error: Can't resolve 'net' in 'C:\Users\jscancella\repos\tm-admin-console-ui\node_modules\@grpc\grpc-js\build\src'

./node_modules/@grpc/grpc-js/build/src/load-balancing-call.js:31:14-30 - Error: Module not found: Error: Can't resolve 'http2' in 'C:\Users\jscancella\repos\tm-admin-console-ui\node_modules\@grpc\grpc-js\build\src'

./node_modules/@grpc/grpc-js/build/src/logging.js:25:18-36 - Error: Module not found: Error: Can't resolve 'process' in 'C:\Users\jscancella\repos\tm-admin-console-ui\node_modules\@grpc\grpc-js\build\src'

BREAKING CHANGE: webpack < 5 used to include polyfills for node.js core modules by default.
This is no longer the case. Verify if you need this module and configure a polyfill for it.

If you want to include a polyfill, you need to:
        - add a fallback 'resolve.fallback: { "process": require.resolve("process/browser") }'
        - install 'process'
If you don't want to include a polyfill, you can use an empty module like this:
        resolve.fallback: { "process": false }

./node_modules/@grpc/grpc-js/build/src/resolver-dns.js:24:14-28 - Error: Module not found: Error: Can't resolve 'dns' in 'C:\Users\jscancella\repos\tm-admin-console-ui\node_modules\@grpc\grpc-js\build\src'

./node_modules/@grpc/grpc-js/build/src/resolver-dns.js:31:14-28 - Error: Module not found: Error: Can't resolve 'net' in 'C:\Users\jscancella\repos\tm-admin-console-ui\node_modules\@grpc\grpc-js\build\src'

./node_modules/@grpc/grpc-js/build/src/resolver-ip.js:22:14-28 - Error: Module not found: Error: Can't resolve 'net' in 'C:\Users\jscancella\repos\tm-admin-console-ui\node_modules\@grpc\grpc-js\build\src'

./node_modules/@grpc/grpc-js/build/src/server-call.js:24:17-34 - Error: Module not found: Error: Can't resolve 'stream' in 'C:\Users\jscancella\repos\tm-admin-console-ui\node_modules\@grpc\grpc-js\build\src'

BREAKING CHANGE: webpack < 5 used to include polyfills for node.js core modules by default.
This is no longer the case. Verify if you need this module and configure a polyfill for it.

If you want to include a polyfill, you need to:
        - add a fallback 'resolve.fallback: { "stream": require.resolve("stream-browserify") }'
        - install 'stream-browserify'
If you don't want to include a polyfill, you can use an empty module like this:
        resolve.fallback: { "stream": false }

./node_modules/@grpc/grpc-js/build/src/server-interceptors.js:26:14-30 - Error: Module not found: Error: Can't resolve 'http2' in 'C:\Users\jscancella\repos\tm-admin-console-ui\node_modules\@grpc\grpc-js\build\src'

./node_modules/@grpc/grpc-js/build/src/server-interceptors.js:28:13-28 - Error: Module not found: Error: Can't resolve 'zlib' in 'C:\Users\jscancella\repos\tm-admin-console-ui\node_modules\@grpc\grpc-js\build\src'

BREAKING CHANGE: webpack < 5 used to include polyfills for node.js core modules by default.
This is no longer the case. Verify if you need this module and configure a polyfill for it.

If you want to include a polyfill, you need to:
        - add a fallback 'resolve.fallback: { "zlib": require.resolve("browserify-zlib") }'
        - install 'browserify-zlib'
If you don't want to include a polyfill, you can use an empty module like this:
        resolve.fallback: { "zlib": false }

./node_modules/@grpc/grpc-js/build/src/server.js:67:14-30 - Error: Module not found: Error: Can't resolve 'http2' in 'C:\Users\jscancella\repos\tm-admin-console-ui\node_modules\@grpc\grpc-js\build\src'

./node_modules/@grpc/grpc-js/build/src/server.js:68:13-28 - Error: Module not found: Error: Can't resolve 'util' in 'C:\Users\jscancella\repos\tm-admin-console-ui\node_modules\@grpc\grpc-js\build\src'

BREAKING CHANGE: webpack < 5 used to include polyfills for node.js core modules by default.
This is no longer the case. Verify if you need this module and configure a polyfill for it.

If you want to include a polyfill, you need to:
        - add a fallback 'resolve.fallback: { "util": require.resolve("util/") }'
        - install 'util'
If you don't want to include a polyfill, you can use an empty module like this:
        resolve.fallback: { "util": false }

./node_modules/@grpc/grpc-js/build/src/service-config.js:32:11-24 - Error: Module not found: Error: Can't resolve 'os' in 'C:\Users\jscancella\repos\tm-admin-console-ui\node_modules\@grpc\grpc-js\build\src'

BREAKING CHANGE: webpack < 5 used to include polyfills for node.js core modules by default.
This is no longer the case. Verify if you need this module and configure a polyfill for it.

If you want to include a polyfill, you need to:
        - add a fallback 'resolve.fallback: { "os": require.resolve("os-browserify/browser") }'
        - install 'os-browserify'
If you don't want to include a polyfill, you can use an empty module like this:
        resolve.fallback: { "os": false }

./node_modules/@grpc/grpc-js/build/src/subchannel-address.js:23:14-28 - Error: Module not found: Error: Can't resolve 'net' in 'C:\Users\jscancella\repos\tm-admin-console-ui\node_modules\@grpc\grpc-js\build\src'

./node_modules/@grpc/grpc-js/build/src/subchannel-call.js:23:14-30 - Error: Module not found: Error: Can't resolve 'http2' in 'C:\Users\jscancella\repos\tm-admin-console-ui\node_modules\@grpc\grpc-js\build\src'

./node_modules/@grpc/grpc-js/build/src/subchannel-call.js:24:11-24 - Error: Module not found: Error: Can't resolve 'os' in 'C:\Users\jscancella\repos\tm-admin-console-ui\node_modules\@grpc\grpc-js\build\src'

BREAKING CHANGE: webpack < 5 used to include polyfills for node.js core modules by default.
This is no longer the case. Verify if you need this module and configure a polyfill for it.

If you want to include a polyfill, you need to:
        - add a fallback 'resolve.fallback: { "os": require.resolve("os-browserify/browser") }'
        - install 'os-browserify'
If you don't want to include a polyfill, you can use an empty module like this:
        resolve.fallback: { "os": false }

./node_modules/@grpc/grpc-js/build/src/tls-helpers.js:23:11-24 - Error: Module not found: Error: Can't resolve 'fs' in 'C:\Users\jscancella\repos\tm-admin-console-ui\node_modules\@grpc\grpc-js\build\src'

./node_modules/@grpc/grpc-js/build/src/transport.js:23:14-30 - Error: Module not found: Error: Can't resolve 'http2' in 'C:\Users\jscancella\repos\tm-admin-console-ui\node_modules\@grpc\grpc-js\build\src'

./node_modules/@grpc/grpc-js/build/src/transport.js:24:14-28 - Error: Module not found: Error: Can't resolve 'tls' in 'C:\Users\jscancella\repos\tm-admin-console-ui\node_modules\@grpc\grpc-js\build\src'

./node_modules/@grpc/grpc-js/build/src/transport.js:32:12-26 - Error: Module not found: Error: Can't resolve 'net' in 'C:\Users\jscancella\repos\tm-admin-console-ui\node_modules\@grpc\grpc-js\build\src'

./node_modules/@grpc/proto-loader/build/src/util.js:25:11-24 - Error: Module not found: Error: Can't resolve 'fs' in 'C:\Users\jscancella\repos\tm-admin-console-ui\node_modules\@grpc\proto-loader\build\src'

./node_modules/@grpc/proto-loader/build/src/util.js:26:13-28 - Error: Module not found: Error: Can't resolve 'path' in 'C:\Users\jscancella\repos\tm-admin-console-ui\node_modules\@grpc\proto-loader\build\src'

BREAKING CHANGE: webpack < 5 used to include polyfills for node.js core modules by default.
This is no longer the case. Verify if you need this module and configure a polyfill for it.

If you want to include a polyfill, you need to:
        - add a fallback 'resolve.fallback: { "path": require.resolve("path-browserify") }'
        - install 'path-browserify'
If you don't want to include a polyfill, you can use an empty module like this:
        resolve.fallback: { "path": false }

./node_modules/@opentelemetry/context-async-hooks/build/src/AsyncHooksContextManager.js:23:19-41 - Error: Module not found: Error: Can't resolve 'async_hooks' in 'C:\Users\jscancella\repos\tm-admin-console-ui\node_modules\@opentelemetry\context-async-hooks\build\src'

./node_modules/@opentelemetry/context-async-hooks/build/src/AsyncLocalStorageContextManager.js:23:22-44 - Error: Module not found: Error: Can't resolve 'async_hooks' in 'C:\Users\jscancella\repos\tm-admin-console-ui\node_modules\@opentelemetry\context-async-hooks\build\src'

./node_modules/@opentelemetry/instrumentation-aws-lambda/build/src/instrumentation.js:22:13-28 - Error: Module not found: Error: Can't resolve 'path' in 'C:\Users\jscancella\repos\tm-admin-console-ui\node_modules\@opentelemetry\instrumentation-aws-lambda\build\src'

BREAKING CHANGE: webpack < 5 used to include polyfills for node.js core modules by default.
This is no longer the case. Verify if you need this module and configure a polyfill for it.

If you want to include a polyfill, you need to:
        - add a fallback 'resolve.fallback: { "path": require.resolve("path-browserify") }'
        - install 'path-browserify'
If you don't want to include a polyfill, you can use an empty module like this:
        resolve.fallback: { "path": false }

./node_modules/@opentelemetry/instrumentation-aws-lambda/build/src/instrumentation.js:23:11-24 - Error: Module not found: Error: Can't resolve 'fs' in 'C:\Users\jscancella\repos\tm-admin-console-ui\node_modules\@opentelemetry\instrumentation-aws-lambda\build\src'

./node_modules/@opentelemetry/instrumentation-aws-lambda/build/src/instrumentation.js:30:18-36 - Error: Module not found: Error: Can't resolve 'process' in 'C:\Users\jscancella\repos\tm-admin-console-ui\node_modules\@opentelemetry\instrumentation-aws-lambda\build\src'

BREAKING CHANGE: webpack < 5 used to include polyfills for node.js core modules by default.
This is no longer the case. Verify if you need this module and configure a polyfill for it.

If you want to include a polyfill, you need to:
        - add a fallback 'resolve.fallback: { "process": require.resolve("process/browser") }'
        - install 'process'
If you don't want to include a polyfill, you can use an empty module like this:
        resolve.fallback: { "process": false }

./node_modules/@opentelemetry/instrumentation-bunyan/build/src/instrumentation.js:22:15-30 - Error: Module not found: Error: Can't resolve 'util' in 'C:\Users\jscancella\repos\tm-admin-console-ui\node_modules\@opentelemetry\instrumentation-bunyan\build\src'

BREAKING CHANGE: webpack < 5 used to include polyfills for node.js core modules by default.
This is no longer the case. Verify if you need this module and configure a polyfill for it.

If you want to include a polyfill, you need to:
        - add a fallback 'resolve.fallback: { "util": require.resolve("util/") }'
        - install 'util'
If you don't want to include a polyfill, you can use an empty module like this:
        resolve.fallback: { "util": false }

./node_modules/@opentelemetry/instrumentation-fs/build/src/instrumentation.js:28:15-30 - Error: Module not found: Error: Can't resolve 'util' in 'C:\Users\jscancella\repos\tm-admin-console-ui\node_modules\@opentelemetry\instrumentation-fs\build\src'

BREAKING CHANGE: webpack < 5 used to include polyfills for node.js core modules by default.
This is no longer the case. Verify if you need this module and configure a polyfill for it.

If you want to include a polyfill, you need to:
        - add a fallback 'resolve.fallback: { "util": require.resolve("util/") }'
        - install 'util'
If you don't want to include a polyfill, you can use an empty module like this:
        resolve.fallback: { "util": false }

./node_modules/@opentelemetry/instrumentation-http/build/src/http.js:25:12-26 - Error: Module not found: Error: Can't resolve 'url' in 'C:\Users\jscancella\repos\tm-admin-console-ui\node_modules\@opentelemetry\instrumentation-http\build\src'

BREAKING CHANGE: webpack < 5 used to include polyfills for node.js core modules by default.
This is no longer the case. Verify if you need this module and configure a polyfill for it.

If you want to include a polyfill, you need to:
        - add a fallback 'resolve.fallback: { "url": require.resolve("url/") }'
        - install 'url'
If you don't want to include a polyfill, you can use an empty module like this:
        resolve.fallback: { "url": false }

./node_modules/@opentelemetry/instrumentation-http/build/src/utils.js:25:12-26 - Error: Module not found: Error: Can't resolve 'url' in 'C:\Users\jscancella\repos\tm-admin-console-ui\node_modules\@opentelemetry\instrumentation-http\build\src'

BREAKING CHANGE: webpack < 5 used to include polyfills for node.js core modules by default.
This is no longer the case. Verify if you need this module and configure a polyfill for it.

If you want to include a polyfill, you need to:
        - add a fallback 'resolve.fallback: { "url": require.resolve("url/") }'
        - install 'url'
If you don't want to include a polyfill, you can use an empty module like this:
        resolve.fallback: { "url": false }

./node_modules/@opentelemetry/instrumentation-net/build/src/instrumentation.js:29:14-28 - Error: Module not found: Error: Can't resolve 'tls' in 'C:\Users\jscancella\repos\tm-admin-console-ui\node_modules\@opentelemetry\instrumentation-net\build\src'

./node_modules/@opentelemetry/instrumentation-net/build/src/utils.js:23:13-26 - Error: Module not found: Error: Can't resolve 'os' in 'C:\Users\jscancella\repos\tm-admin-console-ui\node_modules\@opentelemetry\instrumentation-net\build\src'

BREAKING CHANGE: webpack < 5 used to include polyfills for node.js core modules by default.
This is no longer the case. Verify if you need this module and configure a polyfill for it.

If you want to include a polyfill, you need to:
        - add a fallback 'resolve.fallback: { "os": require.resolve("os-browserify/browser") }'
        - install 'os-browserify'
If you don't want to include a polyfill, you can use an empty module like this:
        resolve.fallback: { "os": false }

./node_modules/@opentelemetry/instrumentation-pino/build/src/log-sending-utils.js:30:17-34 - Error: Module not found: Error: Can't resolve 'stream' in 'C:\Users\jscancella\repos\tm-admin-console-ui\node_modules\@opentelemetry\instrumentation-pino\build\src'

BREAKING CHANGE: webpack < 5 used to include polyfills for node.js core modules by default.
This is no longer the case. Verify if you need this module and configure a polyfill for it.

If you want to include a polyfill, you need to:
        - add a fallback 'resolve.fallback: { "stream": require.resolve("stream-browserify") }'
        - install 'stream-browserify'
If you don't want to include a polyfill, you can use an empty module like this:
        resolve.fallback: { "stream": false }

./node_modules/@opentelemetry/instrumentation-undici/build/src/undici.js:22:15-45 - Error: Module not found: Error: Can't resolve 'diagnostics_channel' in 'C:\Users\jscancella\repos\tm-admin-console-ui\node_modules\@opentelemetry\instrumentation-undici\build\src'

./node_modules/@opentelemetry/instrumentation-undici/build/src/undici.js:23:14-28 - Error: Module not found: Error: Can't resolve 'url' in 'C:\Users\jscancella\repos\tm-admin-console-ui\node_modules\@opentelemetry\instrumentation-undici\build\src'

BREAKING CHANGE: webpack < 5 used to include polyfills for node.js core modules by default.
This is no longer the case. Verify if you need this module and configure a polyfill for it.

If you want to include a polyfill, you need to:
        - add a fallback 'resolve.fallback: { "url": require.resolve("url/") }'
        - install 'url'
If you don't want to include a polyfill, you can use an empty module like this:
        resolve.fallback: { "url": false }

./node_modules/@opentelemetry/otlp-grpc-exporter-base/build/src/util.js:24:13-28 - Error: Module not found: Error: Can't resolve 'path' in 'C:\Users\jscancella\repos\tm-admin-console-ui\node_modules\@opentelemetry\otlp-grpc-exporter-base\build\src'

BREAKING CHANGE: webpack < 5 used to include polyfills for node.js core modules by default.
This is no longer the case. Verify if you need this module and configure a polyfill for it.

If you want to include a polyfill, you need to:
        - add a fallback 'resolve.fallback: { "path": require.resolve("path-browserify") }'
        - install 'path-browserify'
If you don't want to include a polyfill, you can use an empty module like this:
        resolve.fallback: { "path": false }

./node_modules/@opentelemetry/otlp-grpc-exporter-base/build/src/util.js:25:14-28 - Error: Module not found: Error: Can't resolve 'url' in 'C:\Users\jscancella\repos\tm-admin-console-ui\node_modules\@opentelemetry\otlp-grpc-exporter-base\build\src'

BREAKING CHANGE: webpack < 5 used to include polyfills for node.js core modules by default.
This is no longer the case. Verify if you need this module and configure a polyfill for it.

If you want to include a polyfill, you need to:
        - add a fallback 'resolve.fallback: { "url": require.resolve("url/") }'
        - install 'url'
If you don't want to include a polyfill, you can use an empty module like this:
        resolve.fallback: { "url": false }

./node_modules/@opentelemetry/otlp-grpc-exporter-base/build/src/util.js:26:11-24 - Error: Module not found: Error: Can't resolve 'fs' in 'C:\Users\jscancella\repos\tm-admin-console-ui\node_modules\@opentelemetry\otlp-grpc-exporter-base\build\src'

./node_modules/@opentelemetry/resource-detector-alibaba-cloud/build/src/detectors/AlibabaCloudEcsDetector.js:27:13-28 - Error: Module not found: Error: Can't resolve 'http' in 'C:\Users\jscancella\repos\tm-admin-console-ui\node_modules\@opentelemetry\resource-detector-alibaba-cloud\build\src\detectors'

BREAKING CHANGE: webpack < 5 used to include polyfills for node.js core modules by default.
This is no longer the case. Verify if you need this module and configure a polyfill for it.

If you want to include a polyfill, you need to:
        - add a fallback 'resolve.fallback: { "http": require.resolve("stream-http") }'
        - install 'stream-http'
If you don't want to include a polyfill, you can use an empty module like this:
        resolve.fallback: { "http": false }

./node_modules/@opentelemetry/resource-detector-aws/build/src/detectors/AwsBeanstalkDetectorSync.js:27:11-24 - Error: Module not found: Error: Can't resolve 'fs' in 'C:\Users\jscancella\repos\tm-admin-console-ui\node_modules\@opentelemetry\resource-detector-aws\build\src\detectors'

./node_modules/@opentelemetry/resource-detector-aws/build/src/detectors/AwsBeanstalkDetectorSync.js:28:13-28 - Error: Module not found: Error: Can't resolve 'util' in 'C:\Users\jscancella\repos\tm-admin-console-ui\node_modules\@opentelemetry\resource-detector-aws\build\src\detectors'

BREAKING CHANGE: webpack < 5 used to include polyfills for node.js core modules by default.
This is no longer the case. Verify if you need this module and configure a polyfill for it.

If you want to include a polyfill, you need to:
        - add a fallback 'resolve.fallback: { "util": require.resolve("util/") }'
        - install 'util'
If you don't want to include a polyfill, you can use an empty module like this:
        resolve.fallback: { "util": false }

./node_modules/@opentelemetry/resource-detector-aws/build/src/detectors/AwsEcsDetectorSync.js:29:13-28 - Error: Module not found: Error: Can't resolve 'http' in 'C:\Users\jscancella\repos\tm-admin-console-ui\node_modules\@opentelemetry\resource-detector-aws\build\src\detectors'

BREAKING CHANGE: webpack < 5 used to include polyfills for node.js core modules by default.
This is no longer the case. Verify if you need this module and configure a polyfill for it.

If you want to include a polyfill, you need to:
        - add a fallback 'resolve.fallback: { "http": require.resolve("stream-http") }'
        - install 'stream-http'
If you don't want to include a polyfill, you can use an empty module like this:
        resolve.fallback: { "http": false }

./node_modules/@opentelemetry/resource-detector-aws/build/src/detectors/AwsEcsDetectorSync.js:30:13-28 - Error: Module not found: Error: Can't resolve 'util' in 'C:\Users\jscancella\repos\tm-admin-console-ui\node_modules\@opentelemetry\resource-detector-aws\build\src\detectors'

BREAKING CHANGE: webpack < 5 used to include polyfills for node.js core modules by default.
This is no longer the case. Verify if you need this module and configure a polyfill for it.

If you want to include a polyfill, you need to:
        - add a fallback 'resolve.fallback: { "util": require.resolve("util/") }'
        - install 'util'
If you don't want to include a polyfill, you can use an empty module like this:
        resolve.fallback: { "util": false }

./node_modules/@opentelemetry/resource-detector-aws/build/src/detectors/AwsEcsDetectorSync.js:31:11-24 - Error: Module not found: Error: Can't resolve 'fs' in 'C:\Users\jscancella\repos\tm-admin-console-ui\node_modules\@opentelemetry\resource-detector-aws\build\src\detectors'

./node_modules/@opentelemetry/resource-detector-aws/build/src/detectors/AwsEcsDetectorSync.js:32:11-24 - Error: Module not found: Error: Can't resolve 'os' in 'C:\Users\jscancella\repos\tm-admin-console-ui\node_modules\@opentelemetry\resource-detector-aws\build\src\detectors'

BREAKING CHANGE: webpack < 5 used to include polyfills for node.js core modules by default.
This is no longer the case. Verify if you need this module and configure a polyfill for it.

If you want to include a polyfill, you need to:
        - add a fallback 'resolve.fallback: { "os": require.resolve("os-browserify/browser") }'
        - install 'os-browserify'
If you don't want to include a polyfill, you can use an empty module like this:
        resolve.fallback: { "os": false }

./node_modules/@opentelemetry/resource-detector-aws/build/src/detectors/AwsEc2DetectorSync.js:27:13-28 - Error: Module not found: Error: Can't resolve 'http' in 'C:\Users\jscancella\repos\tm-admin-console-ui\node_modules\@opentelemetry\resource-detector-aws\build\src\detectors'

BREAKING CHANGE: webpack < 5 used to include polyfills for node.js core modules by default.
This is no longer the case. Verify if you need this module and configure a polyfill for it.

If you want to include a polyfill, you need to:
        - add a fallback 'resolve.fallback: { "http": require.resolve("stream-http") }'
        - install 'stream-http'
If you don't want to include a polyfill, you can use an empty module like this:
        resolve.fallback: { "http": false }

./node_modules/@opentelemetry/resource-detector-aws/build/src/detectors/AwsEksDetectorSync.js:27:14-30 - Error: Module not found: Error: Can't resolve 'https' in 'C:\Users\jscancella\repos\tm-admin-console-ui\node_modules\@opentelemetry\resource-detector-aws\build\src\detectors'

BREAKING CHANGE: webpack < 5 used to include polyfills for node.js core modules by default.
This is no longer the case. Verify if you need this module and configure a polyfill for it.

If you want to include a polyfill, you need to:
        - add a fallback 'resolve.fallback: { "https": require.resolve("https-browserify") }'
        - install 'https-browserify'
If you don't want to include a polyfill, you can use an empty module like this:
        resolve.fallback: { "https": false }

./node_modules/@opentelemetry/resource-detector-aws/build/src/detectors/AwsEksDetectorSync.js:28:11-24 - Error: Module not found: Error: Can't resolve 'fs' in 'C:\Users\jscancella\repos\tm-admin-console-ui\node_modules\@opentelemetry\resource-detector-aws\build\src\detectors'

./node_modules/@opentelemetry/resource-detector-aws/build/src/detectors/AwsEksDetectorSync.js:29:13-28 - Error: Module not found: Error: Can't resolve 'util' in 'C:\Users\jscancella\repos\tm-admin-console-ui\node_modules\@opentelemetry\resource-detector-aws\build\src\detectors'

BREAKING CHANGE: webpack < 5 used to include polyfills for node.js core modules by default.
This is no longer the case. Verify if you need this module and configure a polyfill for it.

If you want to include a polyfill, you need to:
        - add a fallback 'resolve.fallback: { "util": require.resolve("util/") }'
        - install 'util'
If you don't want to include a polyfill, you can use an empty module like this:
        resolve.fallback: { "util": false }

./node_modules/@opentelemetry/resource-detector-azure/build/src/detectors/AzureVmDetector.js:23:13-28 - Error: Module not found: Error: Can't resolve 'http' in 'C:\Users\jscancella\repos\tm-admin-console-ui\node_modules\@opentelemetry\resource-detector-azure\build\src\detectors'

BREAKING CHANGE: webpack < 5 used to include polyfills for node.js core modules by default.
This is no longer the case. Verify if you need this module and configure a polyfill for it.

If you want to include a polyfill, you need to:
        - add a fallback 'resolve.fallback: { "http": require.resolve("stream-http") }'
        - install 'stream-http'
If you don't want to include a polyfill, you can use an empty module like this:
        resolve.fallback: { "http": false }

./node_modules/@opentelemetry/resource-detector-container/build/src/detectors/ContainerDetector.js:25:11-24 - Error: Module not found: Error: Can't resolve 'fs' in 'C:\Users\jscancella\repos\tm-admin-console-ui\node_modules\@opentelemetry\resource-detector-container\build\src\detectors'

./node_modules/@opentelemetry/resource-detector-container/build/src/detectors/ContainerDetector.js:26:13-28 - Error: Module not found: Error: Can't resolve 'util' in 'C:\Users\jscancella\repos\tm-admin-console-ui\node_modules\@opentelemetry\resource-detector-container\build\src\detectors'

BREAKING CHANGE: webpack < 5 used to include polyfills for node.js core modules by default.
This is no longer the case. Verify if you need this module and configure a polyfill for it.

If you want to include a polyfill, you need to:
        - add a fallback 'resolve.fallback: { "util": require.resolve("util/") }'
        - install 'util'
If you don't want to include a polyfill, you can use an empty module like this:
        resolve.fallback: { "util": false }

./node_modules/agent-base/dist/helpers.js:40:26-41 - Error: Module not found: Error: Can't resolve 'http' in 'C:\Users\jscancella\repos\tm-admin-console-ui\node_modules\agent-base\dist'

BREAKING CHANGE: webpack < 5 used to include polyfills for node.js core modules by default.
This is no longer the case. Verify if you need this module and configure a polyfill for it.

If you want to include a polyfill, you need to:
        - add a fallback 'resolve.fallback: { "http": require.resolve("stream-http") }'
        - install 'stream-http'
If you don't want to include a polyfill, you can use an empty module like this:
        resolve.fallback: { "http": false }

./node_modules/agent-base/dist/helpers.js:41:27-43 - Error: Module not found: Error: Can't resolve 'https' in 'C:\Users\jscancella\repos\tm-admin-console-ui\node_modules\agent-base\dist'

BREAKING CHANGE: webpack < 5 used to include polyfills for node.js core modules by default.
This is no longer the case. Verify if you need this module and configure a polyfill for it.

If you want to include a polyfill, you need to:
        - add a fallback 'resolve.fallback: { "https": require.resolve("https-browserify") }'
        - install 'https-browserify'
If you don't want to include a polyfill, you can use an empty module like this:
        resolve.fallback: { "https": false }

./node_modules/agent-base/dist/index.js:41:25-39 - Error: Module not found: Error: Can't resolve 'net' in 'C:\Users\jscancella\repos\tm-admin-console-ui\node_modules\agent-base\dist'

./node_modules/agent-base/dist/index.js:42:26-41 - Error: Module not found: Error: Can't resolve 'http' in 'C:\Users\jscancella\repos\tm-admin-console-ui\node_modules\agent-base\dist'

BREAKING CHANGE: webpack < 5 used to include polyfills for node.js core modules by default.
This is no longer the case. Verify if you need this module and configure a polyfill for it.

If you want to include a polyfill, you need to:
        - add a fallback 'resolve.fallback: { "http": require.resolve("stream-http") }'
        - install 'stream-http'
If you don't want to include a polyfill, you can use an empty module like this:
        resolve.fallback: { "http": false }

./node_modules/agent-base/dist/index.js:43:16-32 - Error: Module not found: Error: Can't resolve 'https' in 'C:\Users\jscancella\repos\tm-admin-console-ui\node_modules\agent-base\dist'

BREAKING CHANGE: webpack < 5 used to include polyfills for node.js core modules by default.
This is no longer the case. Verify if you need this module and configure a polyfill for it.

If you want to include a polyfill, you need to:
        - add a fallback 'resolve.fallback: { "https": require.resolve("https-browserify") }'
        - install 'https-browserify'
If you don't want to include a polyfill, you can use an empty module like this:
        resolve.fallback: { "https": false }

./node_modules/gaxios/build/src/common.js:26:14-28 - Error: Module not found: Error: Can't resolve 'url' in 'C:\Users\jscancella\repos\tm-admin-console-ui\node_modules\gaxios\build\src'

BREAKING CHANGE: webpack < 5 used to include polyfills for node.js core modules by default.
This is no longer the case. Verify if you need this module and configure a polyfill for it.

If you want to include a polyfill, you need to:
        - add a fallback 'resolve.fallback: { "url": require.resolve("url/") }'
        - install 'url'
If you don't want to include a polyfill, you can use an empty module like this:
        resolve.fallback: { "url": false }

./node_modules/gaxios/build/src/gaxios.js:73:16-32 - Error: Module not found: Error: Can't resolve 'https' in 'C:\Users\jscancella\repos\tm-admin-console-ui\node_modules\gaxios\build\src'

BREAKING CHANGE: webpack < 5 used to include polyfills for node.js core modules by default.
This is no longer the case. Verify if you need this module and configure a polyfill for it.

If you want to include a polyfill, you need to:
        - add a fallback 'resolve.fallback: { "https": require.resolve("https-browserify") }'
        - install 'https-browserify'
If you don't want to include a polyfill, you can use an empty module like this:
        resolve.fallback: { "https": false }

./node_modules/gaxios/build/src/gaxios.js:75:38-60 - Error: Module not found: Error: Can't resolve 'querystring' in 'C:\Users\jscancella\repos\tm-admin-console-ui\node_modules\gaxios\build\src'

BREAKING CHANGE: webpack < 5 used to include polyfills for node.js core modules by default.
This is no longer the case. Verify if you need this module and configure a polyfill for it.

If you want to include a polyfill, you need to:
        - add a fallback 'resolve.fallback: { "querystring": require.resolve("querystring-es3") }'
        - install 'querystring-es3'
If you don't want to include a polyfill, you can use an empty module like this:
        resolve.fallback: { "querystring": false }

./node_modules/gaxios/build/src/gaxios.js:77:14-28 - Error: Module not found: Error: Can't resolve 'url' in 'C:\Users\jscancella\repos\tm-admin-console-ui\node_modules\gaxios\build\src'

BREAKING CHANGE: webpack < 5 used to include polyfills for node.js core modules by default.
This is no longer the case. Verify if you need this module and configure a polyfill for it.

If you want to include a polyfill, you need to:
        - add a fallback 'resolve.fallback: { "url": require.resolve("url/") }'
        - install 'url'
If you don't want to include a polyfill, you can use an empty module like this:
        resolve.fallback: { "url": false }

./node_modules/gaxios/build/src/gaxios.js:80:17-34 - Error: Module not found: Error: Can't resolve 'stream' in 'C:\Users\jscancella\repos\tm-admin-console-ui\node_modules\gaxios\build\src'

BREAKING CHANGE: webpack < 5 used to include polyfills for node.js core modules by default.
This is no longer the case. Verify if you need this module and configure a polyfill for it.

If you want to include a polyfill, you need to:
        - add a fallback 'resolve.fallback: { "stream": require.resolve("stream-browserify") }'
        - install 'stream-browserify'
If you don't want to include a polyfill, you can use an empty module like this:
        resolve.fallback: { "stream": false }

./node_modules/gcp-metadata/build/src/gcp-residency.js:22:13-26 - Error: Module not found: Error: Can't resolve 'fs' in 'C:\Users\jscancella\repos\tm-admin-console-ui\node_modules\gcp-metadata\build\src'

./node_modules/gcp-metadata/build/src/gcp-residency.js:23:13-26 - Error: Module not found: Error: Can't resolve 'os' in 'C:\Users\jscancella\repos\tm-admin-console-ui\node_modules\gcp-metadata\build\src'

BREAKING CHANGE: webpack < 5 used to include polyfills for node.js core modules by default.
This is no longer the case. Verify if you need this module and configure a polyfill for it.

If you want to include a polyfill, you need to:
        - add a fallback 'resolve.fallback: { "os": require.resolve("os-browserify/browser") }'
        - install 'os-browserify'
If you don't want to include a polyfill, you can use an empty module like this:
        resolve.fallback: { "os": false }

./node_modules/https-proxy-agent/dist/index.js:44:25-39 - Error: Module not found: Error: Can't resolve 'net' in 'C:\Users\jscancella\repos\tm-admin-console-ui\node_modules\https-proxy-agent\dist'

./node_modules/https-proxy-agent/dist/index.js:45:25-39 - Error: Module not found: Error: Can't resolve 'tls' in 'C:\Users\jscancella\repos\tm-admin-console-ui\node_modules\https-proxy-agent\dist'

./node_modules/https-proxy-agent/dist/index.js:46:33-50 - Error: Module not found: Error: Can't resolve 'assert' in 'C:\Users\jscancella\repos\tm-admin-console-ui\node_modules\https-proxy-agent\dist'

BREAKING CHANGE: webpack < 5 used to include polyfills for node.js core modules by default.
This is no longer the case. Verify if you need this module and configure a polyfill for it.

If you want to include a polyfill, you need to:
        - add a fallback 'resolve.fallback: { "assert": require.resolve("assert/") }'
        - install 'assert'
If you don't want to include a polyfill, you can use an empty module like this:
        resolve.fallback: { "assert": false }

./node_modules/https-proxy-agent/dist/index.js:49:14-28 - Error: Module not found: Error: Can't resolve 'url' in 'C:\Users\jscancella\repos\tm-admin-console-ui\node_modules\https-proxy-agent\dist'

BREAKING CHANGE: webpack < 5 used to include polyfills for node.js core modules by default.
This is no longer the case. Verify if you need this module and configure a polyfill for it.

If you want to include a polyfill, you need to:
        - add a fallback 'resolve.fallback: { "url": require.resolve("url/") }'
        - install 'url'
If you don't want to include a polyfill, you can use an empty module like this:
        resolve.fallback: { "url": false }

** Angular Live Development Server is listening on localhost:4200, open your browser on https://localhost:4200/ **

× Failed to compile.
svrnm commented 3 hours ago

since you mention the use of angular.js the browser based documentation is probably what you are looking for:

https://opentelemetry.io/docs/languages/js/getting-started/browser/

jscancella commented 2 hours ago

I don't think I want the browser one. This code is working, I just want it to be auto instrumented for metrics instead of having to manually do it myself

import { environment } from 'src/environments/environment';
import status from 'src/environments/status.json';

import { DiagConsoleLogger, DiagLogLevel, diag }  from '@opentelemetry/api';
import { OTLPMetricExporter } from '@opentelemetry/exporter-metrics-otlp-http';
//other optional exporters
//const { OTLPMetricExporter } = require('@opentelemetry/exporter-metrics-otlp-grpc');
//const { OTLPMetricExporter } = require('@opentelemetry/exporter-metrics-otlp-proto');
import { ConsoleMetricExporter } from '@opentelemetry/sdk-metrics' ;
import {
  ExponentialHistogramAggregation,
  MeterProvider,
  PeriodicExportingMetricReader,
  View
} from '@opentelemetry/sdk-metrics';
import { Resource } from '@opentelemetry/resources';
import { SemanticResourceAttributes } from '@opentelemetry/semantic-conventions';

// Optional and only needed to see the internal diagnostic logging (during development)
//diag.setLogger(new DiagConsoleLogger(), DiagLogLevel.DEBUG);

const collectorOptions = {
  url: environment.OTEL_COLLECTOR_URL + '/v1/metrics', // url is optional and can be omitted - default is http://localhost:4318/v1/metrics
  headers: {}, // an optional object containing custom headers to be sent with each request
  concurrencyLimit: 1, // an optional limit on pending requests
};
const metricExporter = new OTLPMetricExporter(collectorOptions);

// Create an instance of the metric provider
const meterProvider = new MeterProvider({
  resource: new Resource({
    [SemanticResourceAttributes.SERVICE_NAME]: 'TM-EADM',
    [SemanticResourceAttributes.SERVICE_VERSION]: status.version,
  }),
  views: [],
});

meterProvider.addMetricReader(
  new PeriodicExportingMetricReader({
    exporter: metricExporter,
    //exporter: new ConsoleMetricExporter(), //used for testing - print the metrics to the console
    exportIntervalMillis: 5000 //export data to otel collector every 5 seconds
  })
);

//fake some data, every 5 seconds add data to the metrics

const meter = meterProvider.getMeter('example-exporter-collector');

const requestCounter = meter.createCounter('requests', {
  description: 'Example of a Counter',
});

const upDownCounter = meter.createUpDownCounter('test_up_down_counter', {
  description: 'Example of a UpDownCounter',
});

const histogram = meter.createHistogram('test_histogram', {
  description: 'Example of a Histogram',
});

const exponentialHistogram = meter.createHistogram('test_exponential_histogram', {
  description: 'Example of an ExponentialHistogram',
});

const attributes = { env: 'local' };

setInterval(() => {
  requestCounter.add(1, attributes);
  upDownCounter.add(Math.random() > 0.5 ? 1 : -1, attributes);
  histogram.record(Math.random(), attributes);
  //exponentialHistogram.record(Math.random(), attributes);
}, 5000);
svrnm commented 2 hours ago

but if you want to run it in nodejs why are you running it through webpack, and why are you mentioning angular?

jscancella commented 2 hours ago

but if you want to run it in nodejs why are you running it through webpack, and why are you mentioning angular?

because I am new to the javascript world and don't really know what I am doing 😄

svrnm commented 2 hours ago

Ok, that's not really something we (OpenTelemetry) can help with, but some pointers:

if your application is browser-based, you follow the instructions I showed above for the browser. An important difference is that not all exporters, especially grpc are supported: https://opentelemetry.io/docs/languages/js/exporters/#usage-in-the-browser

if your application is nodejs-based and therefore running outside of the browser, follow the Node.JS instructions.

jscancella commented 2 hours ago

I did ask in the javascript specific discussions but no one answered, and have been trying to follow the examples that the otel team has written, but I still can't get the metrics to auto instrument.

If you can point me to what I need to change to get auto instrumentation to work with the above code I would be really grateful!

svrnm commented 1 hour ago

Sorry, I am not really the right person to ask that, you may have more luck in the #otel-js slack channel (register via https://slack.cncf.io) or on stackoverflow

jscancella commented 1 hour ago

Ok i'll try there. thank you!