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

Can't update to @opentelemetry/sdk-node v0.34.0 using esbuild #3521

Closed
markandrus opened this issue Jan 5, 2023 · 1 comment · Fixed by #3739
Closed

Can't update to @opentelemetry/sdk-node v0.34.0 using esbuild #3521

markandrus opened this issue Jan 5, 2023 · 1 comment · Fixed by #3739
Assignees
Labels
bug Something isn't working priority:p1 Bugs which cause problems in end-user applications such as crashes, data inconsistencies, etc

Comments

@markandrus
Copy link

markandrus commented Jan 5, 2023

What happened?

I tried to update to @opentelemetry/sdk-node v0.34.0 today. I was previously using v0.32.0. I had to stop at v0.33.0, because v0.34.0 does not work with esbuild (whereas previous versions could be made to work).

Steps to Reproduce

✅ Succeeds with @opentelemetry/sdk-node v0.33.0
cd $(mktemp -d)

cat >package.json <<EOF
{
  "name": "jaeger-issue",
  "version": "1.0.0",
  "description": "",
  "main": "index.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "author": "",
  "license": "ISC",
  "dependencies": {
    "@opentelemetry/sdk-node": "0.33.0",
    "@opentelemetry/sdk-trace-base": "1.7.0",
    "esbuild": "0.16.14"
  }
}
EOF

npm install

cat >index.js <<EOF
const opentelemetry = require('@opentelemetry/sdk-node')
const { BatchSpanProcessor } = require('@opentelemetry/sdk-trace-base')

const traceExporter = new opentelemetry.tracing.ConsoleSpanExporter()
const spanProcessor = new BatchSpanProcessor(traceExporter)
const sdk = new opentelemetry.NodeSDK({
  // resource,
  traceExporter,
  instrumentations: [],
  spanProcessor
})

sdk.start()
  .then(() => { console.log('Tracing initialized') })
  .catch(error => { console.log('Error initializing tracing', error) })
EOF

npx esbuild --bundle index.js --outfile=test.js --platform=node

node test.js
❌ Fails with @opentelemetry/sdk-node v0.34.0
cd $(mktemp -d)

cat >package.json <<EOF
{
  "name": "jaeger-issue",
  "version": "1.0.0",
  "description": "",
  "main": "index.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "author": "",
  "license": "ISC",
  "dependencies": {
    "@opentelemetry/sdk-node": "0.34.0",
    "@opentelemetry/sdk-trace-base": "1.8.0",
    "esbuild": "0.16.14"
  }
}
EOF

npm install

cat >index.js <<EOF
const opentelemetry = require('@opentelemetry/sdk-node')
const { BatchSpanProcessor } = require('@opentelemetry/sdk-trace-base')

const traceExporter = new opentelemetry.tracing.ConsoleSpanExporter()
const spanProcessor = new BatchSpanProcessor(traceExporter)
const sdk = new opentelemetry.NodeSDK({
  // resource,
  traceExporter,
  instrumentations: [],
  spanProcessor
})

sdk.start()
  .then(() => { console.log('Tracing initialized') })
  .catch(error => { console.log('Error initializing tracing', error) })
EOF

npx esbuild --bundle index.js --outfile=test.js --platform=node

node test.js

Expected Behavior

Running node test.js succeeds and prints "Tracing initialized".

Actual Behavior

Running node test.js throws an error, due to .thrift files it cannot read:

Show error
$ node test.js
node:internal/fs/utils:344
    throw err;
    ^

