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
4 changes: 4 additions & 0 deletions skills/sentry-elixir-sdk/SKILL.md
Original file line number Diff line number Diff line change
Expand Up @@ -289,6 +289,10 @@ For each feature: `Read ${SKILL_ROOT}/references/<feature>.md`, follow steps exa
| `:enable_logs` | `boolean` | `false` | Enable Sentry Logs Protocol (v12.0.0+) |
| `:test_mode` | `boolean` | `false` | Capture events in-memory for testing |

### Default PII Guidance

Most Sentry SDKs expose a send-default-PII option. As of sentry v12, the Elixir SDK does not expose a `send_default_pii` config option in its documented option list or current config schema, so do **not** add a non-existent option. For richer user context, use `Sentry.PlugContext` and explicitly set allowed fields with `Sentry.Context.set_user_context/1`, then scrub with `:before_send` if needed. If a future Elixir SDK release adds `send_default_pii`, recommend setting it.

### Environment Variables

| Variable | Maps to | Purpose |
Expand Down
41 changes: 15 additions & 26 deletions skills/sentry-nestjs-sdk/references/ai-monitoring.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ All integrations listed below are **auto-enabled** when the corresponding AI lib

### Auto-Enabled Setup

OpenAI is auto-instrumented — no changes to `instrument.ts` needed. To customize:
OpenAI is auto-instrumented — no changes to `instrument.ts` needed:

```typescript
// instrument.ts
Expand All @@ -51,10 +51,7 @@ Sentry.init({
streamGenAiSpans: true,
sendDefaultPii: true, // enables recordInputs/recordOutputs by default
integrations: [
Sentry.openAIIntegration({
recordInputs: true, // capture prompts sent to OpenAI
recordOutputs: true, // capture generated text/completions
}),
Sentry.openAIIntegration(),
],
});
```
Expand All @@ -69,11 +66,9 @@ import * as Sentry from "@sentry/nestjs";

const openai = new OpenAI({ apiKey: process.env.OPENAI_API_KEY });

// Wrap once at module level — reuse this client everywhere
const client = Sentry.instrumentOpenAiClient(openai, {
recordInputs: true,
recordOutputs: true,
});
// Wrap once at module level — reuse this client everywhere.
// Input/output recording follows sendDefaultPii unless explicitly overridden.
const client = Sentry.instrumentOpenAiClient(openai);
```

### Streaming — Important
Expand Down Expand Up @@ -122,11 +117,9 @@ Sentry.init({
dsn: process.env.SENTRY_DSN,
tracesSampleRate: 1.0,
streamGenAiSpans: true,
sendDefaultPii: true,
integrations: [
Sentry.vercelAIIntegration({
recordInputs: true,
recordOutputs: true,
}),
Sentry.vercelAIIntegration(),
],
});
```
Expand Down Expand Up @@ -193,11 +186,9 @@ Sentry.init({
dsn: process.env.SENTRY_DSN,
tracesSampleRate: 1.0,
streamGenAiSpans: true,
sendDefaultPii: true,
integrations: [
Sentry.anthropicAIIntegration({
recordInputs: true,
recordOutputs: true,
}),
Sentry.anthropicAIIntegration(),
],
});
```
Expand All @@ -210,10 +201,8 @@ import * as Sentry from "@sentry/nestjs";

const anthropic = new Anthropic({ apiKey: process.env.ANTHROPIC_API_KEY });

const client = Sentry.instrumentAnthropicAiClient(anthropic, {
recordInputs: true,
recordOutputs: true,
});
// Input/output recording follows sendDefaultPii unless explicitly overridden.
const client = Sentry.instrumentAnthropicAiClient(anthropic);

const response = await client.messages.create({
model: "claude-sonnet-4-20250514",
Expand Down Expand Up @@ -284,9 +273,9 @@ Sentry.init({
sendDefaultPii: true,
enableLogs: true,
integrations: [
Sentry.openAIIntegration({ recordInputs: true, recordOutputs: true }),
Sentry.vercelAIIntegration({ recordInputs: true, recordOutputs: true }),
Sentry.anthropicAIIntegration({ recordInputs: true, recordOutputs: true }),
Sentry.openAIIntegration(),
Sentry.vercelAIIntegration(),
Sentry.anthropicAIIntegration(),
],
});
```
Expand Down Expand Up @@ -358,7 +347,7 @@ If your `tracesSampleRate` is below 1.0, you may be losing entire agent runs. Se
|-------|----------|
| No AI spans appearing | Verify `tracesSampleRate` > 0; AI monitoring requires tracing |
| Token counts missing in streams | Add `stream_options: { include_usage: true }` to all OpenAI streaming calls |
| `recordInputs`/`recordOutputs` not capturing | Set `sendDefaultPii: true` or explicitly pass `recordInputs: true` to the integration |
| `recordInputs`/`recordOutputs` not capturing | Set `sendDefaultPii: true`, or explicitly pass `recordInputs: true` / `recordOutputs: true` to the integration |
| Anthropic spans missing | Check SDK version; add `anthropicAIIntegration()` explicitly |
| Cost estimates not showing | Model name must match models.dev/OpenRouter pricing data; custom models may show no estimate |
| Vercel AI spans not tracked | Pass `experimental_telemetry: { isEnabled: true }` to every AI SDK call |
Expand Down
47 changes: 21 additions & 26 deletions skills/sentry-nextjs-sdk/references/ai-monitoring.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,18 +53,18 @@ Sentry.init({
// Tracing MUST be enabled for AI monitoring
tracesSampleRate: 1.0,
streamGenAiSpans: true,
sendDefaultPii: true,

integrations: [
Sentry.openAIIntegration({
recordInputs: true, // capture prompts sent to OpenAI
recordOutputs: true, // capture completions from OpenAI
}),
Sentry.openAIIntegration(), // recordInputs/recordOutputs default to true with sendDefaultPii
],
});
```

### Client-Side / Manual Wrapping

Prompt/output capture assumes the matching client-side `Sentry.init()` also sets `sendDefaultPii: true`.

```typescript
import OpenAI from "openai";
import * as Sentry from "@sentry/nextjs";
Expand All @@ -73,11 +73,9 @@ const openai = new OpenAI({
apiKey: process.env.OPENAI_API_KEY, // ⚠️ Never expose this in the browser!
});

// Wrap once at module level — reuse this client everywhere
const client = Sentry.instrumentOpenAiClient(openai, {
recordInputs: true,
recordOutputs: true,
});
// Wrap once at module level — reuse this client everywhere.
// Input/output recording follows sendDefaultPii unless explicitly overridden.
const client = Sentry.instrumentOpenAiClient(openai);

const response = await client.chat.completions.create({
model: "gpt-4o",
Expand Down Expand Up @@ -123,11 +121,10 @@ Sentry.init({
dsn: process.env.SENTRY_DSN,
tracesSampleRate: 1.0,
streamGenAiSpans: true,
sendDefaultPii: true,
integrations: [
Sentry.vercelAIIntegration({
force: true, // ← Required for Vercel production deployments (see note below)
recordInputs: true,
recordOutputs: true,
}),
],
});
Expand All @@ -141,6 +138,7 @@ Sentry.init({
dsn: process.env.SENTRY_DSN,
tracesSampleRate: 1.0,
streamGenAiSpans: true,
sendDefaultPii: true,
integrations: [
Sentry.vercelAIIntegration(),
],
Expand Down Expand Up @@ -216,11 +214,9 @@ Sentry.init({
dsn: process.env.SENTRY_DSN,
tracesSampleRate: 1.0,
streamGenAiSpans: true,
sendDefaultPii: true,
integrations: [
Sentry.anthropicAIIntegration({
recordInputs: true,
recordOutputs: true,
}),
Sentry.anthropicAIIntegration(),
],
});
```
Expand All @@ -235,10 +231,8 @@ const anthropic = new Anthropic({
apiKey: process.env.ANTHROPIC_API_KEY, // ⚠️ Never expose in the browser!
});

const client = Sentry.instrumentAnthropicAiClient(anthropic, {
recordInputs: true,
recordOutputs: true,
});
// Input/output recording follows sendDefaultPii unless explicitly overridden.
const client = Sentry.instrumentAnthropicAiClient(anthropic);

const response = await client.messages.create({
model: "claude-3-5-sonnet-20241022",
Expand Down Expand Up @@ -294,13 +288,13 @@ Sentry.init({
});
```

Or enable explicitly without `sendDefaultPii`:
Use explicit integration options only when you need per-integration overrides instead of the recommended SDK-level default:

```typescript
integrations: [
Sentry.openAIIntegration({
recordInputs: true, // explicitly opt in
recordOutputs: true,
recordInputs: false, // opt out for this integration despite sendDefaultPii: true
recordOutputs: false,
}),
],
```
Expand All @@ -319,10 +313,11 @@ Sentry.init({
dsn: process.env.SENTRY_DSN,
tracesSampleRate: 1.0,
streamGenAiSpans: true,
sendDefaultPii: true,
integrations: [
Sentry.openAIIntegration({ recordInputs: true, recordOutputs: true }),
Sentry.vercelAIIntegration({ force: true, recordInputs: true, recordOutputs: true }),
Sentry.anthropicAIIntegration({ recordInputs: true, recordOutputs: true }),
Sentry.openAIIntegration(),
Sentry.vercelAIIntegration({ force: true }),
Sentry.anthropicAIIntegration(),
],
});
```
Expand Down Expand Up @@ -412,7 +407,7 @@ If your `tracesSampleRate` is below 1.0, you may be losing entire agent runs. Se
| No AI spans appearing | Verify `tracesSampleRate` > 0; AI monitoring requires tracing |
| Token counts missing in streams | Add `stream_options: { include_usage: true }` to all OpenAI streaming calls |
| Vercel AI spans show raw names (`ai.toolCall`) | Add `vercelAIIntegration({ force: true })` in server config |
| `recordInputs`/`recordOutputs` not capturing | Set `sendDefaultPii: true` or explicitly pass `recordInputs: true` to the integration |
| `recordInputs`/`recordOutputs` not capturing | Set `sendDefaultPii: true`, or explicitly pass `recordInputs: true` / `recordOutputs: true` to the integration |
| Anthropic spans missing | Check SDK version supports Anthropic integration; add `anthropicAIIntegration()` explicitly |
| Cost estimates not showing | Model name must match models.dev/OpenRouter pricing data; custom/fine-tuned models may show no estimate |
| Edge runtime AI spans missing | Add `vercelAIIntegration()` to `sentry.edge.config.ts` explicitly (not auto-enabled for Edge) |
Expand Down
18 changes: 13 additions & 5 deletions skills/sentry-node-sdk/references/ai-monitoring.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,12 @@
Tracing must be enabled - AI spans require an active trace:

```typescript
Sentry.init({ dsn: "...", tracesSampleRate: 1.0, streamGenAiSpans: true });
Sentry.init({
dsn: "...",
tracesSampleRate: 1.0,
streamGenAiSpans: true,
sendDefaultPii: true,
});
```

## Integration Matrix
Expand All @@ -31,6 +36,8 @@ Sentry.init({ dsn: "...", tracesSampleRate: 1.0, streamGenAiSpans: true });
| `true` | `true` (default) | Yes |
| `true` | `false` | No |

Set `sendDefaultPii: true` in `Sentry.init()` to let supported integrations default `recordInputs`/`recordOutputs` to `true`. Use integration-level options to opt out or override specific integrations.

## Configuration Examples

### Auto-enabled integrations
Expand All @@ -54,9 +61,10 @@ Sentry.init({
dsn: process.env.SENTRY_DSN,
tracesSampleRate: 1.0,
streamGenAiSpans: true,
sendDefaultPii: true,
integrations: [
Sentry.openAIIntegration({ recordInputs: true, recordOutputs: true }),
Sentry.vercelAIIntegration({ recordInputs: true, recordOutputs: true }),
Sentry.openAIIntegration(),
Sentry.vercelAIIntegration(),
],
});
```
Expand Down Expand Up @@ -144,7 +152,7 @@ await Sentry.startSpan({
| `gen_ai.operation.name` | string | No | Human-readable operation label |
| `gen_ai.agent.name` | string | No | Agent name (for agent spans) |

### Content attributes (PII-gated - only when `sendDefaultPii: true` + `recordInputs/recordOutputs: true`)
### Content attributes (PII-gated only when `sendDefaultPii: true` + `recordInputs/recordOutputs: true`)

| Attribute | Type | Description |
|-----------|------|-------------|
Expand Down Expand Up @@ -210,6 +218,6 @@ If `tracesSampleRate` < 1.0, see the [AI sampling guide](../../sentry-setup-ai-m
| Token counts missing in streams | Add `stream_options: { include_usage: true }` (OpenAI) |
| Vercel AI spans not tracked | Add `experimental_telemetry: { isEnabled: true }` per call |
| Browser OpenAI not traced | Use `Sentry.instrumentOpenAiClient()` - auto-instrumentation is server-only |
| Prompts not captured | Set `sendDefaultPii: true` or explicit `recordInputs: true` |
| Prompts not captured | Set `sendDefaultPii: true`, or explicitly pass `recordInputs: true` / `recordOutputs: true` to the integration |
| AI Agents Dashboard empty | Ensure traces are being sent; check DSN and `tracesSampleRate` |
| Wrong cost calculations | Cached/reasoning tokens are subsets of totals, not additions |
9 changes: 7 additions & 2 deletions skills/sentry-python-sdk/references/ai-monitoring.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,12 @@
Tracing must be enabled — AI spans require an active transaction:

```python
sentry_sdk.init(dsn="...", traces_sample_rate=1.0, stream_gen_ai_spans=True)
sentry_sdk.init(
dsn="...",
traces_sample_rate=1.0,
stream_gen_ai_spans=True,
send_default_pii=True,
)
```

## Integration Matrix
Expand Down Expand Up @@ -37,7 +42,7 @@ Every integration follows the same two-layer control:
| `True` | `True` (default) | ✅ Yes |
| `True` | `False` | ❌ No |

Set `send_default_pii=True` to capture prompts. Use `include_prompts=False` per-integration to override.
Set `send_default_pii=True` in `sentry_sdk.init()` and leave `include_prompts` at its default `True`. Use `include_prompts=False` per integration only to opt out.

## Configuration Examples

Expand Down
Loading
Loading