Skip to content

Conversation

@pabloerhard
Copy link
Contributor

@pabloerhard pabloerhard commented Dec 10, 2025

What does this PR do?

This PR intends to add support prisma client generated through the output field. the output field creates the prisma client in a custom path, which dd-trace has no context of, to add support a new env DD_PRISMA_OUTPUT was added.

DD_PRISMA_OUTPUT can be either the path to client start from the root of the project.

example:

root-folder
└── src
└── generated

in this case DD_PRISMA_OUTPUT would have the following value 'src/generated', if the the schema location is in the default prisma root folder or defined inside the package.json then DD_PRISMA_OUTPUT can be defined to 'auto' this will extract the output from the schema automatically.

Once the path is either provided by the user or extracted automatically, an absolute path is generated. This absolute path is used to register the hook. When ritm resolves the actual request, it uses returns the absolute path plus the filename it resolves to. Because of this, additional logic was added to match the hook using prefix-based matching whenever a registered module points to a specific file, later on the onrequire callback takes care of verifying if the complete path is a match.

With this changes Prisma's instrumentation will cover versions below and above v7 (specifically support for prisma-generator and prisma-generator-js).

Note: An additional PR has to be open to add tests for the new recommended prisma-generator, this prisma-generator generates typescript which can't be imported into js code and has to be transpiled into js before using.

Motivation

Have proper support for Prisma Client instrumentation

Plugin Checklist

Additional Notes

@pabloerhard pabloerhard changed the title Pabloerhard/prisma output support (feature): Prisma Output Support Dec 10, 2025
@pabloerhard pabloerhard force-pushed the pabloerhard/prisma-output-support branch from 210a0a1 to 4965a67 Compare December 10, 2025 15:46
@github-actions
Copy link

github-actions bot commented Dec 10, 2025

Overall package size

Self size: 3.58 MB
Deduped: 4.47 MB
No deduping: 4.47 MB

Dependency sizes | name | version | self size | total size | |------|---------|-----------|------------| | import-in-the-middle | 1.15.0 | 127.66 kB | 856.24 kB | | dc-polyfill | 0.1.10 | 26.73 kB | 26.73 kB |

🤖 This report was automatically generated by heaviest-objects-in-the-universe

@codecov
Copy link

codecov bot commented Dec 10, 2025

Codecov Report

❌ Patch coverage is 51.08696% with 45 lines in your changes missing coverage. Please review.
✅ Project coverage is 84.72%. Comparing base (acc6bef) to head (985e014).

Files with missing lines Patch % Lines
...ntations/src/helpers/extract-prisma-client-path.js 29.16% 17 Missing ⚠️
...s/datadog-instrumentations/src/helpers/register.js 44.44% 15 Missing ⚠️
packages/dd-trace/src/ritm.js 62.06% 11 Missing ⚠️
...ages/datadog-instrumentations/src/helpers/hooks.js 83.33% 1 Missing ⚠️
packages/dd-trace/src/plugins/index.js 83.33% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #7072      +/-   ##
==========================================
- Coverage   84.82%   84.72%   -0.11%     
==========================================
  Files         515      519       +4     
  Lines       22022    22161     +139     
==========================================
+ Hits        18681    18775      +94     
- Misses       3341     3386      +45     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 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.

@pr-commenter
Copy link

pr-commenter bot commented Dec 10, 2025

Benchmarks

Benchmark execution time: 2025-12-12 14:40:44

Comparing candidate commit 985e014 in PR branch pabloerhard/prisma-output-support with baseline commit acc6bef in branch master.

Found 0 performance improvements and 0 performance regressions! Performance is the same for 291 metrics, 29 unstable metrics.

@pabloerhard pabloerhard marked this pull request as ready for review December 11, 2025 19:10
@pabloerhard pabloerhard requested review from a team as code owners December 11, 2025 19:10
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.

2 participants