Skip to content

Conversation

@alexsohn1126
Copy link
Member

@alexsohn1126 alexsohn1126 commented Oct 20, 2025

Resolves #3762

Purpose

This PR will add a new integration for Sentry.Extensions.AI.

It will allow users to instrument their LLM usage, including any tool calls and LLM API calls. Microsoft.Extensions.AI.Abstractions NuGet package is used in this SDK to use their interfaces and types.

Usage

In order to use this SDK, the user will have to have a compatible SDK which can instantiate an IChatClient. In the samples, I have used Microsoft.Extensions.AI.OpenAI. Another popular LLM SDK is Anthropic.SDK.

There are a few AI-exclusive options the users can change.

  • IncludeAIRequestMessages - boolean
    • Defaults to true
    • If true, we include the request message in the spans we send to Sentry.
  • IncludeAIResponseContent - boolean
    • Defaults to true
    • If true, we include the response message in the spans we send to Sentry.
  • AgentName - string
    • Defaults to Agent
    • Name of the agent which this ChatClient represents.

Once the user has set up and sends AI spans to Sentry, they will be able to see it in Insights > AI (from the sidebar).

Screen.Recording.2025-10-31.at.5.39.14.PM.mov

There are useful information about LLM usage in the webpage. Such as how many tokens the user has sent/received, what tool calls were made, how long they tool, etc.

@codecov
Copy link

codecov bot commented Oct 20, 2025

Codecov Report

❌ Patch coverage is 82.37705% with 43 lines in your changes missing coverage. Please review.
✅ Project coverage is 73.82%. Comparing base (16e05ec) to head (3dce4d1).
⚠️ Report is 14 commits behind head on main.

Files with missing lines Patch % Lines
src/Sentry.Extensions.AI/SentryAISpanEnricher.cs 85.41% 13 Missing and 1 partial ⚠️
src/Sentry.Extensions.AI/SentryChatClient.cs 89.04% 4 Missing and 4 partials ⚠️
...try.Extensions.AI/Extensions/SentryAIExtensions.cs 22.22% 7 Missing ⚠️
...c/Sentry.Extensions.AI/SentryAIActivityListener.cs 80.00% 2 Missing and 3 partials ⚠️
...Sentry.Extensions.AI/SentryInstrumentedFunction.cs 80.76% 1 Missing and 4 partials ⚠️
src/Sentry.Extensions.AI/SentryAIUtil.cs 33.33% 3 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #4657      +/-   ##
==========================================
+ Coverage   73.66%   73.82%   +0.15%     
==========================================
  Files         476      485       +9     
  Lines       17442    17693     +251     
  Branches     3453     3499      +46     
==========================================
+ Hits        12849    13061     +212     
- Misses       3744     3773      +29     
- Partials      849      859      +10     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@alexsohn1126
Copy link
Member Author

@sentry review

@alexsohn1126
Copy link
Member Author

@sentry review

@alexsohn1126
Copy link
Member Author

@BugBot review

cursor[bot]

This comment was marked as outdated.

@alexsohn1126
Copy link
Member Author

@BugBot review

@alexsohn1126
Copy link
Member Author

@sentry review

cursor[bot]

This comment was marked as outdated.

@alexsohn1126
Copy link
Member Author

@BugBot review

@alexsohn1126
Copy link
Member Author

@sentry review

@alexsohn1126
Copy link
Member Author

@BugBot review

@alexsohn1126
Copy link
Member Author

@sentry review

@alexsohn1126
Copy link
Member Author

@BugBot review

alexsohn1126 added a commit to getsentry/sentry-docs that referenced this pull request Dec 3, 2025
…xtensions.AI` (#15431)

<!-- Use this checklist to make sure your PR is ready for merge. You may
delete any sections you don't need. -->

## DESCRIBE YOUR PR
We are making a new AI Agent Monitoring SDK for .NET.

- getsentry/sentry-dotnet#4657

## IS YOUR CHANGE URGENT?  

Help us prioritize incoming PRs by letting us know when the change needs
to go live.
- [ ] Urgent deadline (GA date, etc.): <!-- ENTER DATE HERE -->
- [ ] Other deadline: <!-- ENTER DATE HERE -->
- [ ] None: Not urgent, can wait up to 1 week+

## SLA

- Teamwork makes the dream work, so please add a reviewer to your PRs.
- Please give the docs team up to 1 week to review your PR unless you've
added an urgent due date to it.
Thanks in advance for your help!

## PRE-MERGE CHECKLIST

*Make sure you've checked the following before merging your changes:*

- [ ] Checked Vercel preview for correctness, including links
- [ ] PR was reviewed and approved by any necessary SMEs (subject matter
experts)
- [ ] PR was reviewed and approved by a member of the [Sentry docs
team](https://github.com/orgs/getsentry/teams/docs)

## LEGAL BOILERPLATE

<!-- Sentry employees and contractors can delete or ignore this section.
-->

Look, I get it. The entity doing business as "Sentry" was incorporated
in the State of Delaware in 2015 as Functional Software, Inc. and is
gonna need some rights from me in order to utilize my contributions in
this here PR. So here's the deal: I retain all rights, title and
interest in and to my contributions, and by keeping this boilerplate
intact I confirm that Sentry can use, modify, copy, and redistribute my
contributions, under Sentry's choice of terms.

## EXTRA RESOURCES

- [Sentry Docs contributor guide](https://docs.sentry.io/contributing/)

---------

Co-authored-by: James Crosswell <jamescrosswell@users.noreply.github.com>
This was referenced Dec 11, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Support for Microsoft.Extensions.AI

5 participants