Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,16 @@ Requires SDK version `10.12.0` or higher for Deno.

</Alert>

<PlatformSection supported={['javascript.cloudflare']}>

<Alert>

On Cloudflare, AI SDK v7 support requires SDK version `10.64.0` or higher and the <PlatformLink to="/features/nodejs-compat">`@sentry/cloudflare/nodejs_compat`</PlatformLink> entrypoint.

</Alert>

</PlatformSection>

<Alert level="warning">

Don't use the AI SDK's `registerTelemetry` API (AI SDK v7 and above) together with this integration. Sentry's `vercelAIIntegration` already instruments the AI SDK, so registering telemetry separately will result in duplicate spans.
Expand Down Expand Up @@ -185,7 +195,9 @@ Pass `experimental_telemetry` with `isEnabled: true` to the `ToolLoopAgent` cons
```javascript
const agent = new ToolLoopAgent({
model: openai("gpt-4o"),
tools: { /* ... */ },
tools: {
/* ... */
},
experimental_telemetry: { isEnabled: true },
});

Expand Down Expand Up @@ -213,7 +225,9 @@ For `ToolLoopAgent`, set `functionId` in the constructor:
```javascript
const agent = new ToolLoopAgent({
model: openai("gpt-4o"),
tools: { /* ... */ },
tools: {
/* ... */
},
experimental_telemetry: {
isEnabled: true,
functionId: "weather-agent",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
---
title: Prisma
description: "Adds instrumentation for Prisma ORM queries on Cloudflare Workers running with Node.js compatibility."
---

<Alert>

On Cloudflare, the `prismaIntegration` is only available through the <PlatformLink to="/features/nodejs-compat">`@sentry/cloudflare/nodejs_compat`</PlatformLink> entrypoint, which requires SDK version `10.64.0` or higher.

</Alert>

_Import name: `Sentry.prismaIntegration`_

Sentry supports tracing [Prisma ORM](https://www.prisma.io/) queries with the Prisma integration. The integration creates a span for each query and reports relevant details to Sentry.

To enable it on Cloudflare, import Sentry from the `@sentry/cloudflare/nodejs_compat` entrypoint and add the `prismaIntegration` to your `Sentry.init` call:

```javascript {3,5}
import * as Sentry from "@sentry/cloudflare/nodejs_compat";

Sentry.init({
tracesSampleRate: 1.0,
integrations: [Sentry.prismaIntegration()],
});
```

This integration supports Prisma versions 5, 6, and 7. In Prisma v5, you also need to add the `tracing` preview feature to the `generator` block of your Prisma schema:

```txt {tabTitle: Prisma Schema} {filename: schema.prisma} {3}
generator client {
provider = "prisma-client-js"
previewFeatures = ["tracing"]
}
```

## Supported Versions

- `prisma`: `5.x`, `6.x`, `7.x`

## Learn More

For details on the span structure that Prisma's OpenTelemetry tracing produces (e.g., `prisma:client:operation`, `prisma:engine:db_query`), see the [Prisma trace output documentation](https://www.prisma.io/docs/orm/prisma-client/observability-and-logging/opentelemetry-tracing#trace-output).
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
---
title: Node.js Compatibility Entrypoint
description: "Learn how the nodejs_compat entrypoint unlocks additional Node.js SDK features on Cloudflare Workers, such as Prisma instrumentation."
---

Cloudflare Workers can run with Node.js APIs enabled through the [`nodejs_compat` compatibility flag](https://developers.cloudflare.com/workers/runtime-apis/nodejs/). To take advantage of this, the Cloudflare SDK ships a dedicated `@sentry/cloudflare/nodejs_compat` entrypoint that unlocks Node.js SDK features which aren't available in the default Workers runtime.

<Alert>

The `@sentry/cloudflare/nodejs_compat` entrypoint requires SDK version `10.64.0` or higher. It will become the default entrypoint in the next major version (v11).

</Alert>

## What It Unlocks

The `/nodejs_compat` entrypoint enables Node.js-only integrations and features on Cloudflare, including:

- The <PlatformLink to="/configuration/integrations/prisma">`prismaIntegration`</PlatformLink> for tracing Prisma ORM queries.
- Vercel AI SDK v7 support for the <PlatformLink to="/configuration/integrations/vercelai">`vercelAIIntegration`</PlatformLink>.
Comment thread
JPeer264 marked this conversation as resolved.

## Usage

The entrypoint is a drop-in replacement for `@sentry/cloudflare`, so switching over only requires changing your imports:

```javascript {tabTitle:After}
import * as Sentry from "@sentry/cloudflare/nodejs_compat";
```

```javascript {tabTitle:Before}
import * as Sentry from "@sentry/cloudflare";
```

To use the entrypoint, your Worker must set the `nodejs_compat` compatibility flag in your Wrangler configuration:


```jsonc {tabTitle:JSON} {filename:wrangler.jsonc}
{
"compatibility_flags": ["nodejs_compat"],
}
```

```toml {tabTitle:Toml} {filename:wrangler.toml}
compatibility_flags = ["nodejs_compat"]
```
6 changes: 6 additions & 0 deletions docs/platforms/javascript/guides/cloudflare/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,12 @@ Run the command for your preferred package manager to add the Sentry SDK to your
</SplitSection>
</SplitLayout>

<Alert>

Importing Sentry from the `@sentry/cloudflare/nodejs_compat` entrypoint unlocks additional Node.js SDK features on Cloudflare. It requires SDK version `10.64.0` or higher and will become the default in the next major version. [Learn more](./features/nodejs-compat).

</Alert>

## Configure

The main Sentry configuration should happen as early as possible in your app's lifecycle.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
### Integrations

| | **Auto Enabled** | **Errors** | **Tracing** | **Cron** | **Additional Context** |
|-----------------------------------------------------|:----------------:|:----------:|:-----------:|:--------:|:----------------------:|
| --------------------------------------------------- | :--------------: | :--------: | :---------: | :------: | :--------------------: |
| [`dedupeIntegration`](./dedupe) | ✓ | ✓ | | | |
| [`fetchIntegration`](./fetchIntegration) | ✓ | ✓ | ✓ | | |
| [`functionToStringIntegration`](./functiontostring) | ✓ | | | | |
Expand All @@ -13,4 +13,7 @@
| [`rewriteFramesIntegration`](./rewriteframes) | | ✓ | | | |
| [`supabaseIntegration`](./supabase) | | ✓ | ✓ | | |
| [`instrumentPostgresJsSql`](./postgresjs) | | | ✓ | | |
| [`prismaIntegration`](./prisma) | | | ✓ | | |
| [`honoIntegration`](./hono) | ✓ | ✓ | | | |

The [`prismaIntegration`](./prisma) is only available through the [`@sentry/cloudflare/nodejs_compat`](../../features/nodejs-compat) entrypoint.
Comment on lines +18 to +19

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Bug: The relative link ../../features/nodejs-compat in javascript.cloudflare.mdx will likely break because the file is included in a different context, causing the path to resolve incorrectly.
Severity: LOW

Suggested Fix

Replace the relative markdown link ../../features/nodejs-compat with a platform-aware component like <PlatformLink> or an absolute path. This ensures the link resolves correctly regardless of the context in which the content is included, following the established pattern in the documentation codebase.

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: platform-includes/configuration/integrations/javascript.cloudflare.mdx#L18-L19

Potential issue: The file
`platform-includes/configuration/integrations/javascript.cloudflare.mdx` is a
platform-specific content file that is included in other documentation pages. It
contains a relative markdown link `../../features/nodejs-compat`. When this content is
rendered on a different page, the relative path will be resolved from the new page's
location, not the original file's location. This will cause the link to point to an
incorrect or non-existent URL, resulting in a broken link for the user.

Loading