Skip to content

feat(instrumentation-typeorm): add support for typeorm@1.x - #3619

Open
katoztmy wants to merge 1 commit into
open-telemetry:mainfrom
katoztmy:feat/typeorm-1x-support
Open

feat(instrumentation-typeorm): add support for typeorm@1.x#3619
katoztmy wants to merge 1 commit into
open-telemetry:mainfrom
katoztmy:feat/typeorm-1x-support

Conversation

@katoztmy

@katoztmy katoztmy commented Jul 11, 2026

Copy link
Copy Markdown

Which problem is this PR solving?

Fixes #3545

typeorm@1.0.0 removed EntityManager#findByIds, and the instrumentation tries to wrap it unconditionally, so patching crashes with "Attempt to wrap undefined property findByIds as function". Also supportedVersions is >=0.3.0 <1, so 1.x is not instrumented at all.

Short description of the changes

  • Extended the version range to >=0.3.0 <2. I kept the upper bound to avoid claiming support for major versions that are not verified yet, which is also why the existing code was capped at <1.
  • Skip wrapping EntityManager methods that don't exist in the loaded version. In 1.x only findByIds is affected.
  • I kept the connection getter as-is. In 1.x it is deprecated but still works (it just returns dataSource), and 0.3.x doesn't have dataSource on EntityManager, so connection is the only property that works on both.
  • typeorm 1.x dropped the sqlite driver in favor of better-sqlite3, so the test helper now picks whichever driver the installed typeorm supports. The tests themselves are unchanged.
  • .tav.yml runs 1.x in a separate job with node: ">=20" (typeorm 1.0 requires Node 20.19+) and better-sqlite3@^12.0.0, same range as typeorm's own peer dependency.

Tested with typeorm 0.3.x and 1.0.0, 13/13 passing on both. TAV run on my fork: https://github.com/katoztmy/opentelemetry-js-contrib/actions/runs/29142553352

I used AI assistance (Claude) for this change. I reviewed and tested everything myself.

This is my first contribution to this repo, so please let me know if I missed anything in the process.

@katoztmy
katoztmy requested a review from a team as a code owner July 11, 2026 06:48
@linux-foundation-easycla

linux-foundation-easycla Bot commented Jul 11, 2026

Copy link
Copy Markdown

CLA Signed
The committers listed above are authorized under a signed CLA.

  • ✅ login: katoztmy / name: katoztmy (9115c48)

@github-actions

Copy link
Copy Markdown
Contributor

Welcome, contributor! Thank you for your contribution to opentelemetry-js-contrib.

Important reminders:

  • Read our Contributing Guidelines.
  • Sign the CLA if you haven't already.
  • Follow the OpenTelemetry Generative AI policy: disclose any AI use in your contribution, and communicate (PR descriptions, review replies) in your own words rather than AI-generated text.
  • Give reviewers at least a few days before pinging them for feedback.
  • If you need help with general setup, development process, or contributor etiquette, ask in #opentelemetry-new-contributors.

typeorm@1.0.0 removed EntityManager#findByIds, which crashed the patch
phase when the instrumentation attempted to wrap it. Skip wrapping
methods that do not exist in the loaded version, and extend the
supported version range to '>=0.3.0 <2'.

typeorm@1.x also dropped the 'sqlite' (sqlite3) driver in favor of
'better-sqlite3' and requires Node.js 20.19+, so the tests pick the
sqlite driver supported by the installed typeorm version, and the TAV
config runs 1.x in a separate job with node '>=20' and better-sqlite3
as a peer dependency.

Closes open-telemetry#3545

Assisted-By: Claude Fable 5
@katoztmy
katoztmy force-pushed the feat/typeorm-1x-support branch from 9115c48 to e2435ba Compare July 11, 2026 07:00
@opentelemetry-pr-dashboard

opentelemetry-pr-dashboard Bot commented Jul 18, 2026

Copy link
Copy Markdown

Pull request dashboard status

Waiting on reviewers · refreshed 2026-08-10 13:49 UTC

Review the latest changes.

Status above doesn't look right?
  • Just replied or pushed? Anything around or after the refresh time above may not be picked up yet — give it a few minutes.
  • Anything look wrong? Report it with what you expected; it helps us improve the dashboard.

@katoztmy

Copy link
Copy Markdown
Author

Hi @mhennoch @seemk @t2t2 @weyert — just a gentle ping on this PR, it's been about two weeks since it was opened and CI is green (tested against typeorm 0.3.x and 1.0.0). This is my first contribution here, so happy to adjust anything that doesn't fit the repo's conventions. Thanks for taking a look when you get a chance!

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.

[instrumentation-typeorm] support typeorm 1.x

5 participants