diff --git a/docs/platforms/javascript/common/configuration/integrations/mistral.mdx b/docs/platforms/javascript/common/configuration/integrations/mistral.mdx index 198678d4df294f..8e3a2dfacf12cc 100644 --- a/docs/platforms/javascript/common/configuration/integrations/mistral.mdx +++ b/docs/platforms/javascript/common/configuration/integrations/mistral.mdx @@ -29,6 +29,65 @@ Sentry.init({ }); ``` + + +On Deno, preload Sentry's import hook so the Mistral SDK can be instrumented: + +```bash +deno run --allow-net --allow-env --allow-read --allow-sys --allow-write --preload=npm:@sentry/deno/import app.ts +``` + + + + + + + +With the Node.js adapter, no build step is needed. The integration is enabled by default when tracing is enabled. + +On Bun, add `sentryBunPlugin()` to your build so the plugin can instrument the bundled Mistral SDK: + + + + + +On Bun, add `sentryBunPlugin()` to your build so the plugin can instrument the bundled Mistral SDK: + + + +```typescript {filename:build.ts} +import { sentryBunPlugin } from "@sentry/bun/plugin"; + +await Bun.build({ + entrypoints: ["./src/index.ts"], + outdir: "./dist", + target: "bun", + plugins: [sentryBunPlugin()], +}); +``` + +The Mistral SDK must be part of the bundle. The plugin only runs during a build, so for unbundled applications started with `bun run`, use [Manual Instrumentation](#manual-instrumentation). + + + + + +On Cloudflare, add `sentryCloudflareVitePlugin()` alongside Cloudflare's Vite plugin so the bundled Mistral SDK is instrumented: + +```typescript {filename:vite.config.mts} +import { cloudflare } from "@cloudflare/vite-plugin"; +import { sentryCloudflareVitePlugin } from "@sentry/cloudflare/vite"; +import { defineConfig } from "vite"; + +export default defineConfig({ + plugins: [cloudflare(), sentryCloudflareVitePlugin()], +}); +``` + +Build-time instrumentation is enabled by default, and the plugin registers the integration in both `vite dev` and `vite build`. Keep the `nodejs_compat` flag enabled in your Wrangler configuration, and see the Vite plugin page for the full setup. Without the plugin, or with `buildTimeInstrumentation: false`, use [Manual Instrumentation](#manual-instrumentation). + + + ## Supported Operations By default, tracing support is added to the following Mistral AI SDK calls: @@ -75,3 +134,44 @@ Sentry.init({ ], }); ``` + + + +## Manual Instrumentation + +_Import name: `Sentry.instrumentMistralAiClient`_ + +If your application does not use automatic instrumentation, wrap your Mistral client after setting up Sentry. Use the returned client for all Mistral calls. + + + +Import Sentry from the entry point for your runtime: `@sentry/hono/node`, `@sentry/hono/bun`, or `@sentry/hono/cloudflare`. + + + + + +```javascript +import * as Sentry from "___SDK_PACKAGE___"; +``` + + + +```javascript +import { Mistral } from "@mistralai/mistralai"; + +const mistral = new Mistral({ apiKey: "your-mistral-api-key" }); +const client = Sentry.instrumentMistralAiClient(mistral, { + recordInputs: false, + recordOutputs: false, +}); + +const response = await client.chat.complete({ + model: "mistral-small-latest", + messages: [{ role: "user", content: "Hello!" }], +}); +``` + +Use one instrumentation approach for each client. If automatic instrumentation is already active, you don't need to wrap the client. + + diff --git a/platform-includes/configuration/integrations/javascript.cloudflare.mdx b/platform-includes/configuration/integrations/javascript.cloudflare.mdx index 1a117d34ac0ce9..82ee0233153bd1 100644 --- a/platform-includes/configuration/integrations/javascript.cloudflare.mdx +++ b/platform-includes/configuration/integrations/javascript.cloudflare.mdx @@ -16,4 +16,6 @@ | [`prismaIntegration`](./prisma) | | | ✓ | | | | [`honoIntegration`](./hono) | ✓ | ✓ | | | | +[Mistral AI](./mistral) is automatically instrumented when built with the Sentry Cloudflare Vite plugin. Without the plugin, use `instrumentMistralAiClient`. + The [`prismaIntegration`](./prisma) is only available through the [`@sentry/cloudflare/nodejs_compat`](../../features/nodejs-compat) entrypoint. diff --git a/platform-includes/configuration/integrations/javascript.deno.mdx b/platform-includes/configuration/integrations/javascript.deno.mdx index 1538e77225a057..bc060c536aaf57 100644 --- a/platform-includes/configuration/integrations/javascript.deno.mdx +++ b/platform-includes/configuration/integrations/javascript.deno.mdx @@ -20,3 +20,4 @@ | [`instrumentPostgresJsSql`](./postgresjs) | | | ✓ | | | | [`trpcMiddleware`](./trpc) | | ✓ | ✓ | | ✓ | | [`zodErrorsIntegration`](./zodErrors) | | | | ✓ | +| [`mistralAIIntegration`](./mistral) | ✓ | | ✓ | | |