How to get JS OTEL auto-instrumentation packages compatible with Yarn 2?

57 views Asked by At

We are trying to use @opentelemetry/* packages with our project that also uses [email protected] and the pnp functionality (no node_modules directory). Our issue is described in the related https://github.com/open-telemetry/opentelemetry-js/issues/1412

The errors we are getting in our spans are similar to:

  ...
  status: {
    message: "ENOENT: no such file or directory, stat '/node_modules/graphql/index'",
    code: 2
  },
  events: [
    {
      name: 'exception',
      attributes: {
        'exception.type': 'ENOENT',
        'exception.message': "ENOENT: no such file or directory, stat '/node_modules/graphql/index'",
        'exception.stacktrace': "Error: ENOENT: no such file or directory, stat '/node_modules/graphql/index'\n" +
          '    at makeError$1 (/<proj>/.pnp.cjs:15833:24)\n' +
          '    at ENOENT (/<proj>/.pnp.cjs:15848:10)\n' +
          '    at ZipFS.statSync (/<proj>/.pnp.cjs:17272:13)\n' +
          '    at /<proj>/.pnp.cjs:18572:20\n' +
          '    at /<proj>/.pnp.cjs:19026:60\n' +
          '    at ZipOpenFS.getZipSync (/<proj>/.pnp.cjs:19155:14)\n' +
          '    at ZipOpenFS.makeCallSync (/<proj>/.pnp.cjs:19026:17)\n' +
          '    at ZipOpenFS.statSync (/<proj>/.pnp.cjs:18569:17)\n' +
          '    at VirtualFS.statSync (/<proj>/.pnp.cjs:18041:24)\n' +
          '    at PosixFS.statSync (/<proj>/.pnp.cjs:18041:24)'
      }
    }
  ],

We have localized these error spans to the auto-instrumented @opentelemetry/instrumentation-fs package (as when we disable that package we do not get there errors).

It has been recommended to use packageExtensions to handle the dependency issue here, but how do we orient the correct extension?

The latest we have tried is:

# .yarnrc.yml

packageExtensions:
  '@opentelemetry/sdk-node@^0.44.0':
    dependencies:
      '@opentelemetry/instrumentation-fs': '^0.8.3'
  '@opentelemetry/instrumentation-fs@^0.8.3':
    dependencies:
      'graphql': ^16.8.1

Our understanding was that the above would say that @opentelemetry/instrumentation-fs requires graphql (apparently due to the error) and that it would be able to find it.

Is there any alternative ways to handle this?

0

There are 0 answers