Skip to content

Commit dede3a4

Browse files
authored
docs(plugin-sentry): add pg query instrumentation guide (#12229)
<!-- Thank you for the PR! Please go through the checklist below and make sure you've completed all the steps. Please review the [CONTRIBUTING.md](https://github.com/payloadcms/payload/blob/main/CONTRIBUTING.md) document in this repository if you haven't already. The following items will ensure that your PR is handled as smoothly as possible: - PR Title must follow conventional commits format. For example, `feat: my new feature`, `fix(plugin-seo): my fix`. - Minimal description explained as if explained to someone not immediately familiar with the code. - Provide before/after screenshots or code diffs if applicable. - Link any related issues/discussions from GitHub or Discord. - Add review comments if necessary to explain to the reviewer the logic behind a change --> ### What? Hi Payload Team, this PR is a reply to @DanRibbens's request to document #11478. Let me know if you'd like to see any changes - thank you!
1 parent 7a0308f commit dede3a4

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

docs/plugins/sentry.mdx

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,28 @@ const config = buildConfig({
8484
export default config
8585
```
8686

87+
## Instrumenting Database Queries
88+
89+
If you want Sentry to capture Postgres query performance traces, you need to inject the Sentry-patched `pg` driver into the Postgres adapter. This ensures Sentry’s instrumentation hooks into your database calls.
90+
91+
```ts
92+
import * as Sentry from '@sentry/nextjs'
93+
import { buildConfig } from 'payload'
94+
import { sentryPlugin } from '@payloadcms/plugin-sentry'
95+
import { postgresAdapter } from '@payloadcms/db-postgres'
96+
import pg from 'pg'
97+
98+
export default buildConfig({
99+
db: postgresAdapter({
100+
pool: { connectionString: process.env.DATABASE_URL },
101+
pg, // Inject the patched pg driver for Sentry instrumentation
102+
}),
103+
plugins: [
104+
sentryPlugin({ Sentry }),
105+
],
106+
})
107+
```
108+
87109
## Options
88110

89111
- `Sentry` : Sentry | **required**

0 commit comments

Comments
 (0)