Skip to content

docs(cloudflare,deno): Add instrumentPostgresJsSql#16634

Merged
andreiborza merged 2 commits intomasterfrom
ab/postgresjs
Mar 3, 2026
Merged

docs(cloudflare,deno): Add instrumentPostgresJsSql#16634
andreiborza merged 2 commits intomasterfrom
ab/postgresjs

Conversation

@andreiborza
Copy link
Member

DESCRIBE YOUR PR

This PR documents the newly exposed instrumentPostgresJsSql helpers to manually instrument postgres.js for deno and cloudflare, where we don't have OpenTelemetry and can't rely on automatic monkey-patching.

To be merged after the 10.41.0 release is out.

IS YOUR CHANGE URGENT?

Help us prioritize incoming PRs by letting us know when the change needs to go live.

  • Urgent deadline (GA date, etc.):
  • Other deadline:
  • None: Not urgent, can wait up to 1 week+

@vercel
Copy link

vercel bot commented Mar 2, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
sentry-docs Ready Ready Preview, Comment Mar 2, 2026 5:17pm
1 Skipped Deployment
Project Deployment Actions Updated (UTC)
develop-docs Ignored Ignored Preview Mar 2, 2026 5:17pm

Request Review

const sql = Sentry.instrumentPostgresJsSql(postgres(env.DATABASE_URL));

// All queries now create Sentry spans
const users = await sql`SELECT * FROM users WHERE id = ${userId}`;
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bug: The postgresjs documentation examples use an undeclared userId variable, which will cause a ReferenceError when the code is executed.
Severity: MEDIUM

Suggested Fix

Declare the userId variable before it is used in the SQL query. For example, add const userId = "user_123"; before the line where sql is called.

Prompt for AI Agent
Review the code at the location below. A potential bug has been identified by an AI
agent.
Verify if this is a real issue. If it is, propose a fix; if not, explain why it's not
valid.

Location: docs/platforms/javascript/common/configuration/integrations/postgresjs.mdx#L26

Potential issue: The code examples for Cloudflare and Deno in the `postgresjs.mdx`
documentation file use the template literal `${userId}` within SQL queries without
declaring the `userId` variable. If a developer copies and pastes this code, it will
throw a `ReferenceError: userId is not defined` at runtime, causing the application to
crash. Other documentation examples in the repository, such as in `logs/index.mdx`,
correctly declare variables before they are used.

Did we get this right? 👍 / 👎 to inform future reviews.

A hook called before each span is started. Use it to set additional attributes or modify the span.

```javascript
const sql = Sentry.instrumentPostgresJsSql(postgres(env.DATABASE_URL), {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bug: The generic requestHook documentation example uses Cloudflare-specific env.DATABASE_URL syntax, causing a ReferenceError on other platforms.
Severity: MEDIUM

Suggested Fix

Make the example platform-agnostic by using a generic placeholder like DATABASE_URL instead of env.DATABASE_URL. Alternatively, wrap the example in platform-specific tags to clarify it is for Cloudflare.

Prompt for AI Agent
Review the code at the location below. A potential bug has been identified by an AI
agent.
Verify if this is a real issue. If it is, propose a fix; if not, explain why it's not
valid.

Location: docs/platforms/javascript/common/configuration/integrations/postgresjs.mdx#L67

Potential issue: In the `postgresjs.mdx` documentation, the `requestHook` example under
the generic `## Options` section uses `env.DATABASE_URL`. This `env` object is specific
to the Cloudflare Workers environment and is not available on other platforms like Deno.
Developers on non-Cloudflare platforms who copy this example will encounter a
`ReferenceError` because `env` is not defined. This is inconsistent with other parts of
the document that correctly use platform-specific tags to isolate environment-dependent
code.

Did we get this right? 👍 / 👎 to inform future reviews.

Copy link
Member

@chargome chargome left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we leave an available since note in here too?

@chargome chargome changed the title feat(cloudflare,deno): Add instrumentPostgresJsSql docs(cloudflare,deno): Add instrumentPostgresJsSql Mar 2, 2026
Co-Authored-By: Claude <noreply@anthropic.com>
@andreiborza andreiborza merged commit 5dcd044 into master Mar 3, 2026
17 checks passed
@andreiborza andreiborza deleted the ab/postgresjs branch March 3, 2026 09:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants