Sentry logo

Sentry

Community
znlgis
sentry

Use when adding error tracking, performance monitoring or release health to .NET apps — builder.WebHost.UseSentry, SetBeforeSend, SentrySdk.CaptureException, TracesSampleRate, StartTransaction/StartChild spans, Source Context, symbol upload. Also for events not arriving because Dsn is empty (the SDK stays silent), tracing producing no transactions, PII leaking into events, and StartChildSpan no longer existing in 6.x. Sentry .NET SDK.

Overview

Publisherznlgis
Repositoryopengis-skills
Skill namesentry
Stars
76
Forks
12
Bundled files
Instructions only
LicenseMIT
Links
  • Markdown instructions

    A SKILL.md file the model loads on demand, so it only costs tokens when a request actually matches.

  • Works with any LLM

    AI skills are plain Markdown, not provider-specific code, so this works with GPT, Claude, Gemini, Grok, or a local model.

  • Self-contained

    Everything the model needs lives in the instructions — no extra files to sync.

  • Open source

    Published by znlgis on GitHub. Read the source before you install it.

Installation

Install the Sentry AI skill in TypingMind to use it with any LLM, or drop it into another agent that reads SKILL.md.

1

Install in TypingMind

TypingMind installs a skill straight from its GitHub folder — it reads SKILL.md, bundles the resource files, and stores the result locally.

  1. Open the app and go to Plugins → Skills.
  2. Choose "Install from GitHub".
  3. Paste the skill folder URL below and confirm.
    https://github.com/znlgis/opengis-skills/tree/main/csharp/sentry
  4. Enable the skill in any chat where you want it available.
Plugins → Skills → Add skill → From GitHub URL, then paste the folder URL and press Continue.
2

Install in another agent

Any agent that reads the Agent Skills format can use this skill — copy the folder into that agent's skills directory.

Claude Code — .claude/skills
git clone --depth 1 https://github.com/znlgis/opengis-skills.git /tmp/opengis-skills
mkdir -p .claude/skills
cp -r /tmp/opengis-skills/csharp/sentry .claude/skills/sentry
Restart Claude Code after copying so it picks up the new skill.

Use it in TypingMind

Enable Sentry in any TypingMind chat and the model takes it from there. Its name and description sit in the system prompt, and the moment a request matches, the model loads the full instructions itself — you never invoke it by hand, and it costs no tokens until it is actually used.

The model loads Sentry on its own as soon as a request matches it.

Works with any AI model

AI skills are plain Markdown instructions rather than provider-specific code, so Sentry is not tied to the model it was written for. Install it once in TypingMind and use it with GPT-5, Claude, Gemini, Grok, DeepSeek, Mistral, Llama, or a local model you run yourself — all on your own API keys.

  • Loaded only when it is needed

    The system prompt carries just the name and description. The instructions are fetched on the first matching request, so an idle skill costs nothing.

  • Switch models mid-chat

    Because the skill is instructions rather than code, changing model does not break it — the next model reads the same SKILL.md.

Skill instructions

This is the SKILL.md content the model loads. Read it before installing — a skill is instructions your model will follow.

项目地址: https://github.com/getsentry/sentry-dotnet

官方文档: https://docs.sentry.io/platforms/dotnet/

NuGet: https://www.nuget.org/packages/Sentry

最新版本: Sentry / Sentry.AspNetCore 6.12.1(截至 2026-10,NuGet 实测)

许可证: MIT

概述

Sentry 是一个开源的 错误追踪与性能监控平台,.NET SDK 支持将异常、崩溃、性能指标统一上报到 Sentry 服务端(SaaS 或自托管)。

核心特性

特性说明
自动异常捕获集成 ASP.NET Core / MAUI / WPF / Blazor / Console
性能监控Transaction + Span 模型,自动采集 HTTP/DB/EF Core 耗时
源码映射Release + Debug Files 支持,还原压缩/混淆后的堆栈
Breadcrumb自动记录用户操作、HTTP 请求、日志等上下文
Session Replay用户会话回放(Web 前端支持)
Alerting基于 Issue / Metric 的告警规则
自托管完整的自托管部署方案(Docker/Kubernetes)

支持的平台

包名用途
Sentry核心 SDK(控制台/Worker)
Sentry.AspNetCoreASP.NET Core Web API / MVC
Sentry.Maui.NET MAUI 移动应用
Sentry.AspNetCore.Blazor.WebAssemblyBlazor WASM
Sentry.EntityFrameworkEntity Framework 6 集成(EF Core 查询经内置 DiagnosticSource 自动采集)
Sentry.DiagnosticSourceDiagnosticSource 事件采集
Sentry.OpenTelemetryOpenTelemetry 集成
Sentry.Profiling代码级性能剖析

环境准备

安装

方式一:dotnet CLI
bash
# ASP.NET Core 项目
dotnet add package Sentry.AspNetCore

# 控制台 / Worker 项目
dotnet add package Sentry

# 可选集成
dotnet add package Sentry.EntityFramework     # EF6(EF Core 无需此包)
dotnet add package Sentry.DiagnosticSource    # HTTP / ADO.NET 自动 Span
dotnet add package Sentry.OpenTelemetry       # OTel 桥接
dotnet add package Sentry.Profiling           # 性能剖析
方式二:PackageReference
xml
<ItemGroup>
  <PackageReference Include="Sentry.AspNetCore" Version="6.12.1" />
</ItemGroup>
方式三:包管理器控制台
powershell
Install-Package Sentry.AspNetCore -Version 6.12.1
验证安装
bash
dotnet list package | grep -i sentry

初始化

csharp
// ASP.NET Core (Program.cs)
builder.WebHost.UseSentry(o =>
{
    o.Dsn = "https://examplePublicKey@o0.ingest.sentry.io/0";
    o.TracesSampleRate = 1.0;  // 100% 性能追踪采样
    o.Environment = builder.Environment.EnvironmentName;
    o.Release = "my-app@1.0.0";
});

// 控制台应用
SentrySdk.Init(o =>
{
    o.Dsn = "https://examplePublicKey@o0.ingest.sentry.io/0";
    o.TracesSampleRate = 0.2;  // 20% 采样
});

核心 API

手动上报异常

csharp
try
{
    DoSomething();
}
catch (Exception ex)
{
    // 添加额外上下文
    SentrySdk.ConfigureScope(scope =>
    {
        scope.SetTag("feature", "payment");
        scope.SetExtra("request_body", requestBody);
        scope.User = new SentryUser { Id = "12345", Email = "user@example.com" };
    });
    
    SentrySdk.CaptureException(ex);
}

性能追踪

csharp
// 创建 Transaction
var transaction = SentrySdk.StartTransaction("process-order", "task");
SentrySdk.ConfigureScope(s => s.Transaction = transaction);

try
{
    // Span: 数据库查询(6.12.1 的 ISpan 只有 StartChild(operation),
    // 带 description 的重载是 SpanExtensions 扩展方法)
    var dbSpan = transaction.StartChild("db.query", "SELECT * FROM orders");
    var orders = await db.QueryAsync("SELECT * FROM orders WHERE ...");
    dbSpan.Finish();

    // Span: 业务逻辑
    var bizSpan = transaction.StartChild("business.process");
    ProcessOrders(orders);
    bizSpan.Finish();

    transaction.Finish(SpanStatus.Ok);
}
catch (Exception ex)
{
    transaction.Finish(ex);
}

Breadcrumb 自动采集

csharp
// ASP.NET Core 自动记录:
// - HTTP 请求/响应
// - EF Core 查询
// - 日志消息(需配置 SentryLogs)
// - 认证事件

// 手动添加 Breadcrumb
SentrySdk.AddBreadcrumb(
    "User clicked checkout button",
    category: "ui",
    level: BreadcrumbLevel.Info
);

典型工作流

ASP.NET Core 完整集成

csharp
// Program.cs
var builder = WebApplication.CreateBuilder(args);

builder.WebHost.UseSentry(o =>
{
    o.Dsn = Environment.GetEnvironmentVariable("SENTRY_DSN");
    o.TracesSampleRate = 0.3;
    o.ProfilesSampleRate = 0.1;  // 采样率
    o.Environment = builder.Environment.EnvironmentName;
    o.Release = $"my-api@{Assembly.GetExecutingAssembly().GetName().Version}";
    
    // 性能:只追踪特定路由
    o.TracePropagationTargets = new[] { "https://my-api.com" };
});

// EF Core 查询 Span 由 SDK 内置 DiagnosticSource 集成自动采集;
// EF6 才需要额外安装 Sentry.EntityFramework

var app = builder.Build();
// 新版 SDK 中 ASP.NET Core 请求 Transaction 自动创建(TracesSampleRate > 0 即生效),
// 无需再手动调用 UseSentryTracing()
app.MapControllers();
app.Run();

自托管部署(Docker)

bash
# Sentry 自托管(开发环境)
git clone https://github.com/getsentry/self-hosted.git
cd self-hosted
./install.sh
# 访问 http://localhost:9000

