docs(cloudflare,deno): Add instrumentPostgresJsSql#16634
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
1 Skipped Deployment
|
| const sql = Sentry.instrumentPostgresJsSql(postgres(env.DATABASE_URL)); | ||
|
|
||
| // All queries now create Sentry spans | ||
| const users = await sql`SELECT * FROM users WHERE id = ${userId}`; |
There was a problem hiding this comment.
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), { |
There was a problem hiding this comment.
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.
chargome
left a comment
There was a problem hiding this comment.
Can we leave an available since note in here too?
Co-Authored-By: Claude <noreply@anthropic.com>
DESCRIBE YOUR PR
This PR documents the newly exposed
instrumentPostgresJsSqlhelpers 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.