Error: ENOENT: no such file or directory, open '/private/var/folders/zg/95xpb4z16ys_8gzd9yg60p100000gn/T/tmp.qcbn09Zc/jaeger-idl/thrift/jaeger.thrift'
    at Object.openSync (node:fs:585:3)
    at Object.readFileSync (node:fs:453:35)
    at Function.loadJaegerThriftDefinition (/private/var/folders/zg/95xpb4z16ys_8gzd9yg60p100000gn/T/tmp.qcbn09Zc/test.js:56366:31)
    at node_modules/jaeger-client/dist/src/thrift.js (/private/var/folders/zg/95xpb4z16ys_8gzd9yg60p100000gn/T/tmp.qcbn09Zc/test.js:56499:27)
    at __require (/private/var/folders/zg/95xpb4z16ys_8gzd9yg60p100000gn/T/tmp.qcbn09Zc/test.js:3:51)
    at node_modules/jaeger-client/dist/src/reporters/udp_sender.js (/private/var/folders/zg/95xpb4z16ys_8gzd9yg60p100000gn/T/tmp.qcbn09Zc/test.js:56544:19)
    at __require (/private/var/folders/zg/95xpb4z16ys_8gzd9yg60p100000gn/T/tmp.qcbn09Zc/test.js:3:51)
    at node_modules/@opentelemetry/exporter-jaeger/build/src/types.js (/private/var/folders/zg/95xpb4z16ys_8gzd9yg60p100000gn/T/tmp.qcbn09Zc/test.js:56873:26)
    at __require (/private/var/folders/zg/95xpb4z16ys_8gzd9yg60p100000gn/T/tmp.qcbn09Zc/test.js:3:51)
    at node_modules/@opentelemetry/exporter-jaeger/build/src/transform.js (/private/var/folders/zg/95xpb4z16ys_8gzd9yg60p100000gn/T/tmp.qcbn09Zc/test.js:56893:19) {
  errno: -2,
  syscall: 'open',
  code: 'ENOENT',
  path: '/private/var/folders/zg/95xpb4z16ys_8gzd9yg60p100000gn/T/tmp.qcbn09Zc/jaeger-idl/thrift/jaeger.thrift'
}

Additional Details

This is a minimal reproduction. In my actual application, I have a much weirder error that I cannot explain:

Show error
$ node redacted.js 
redacted.js:49229
            target[key] = source[key];
                        ^

TypeError: Cannot assign to read only property 'name' of function 'function createError(opts) {
        var result = new Error();
        Object.defineProperty(result, "type", {
...<omitted>... }'
    at extend (redacted.js:49229:25)
    at TypedError (redacted.js:49260:7)
    at ../../node_modules/thriftrw/errors.js (redacted.js:49301:38)
    at __require (redacted.js:12:51)
    at ../../node_modules/thriftrw/tmap.js (redacted.js:49401:18)
    at __require (redacted.js:12:51)
    at ../../node_modules/thriftrw/index.js (redacted.js:59590:16)
    at __require (redacted.js:12:51)
    at ../../node_modules/jaeger-client/dist/src/reporters/udp_sender.js (redacted.js:61127:21)
    at __require (redacted.js:12:51)

In production, I actually use the OTLPTraceExporter with the hack described here #2786 (comment). Maybe I should actually update to the HTTP exporter, per #2786 (comment). But I think I'd still need some way to avoid this .thrift file issue.

OpenTelemetry Setup Code

See above.

package.json

See above.

Relevant log output

See above.

@markandrus markandrus added bug Something isn't working triage labels Jan 5, 2023
@dyladan dyladan self-assigned this Jan 11, 2023
@dyladan dyladan added priority:p1 Bugs which cause problems in end-user applications such as crashes, data inconsistencies, etc and removed triage labels Mar 1, 2023
Vadman97 added a commit to highlight/highlight that referenced this issue Mar 17, 2023
## Summary

As mentioned in discord, our nodejs SDK is broken due to a dependence on
an old opentelemetry SDK version.
See open-telemetry/opentelemetry-js#3521

## How did you test this change?

Spinning up e2e express app. Cloudflare worker e2e healthy.
<img width="1121" alt="image"
src="https://user-images.githubusercontent.com/1351531/226015597-dd302aab-640c-45e7-a46c-bc2d1fb2619e.png">


## Are there any deployment considerations?

New versions released.
@markandrus
Copy link
Author

Thank you! My team was able to update to the latest OpenTelemetry 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working priority:p1 Bugs which cause problems in end-user applications such as crashes, data inconsistencies, etc
Projects
None yet
2 participants