最佳实践

  1. DSN 安全:DSN 可以公开(不像 API Key),但仍建议通过环境变量管理
  2. 采样率:生产环境建议 TracesSampleRate = 0.1-0.3,避免高流量下性能影响
  3. Release 标记:设置 Release 标签,让 Sentry 关联代码变更与错误
  4. BeforeSend 钩子:过滤敏感信息(密码、Token)再上报
  5. 用户隐私:遵守 GDPR,配置 SendDefaultPii = false(默认)

常见问题

问题解决方案
DSN 在哪里获取?Sentry Dashboard → Settings → Projects → Client Keys
如何过滤敏感数据?使用 BeforeSend 回调或 BeforeSendTransaction
ASP.NET Core 中性能追踪不生效?确保 TracesSampleRate > 0(新版 SDK 自动创建请求 Transaction,无需额外中间件)
如何与 OpenTelemetry 共存?安装 Sentry.OpenTelemetry,通过 OTel 桥接
EF Core 查询没有追踪?确认 ADO.NET/DiagnosticSource 集成未被禁用;Sentry.EntityFramework 仅用于 EF6

AI 使用建议

推荐工作流

  1. 安装 SDK:dotnet add package Sentry.AspNetCore(ASP.NET Core)或 Sentry(基础)
  2. 配置 DSN:在 appsettings.json 中设置 Sentry:Dsn 或环境变量 SENTRY_DSN
  3. 启用追踪:builder.WebHost.UseSentry()(Web)或 SentrySdk.Init()(控制台),并设置 TracesSampleRate
  4. 自动采集:ASP.NET Core、EF Core、HttpClient 等自动采集性能数据
  5. 自定义事件:SentrySdk.CaptureMessage() 或 SentrySdk.CaptureException()

关键注意事项

  • DSN 必填:无 DSN 时 SDK 静默不工作,不会抛异常
  • 性能追踪:设置 TracesSampleRate > 0 才会生成 Transaction/Span;新版 SDK 自动插桩,旧文档中的 UseSentryTracing() 中间件已无需调用
  • 采样率:生产环境建议 TracesSampleRate = 0.1(10%),避免过多数据
  • 隐私过滤:用 BeforeSend 回调过滤敏感数据(PII、密码等)
  • 自托管:Docker 部署需配置 SENTRY_SECRET_KEY 和邮件服务

相关技能


参考资源

Frequently asked questions

What does the Sentry AI skill do?

Use when adding error tracking, performance monitoring or release health to .NET apps — builder.WebHost.UseSentry, SetBeforeSend, SentrySdk.CaptureException, TracesSampleRate, StartTransaction/StartChild spans, Source Context, symbol upload. Also for events not arriving because Dsn is empty (the SDK stays silent), tracing producing no transactions, PII leaking into events, and StartChildSpan no longer existing in 6.x. Sentry .NET SDK.

Why use Sentry on TypingMind?

Because you install it once and use it with any model. Sentry is plain Markdown rather than provider-specific code, so the same skill runs on GPT-5, Claude, Gemini, Grok, or a local model — and you can switch model mid-chat without it breaking. TypingMind runs on your own API keys, so you pay providers directly instead of a per-seat subscription, and your skills and chats stay in your own storage.

How do I install Sentry in TypingMind?

Open Plugins → Skills → Install from GitHub in TypingMind and paste https://github.com/znlgis/opengis-skills/tree/main/csharp/sentry. TypingMind reads its SKILL.md and installs it as a skill you can enable per chat.

Which AI models can use Sentry?

Any model you connect in TypingMind. AI skills are plain Markdown instructions rather than provider-specific code, so GPT, Claude, Gemini, Grok, and local models can all load this skill when a request matches it.

How many AI models can I use with Sentry?

As many as you like. As long as a model supports skills, you can use Sentry with it — GPT, Claude, Gemini, Grok, DeepSeek, Mistral, Llama and more — all on TypingMind with your own API keys.

Is the Sentry AI skill free?

Yes. It is published on GitHub by znlgis under the MIT license. You only pay your own AI provider for the tokens you use.

What are AI skills?

An AI skill is a reusable instruction bundle that teaches an AI model how to do one specific task. It follows the open Agent Skills format: a SKILL.md file with a name and description, plus any scripts, templates or reference files the model may need. The model reads the instructions only when your request matches the skill, so an installed skill costs nothing until it is used.

How are AI skills different from plugins or MCP servers?

A plugin or MCP server gives a model new tools to call — code that runs somewhere and returns a result. An AI skill gives the model knowledge and process instead: how to approach a task, which steps to follow, what good output looks like. Skills are plain Markdown, so they need no server, no API key and no runtime, and they work with any model.

View all

Set up your own AI workspace now

Get notified about new features and future giveaways by subscribing to our newsletter 👇