Skip to content

fix(@opentelemetry/instrumentation-dataloader): fix instrumentation of ESM-imported dataloader #2813

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

TheDadi
Copy link

@TheDadi TheDadi commented May 5, 2025

Which problem is this PR solving?

  • The ESM imported top-level object is a Module Namespace Object per ECMA262 spec. The ".default" holds the equivalent of require('dataloader')

TypeError: Cannot read properties of undefined (reading 'load') at DataloaderInstrumentation._patchLoad

Contributes to #1942

@TheDadi TheDadi requested a review from a team as a code owner May 5, 2025 17:17
Copy link

linux-foundation-easycla bot commented May 5, 2025

CLA Signed


The committers listed above are authorized under a signed CLA.

Copy link

codecov bot commented May 7, 2025

Codecov Report

Attention: Patch coverage is 92.30769% with 1 line in your changes missing coverage. Please review.

Project coverage is 89.49%. Comparing base (a99ba69) to head (ffdf6c8).
Report is 2 commits behind head on main.

Files with missing lines Patch % Lines
.../instrumentation-dataloader/src/instrumentation.ts 92.30% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2813      +/-   ##
==========================================
- Coverage   89.51%   89.49%   -0.02%     
==========================================
  Files         180      180              
  Lines        8735     8741       +6     
  Branches     1778     1780       +2     
==========================================
+ Hits         7819     7823       +4     
- Misses        916      918       +2     
Files with missing lines Coverage Δ
.../instrumentation-dataloader/src/instrumentation.ts 98.14% <92.30%> (-0.88%) ⬇️

... and 1 file with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@david-luna
Copy link
Contributor

Hi @TheDadi

Thanks for your contribution to OpenTelemetry. I think it would be good to add a test case for the ESM usage.

#2807 fixed ESM support for pg and included such test. You can take it as a reference

@dyladan
Copy link
Member

dyladan commented Jun 25, 2025

Related: #1942

This needs tests and fix the conflicts and we can get this merged

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants