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

v8 Node OpenTelemetry Instrumentation Blockers #12242

Closed
10 of 11 tasks
AbhiPrasad opened this issue May 27, 2024 · 5 comments · Fixed by #12388
Closed
10 of 11 tasks

v8 Node OpenTelemetry Instrumentation Blockers #12242

AbhiPrasad opened this issue May 27, 2024 · 5 comments · Fixed by #12388
Assignees
Labels

Comments

@AbhiPrasad
Copy link
Member

AbhiPrasad commented May 27, 2024

With the release of v8 of the Sentry SDK, the Node SDK now relies on OpenTelemetry. OpenTelemetry instrumentation does have some problems though (particularly with ESM because of import-in-the-middle), so this issue aims at documented these gaps.

import-in-the-middle

These are import-in-the-middle bugs, which are encountered by Sentry users who want to use Sentry in their ESM app.

1. import-in-the-middle does not work with multiple loaders.

Reported issue: #12011
Node.js issue: nodejs/node#52987

Fix: nodejs/import-in-the-middle#76

2. relative resolution fails for some modules

import-in-the-middle expects modules to be relative to the current file, but this doesn't always apply (re-exporting for example). Instead we should just use node's resolve

Reported issue: #12059
IITM issues: nodejs/import-in-the-middle#59, nodejs/import-in-the-middle#62, nodejs/import-in-the-middle#63

Fix: nodejs/import-in-the-middle#78

3. import-in-the-middle breaks with duplicate wildcard exports

Reported issue: #12154
IITM issue: nodejs/import-in-the-middle#60

Fix: nodejs/import-in-the-middle#79

4. Does not handle import * of current file

Reported issue: #12237
IITM issue: nodejs/import-in-the-middle#82

Fix: nodejs/import-in-the-middle#83

5. Does not handle CallExpression in ExportDefaultDeclaration node

IITM issue: nodejs/import-in-the-middle#77

Fix: nodejs/import-in-the-middle#85

6. tsx and --import seems to not play nicely

Reported issue: #12357

Instrumentation and Span Data Quality

This is being tracked by #12109

Performance Degradation with v8 PR.

Tasks

  1. Feature: Performance Package-Meta: OpenTelemetry Package: node
    timfish

PostgresIntegration problems

We've gotten two different reports (#11897, https://discord.com/channels/621778831602221064/1242436171737333810) that using the postgres integration with Sentry is causing memory issues.

@AbhiPrasad AbhiPrasad added this to the v8 Instrumentation Bugs milestone May 27, 2024
@timfish
Copy link
Collaborator

timfish commented May 27, 2024

Here is a patch for import-in-the-middle that can be used with patch-package which includes all the pending PR's.
import-in-the-middle+1.7.4.patch

If you encounter issues with this patch applied, please open a new issue!

@timfish
Copy link
Collaborator

timfish commented Jun 1, 2024

import-in-the-middle@1.8.0 has been released and I opened an otel PR to update it!

@jd-carroll
Copy link

FYI - This is fixed, but for the dependencies in @prisma

▲ [WARNING] Constructing "ImportInTheMiddle" will crash at run-time because it's an import namespace object, not a constructor [call-import-namespace]

    ../../node_modules/@prisma/instrumentation/node_modules/@opentelemetry/instrumentation/build/esm/platform/node/instrumentation.js:286:30:
      286 │ ...     var esmHook = new ImportInTheMiddle([module_2.name], { in...
          ╵                           ~~~~~~~~~~~~~~~~~

  Consider changing "ImportInTheMiddle" to a default import instead:

    ../../node_modules/@prisma/instrumentation/node_modules/@opentelemetry/instrumentation/build/esm/platform/node/instrumentation.js:48:7:
      48 │ import * as ImportInTheMiddle from 'import-in-the-middle';
         │        ~~~~~~~~~~~~~~~~~~~~~~
         ╵        ImportInTheMiddle

                            ~~~~~~~

Not sure where / how / when this would be encountered, if at all, but just thought I would share.

Thank you for all the effort in getting the ESM stuff resolved! ❤️

@jd-carroll
Copy link

Ohh, I should note:

Adding a resolution takes care of this:

# package.json
  ...
  "resolutions": {
    "@opentelemetry/instrumentation": "0.52.0"
  },
}

I should also note that we do not use any of the @prisma integrations.

@mydea
Copy link
Member

mydea commented Jun 10, 2024

Yeah, I guess this is because @prisma/instrumentation has not yet bumped to the latest version of @opentelemetry/instrumentation - I opened a PR for this here: prisma/prisma#24480

A resolution is the best short-term fix for this IMHO! 👍

billyvg pushed a commit that referenced this issue Jun 10, 2024
resolves #12242
(although there are still some follow ups)

https://github.com/open-telemetry/opentelemetry-js/releases/tag/v1.25.0

I think this lockfile looks correct, but lmk if this feels off.

resolves #12011
resolves #12059
resolves #12154
resolves #12237
resolves nodejs/import-in-the-middle#77 cc
@mohd-akram
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants