Skip to content

Commit 92cdf28

Browse files
docs(dotnet): Document GenAI data collection for AI Agents
The snippets set RecordInputs and RecordOutputs to true. Once Sentry.Extensions.AI honours DataCollection.GenAI, an explicit flag overrides it for that chat client, so an app that copied the snippet would keep sending prompts and responses after turning GenAI off. Drop the flags from both snippets, describe how they combine with DataCollection, and show how to turn AI content off for every chat client with ConfigureDataCollection. Closes getsentry/sentry-dotnet#5954 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
1 parent 80202b4 commit 92cdf28

1 file changed

Lines changed: 30 additions & 12 deletions

File tree

‎docs/platforms/dotnet/common/tracing/instrumentation/ai-agents-module.mdx‎

Lines changed: 30 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,6 @@ var openAiClient = new OpenAI.Chat.ChatClient("gpt-4o-mini", apiKey)
4848
.AsIChatClient()
4949
.AddSentry(options =>
5050
{
51-
options.Experimental.RecordInputs = true;
52-
options.Experimental.RecordOutputs = true;
5351
options.Experimental.AgentName = "MyAgent";
5452
});
5553

@@ -84,15 +82,19 @@ var response = await chatClient.GetResponseAsync(
8482

8583
The `AddSentry()` method accepts an optional configuration delegate to customize the instrumentation:
8684

87-
<SdkOption name="Experimental.RecordInputs" type="bool" defaultValue="true">
85+
<SdkOption name="Experimental.RecordInputs" type="bool" defaultValue="true" defaultNote="unless GenAI.Inputs is false">
8886

89-
Whether to include request messages in spans. When enabled, the content of messages sent to the AI model will be recorded in the span data.
87+
Whether to include AI inputs in spans: request messages, tool definitions, and tool call arguments.
88+
89+
If you set it, it overrides `GenAI.Inputs` from [`ConfigureDataCollection`](#stop-sending-prompts-and-responses) for this chat client. If you don't, `GenAI.Inputs` decides, and that defaults to `true`.
9090

9191
</SdkOption>
9292

93-
<SdkOption name="Experimental.RecordOutputs" type="bool" defaultValue="true">
93+
<SdkOption name="Experimental.RecordOutputs" type="bool" defaultValue="true" defaultNote="unless GenAI.Outputs is false">
94+
95+
Whether to include AI outputs in spans: response text, response tool calls, and tool call results.
9496

95-
Whether to include response content in spans. When enabled, the content of responses from the AI model will be recorded in the span data.
97+
If you set it, it overrides `GenAI.Outputs` from [`ConfigureDataCollection`](#stop-sending-prompts-and-responses) for this chat client. If you don't, `GenAI.Outputs` decides, and that defaults to `true`.
9698

9799
</SdkOption>
98100

@@ -102,6 +104,27 @@ Name of the agent. This name will be used to identify the agent in the Sentry UI
102104

103105
</SdkOption>
104106

107+
## Stop Sending Prompts and Responses
108+
109+
To stop sending AI content from every chat client, turn off generative AI inputs and outputs when you initialize the SDK. Sentry still sends metadata, such as model names and token counts. For details, see <Link to="/product/agents/privacy/#sdk-data-collection">AI Agents Privacy</Link>.
110+
111+
```csharp
112+
SentrySdk.Init(options =>
113+
{
114+
options.Dsn = "___PUBLIC_DSN___";
115+
options.TracesSampleRate = 1.0;
116+
options.ConfigureDataCollection(dc =>
117+
{
118+
dc.GenAI.Inputs = false;
119+
dc.GenAI.Outputs = false;
120+
});
121+
});
122+
```
123+
124+
`ConfigureDataCollection` is experimental and may change in a future release.
125+
126+
To keep sending content from a specific chat client, set `RecordInputs` or `RecordOutputs` to `true` in its `AddSentry()` call.
127+
105128
<PlatformSection supported={["dotnet.aspnetcore"]}>
106129

107130
## ASP.NET Core Integration
@@ -121,11 +144,7 @@ builder.WebHost.UseSentry(options =>
121144
// Set up the AI client with Sentry instrumentation
122145
var openAiClient = new OpenAI.Chat.ChatClient("gpt-4o-mini", apiKey)
123146
.AsIChatClient()
124-
.AddSentry(options =>
125-
{
126-
options.Experimental.RecordInputs = true;
127-
options.Experimental.RecordOutputs = true;
128-
});
147+
.AddSentry();
129148

130149
var chatClient = new ChatClientBuilder(openAiClient)
131150
.UseFunctionInvocation()
@@ -153,4 +172,3 @@ app.Run();
153172
```
154173

155174
</PlatformSection>
156-

0 commit comments

Comments
 (0)