Skip to content

Commit c1462e1

Browse files
committed
chore: add Exceptionless ASP.NET Core agent skill references
1 parent 2823258 commit c1462e1

19 files changed

Lines changed: 1675 additions & 0 deletions
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
---
2+
name: exceptionless-dotnet
3+
description: Use this skill when configuring, integrating, documenting, or reviewing Exceptionless .NET clients. Covers package selection and setup for Exceptionless, Exceptionless.AspNetCore, Extensions.Hosting, Extensions.Logging, MVC, Web API, WebForms, WCF, WPF, Windows Forms, NLog, log4net, Blazor, and serverless; client configuration, appsettings/app.config/environment variables, self-hosted URLs, storage, queue flushing, events, log levels, server-synced settings, plugins, privacy/data exclusions, troubleshooting, and upgrades.
4+
---
5+
6+
# Exceptionless .NET
7+
8+
## Core Workflow
9+
10+
Use this skill to produce implementation-ready Exceptionless .NET guidance or patches. Prefer current repository source and package readmes over older public docs when they differ.
11+
12+
1. Identify the app shape first: ASP.NET Core, Generic Host worker/service, console, legacy ASP.NET MVC/Web API/WebForms/WCF, WPF, Windows Forms, logging-only integration, Blazor WebAssembly, or serverless.
13+
2. Read only the reference file that matches the requested package or advanced topic:
14+
- `references/client-package-selection.md` for package choice, authoritative source files, and public docs.
15+
- `references/client-console-services.md` for the root `Exceptionless` package in console apps, services, Blazor WebAssembly, and serverless functions.
16+
- `references/client-aspnetcore.md` for `Exceptionless.AspNetCore`.
17+
- `references/client-extensions-hosting.md` for `Exceptionless.Extensions.Hosting`.
18+
- `references/client-extensions-logging.md` for `Exceptionless.Extensions.Logging`.
19+
- `references/client-nlog.md` for `Exceptionless.NLog`.
20+
- `references/client-log4net.md` for `Exceptionless.Log4net`.
21+
- `references/client-mvc.md`, `references/client-webapi.md`, and `references/client-web-webforms-wcf.md` for legacy ASP.NET packages.
22+
- `references/client-wpf.md` and `references/client-windows-forms.md` for desktop packages.
23+
- `references/client-messagepack.md` for `Exceptionless.MessagePack`.
24+
- `references/client-configuration-runtime-settings.md` for API keys, config sources, self-hosted URLs, storage, real-time settings, sessions, and serverless queue flushing.
25+
- `references/client-plugins-event-pipeline.md` for plugins, priorities, cancellation, enrichment, and event exclusions.
26+
- `references/client-log-levels-filtering.md` for log levels, remote log filters, type/source filters, and high-throughput logging.
27+
- `references/client-privacy-data-exclusions-troubleshooting.md` for privacy, diagnostics, troubleshooting, proxies, de-duplication, and upgrades.
28+
3. Choose the platform package before writing code. Do not use the root `Exceptionless` package alone when a platform package will capture richer context automatically.
29+
4. Configure before the first event is submitted. Some settings are locked after queue/submission startup, including API key and server URLs.
30+
5. Prefer dependency injection for ASP.NET Core and hosted services. Use `ExceptionlessClient.Default` for simple console apps, legacy integrations, and examples only when DI is not already available.
31+
6. Treat privacy as a first-class requirement. Default collection includes potentially private metadata; explicitly decide on `IncludePrivateInformation`, data exclusions, and custom plugin redaction for production examples.
32+
7. When changing code examples, update or add repository tests that exercise the documented API surface. Do not add executable scripts, generated validators, or other runnable code inside this skill.
33+
34+
## Quality Bar
35+
36+
- Include the package name, startup call, configuration source, queue-flush behavior, and privacy stance for every setup recommendation.
37+
- For ASP.NET Core on current source, include `builder.AddExceptionless(...)`, `builder.Services.AddProblemDetails()`, `app.UseExceptionHandler()`, and `app.UseExceptionless()` when capturing unhandled HTTP exceptions.
38+
- For Generic Host workers, include `builder.AddExceptionless(...)` plus `builder.UseExceptionless()` or explain how `ProcessQueueAsync()` is called during shutdown.
39+
- For logging, explain the split between Microsoft logging rules and Exceptionless remote log-level settings.
40+
- For advanced filtering, use server-synced settings or plugins instead of scattering ad hoc `if` statements around application code.
41+
- For high-throughput logs, prefer in-memory storage for logging-only clients and document the durability tradeoff.
42+
- For short-lived processes, serverless handlers, and CLI tools, flush with `await client.ProcessQueueAsync()` or an async-disposable scope before exit.
43+
44+
## Validation
45+
46+
Keep validation in the repository test suite, not in skill scripts. When editing this skill, verify the claims against current source/readmes and run the relevant `dotnet test` projects that cover the documented setup, configuration, logging, plugin, filtering, and privacy behavior.
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
interface:
2+
display_name: "Exceptionless .NET"
3+
short_description: "Exceptionless .NET setup and best practices"
4+
default_prompt: "Use $exceptionless-dotnet to configure or review Exceptionless .NET client setup, logging, plugins, runtime settings, privacy, and troubleshooting."
Lines changed: 166 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,166 @@
1+
# Exceptionless.AspNetCore Client
2+
3+
4+
## When To Use
5+
6+
Use `Exceptionless.AspNetCore` for ASP.NET Core web apps and APIs. It integrates with DI, ASP.NET Core exception handling, request diagnostics, 404 tracking, HTTP context collection, and host shutdown flushing. Add `Exceptionless.Extensions.Logging` when `ILogger` events should be sent too.
7+
8+
## Install
9+
10+
```bash
11+
dotnet add package Exceptionless.AspNetCore
12+
dotnet add package Exceptionless.Extensions.Logging
13+
```
14+
15+
## Current Minimal Setup
16+
17+
Current source setup is newer than the public web-server example. Use `WebApplicationBuilder.AddExceptionless`, `AddProblemDetails`, `UseExceptionHandler`, and `UseExceptionless`.
18+
19+
```csharp
20+
using Exceptionless;
21+
using Microsoft.AspNetCore.Builder;
22+
using Microsoft.Extensions.DependencyInjection;
23+
using Microsoft.Extensions.Logging;
24+
25+
var builder = WebApplication.CreateBuilder(args);
26+
27+
builder.Logging.AddExceptionless();
28+
builder.AddExceptionless(c => {
29+
c.ApiKey = "VALID_API_KEY_12345";
30+
c.DefaultData["Service"] = "payments-api";
31+
c.DefaultTags.Add("aspnetcore");
32+
});
33+
34+
builder.Services.AddProblemDetails();
35+
builder.Services.AddControllers();
36+
37+
var app = builder.Build();
38+
39+
app.UseExceptionHandler();
40+
app.UseExceptionless();
41+
42+
app.MapControllers();
43+
app.Run();
44+
```
45+
46+
## Minimal APIs
47+
48+
Minimal APIs are supported using the same middleware stack as controllers; register `ProblemDetails`, `UseExceptionHandler`, and `UseExceptionless` before endpoint mapping, and inject `ExceptionlessClient` into handlers as needed.
49+
50+
```csharp
51+
using Exceptionless;
52+
using Exceptionless.AspNetCore;
53+
using Microsoft.AspNetCore.Builder;
54+
using Microsoft.AspNetCore.Http;
55+
using Microsoft.Extensions.DependencyInjection;
56+
57+
var builder = WebApplication.CreateBuilder(args);
58+
59+
builder.Logging.AddExceptionless();
60+
builder.AddExceptionless(c => {
61+
c.ApiKey = "VALID_API_KEY_12345";
62+
c.DefaultData["Service"] = "minimal-api";
63+
c.DefaultTags.Add("minimal-api");
64+
});
65+
66+
builder.Services.AddProblemDetails();
67+
68+
var app = builder.Build();
69+
70+
app.UseExceptionHandler();
71+
app.UseExceptionless();
72+
73+
app.MapGet("/ping", (ExceptionlessClient exceptionless) => {
74+
exceptionless.SubmitFeatureUsage("PingEndpoint");
75+
return Results.Ok(new { ok = true, service = "minimal-api" });
76+
});
77+
78+
app.MapGet("/fail", (HttpContext context) => throw new InvalidOperationException("Handled by middleware"));
79+
80+
app.Run();
81+
```
82+
83+
## Controller And Service Usage
84+
85+
Inject `ExceptionlessClient`. The static default works, but DI is better for tests and code clarity.
86+
87+
```csharp
88+
using System;
89+
using Exceptionless;
90+
using Microsoft.AspNetCore.Mvc;
91+
using Microsoft.Extensions.Logging;
92+
93+
[ApiController]
94+
[Route("api/[controller]")]
95+
public sealed class ValuesController : ControllerBase {
96+
private readonly ExceptionlessClient _exceptionless;
97+
private readonly ILogger<ValuesController> _logger;
98+
99+
public ValuesController(ExceptionlessClient exceptionless, ILogger<ValuesController> logger) {
100+
_exceptionless = exceptionless;
101+
_logger = logger;
102+
}
103+
104+
[HttpGet("{id}")]
105+
public IActionResult Get(string id) {
106+
_logger.LogWarning("Loading value {ValueId}", id);
107+
_exceptionless.SubmitFeatureUsage("ValuesController.Get");
108+
109+
try {
110+
throw new InvalidOperationException("Example handled failure.");
111+
} catch (Exception ex) {
112+
ex.ToExceptionless(_exceptionless)
113+
.SetProperty("ValueId", id)
114+
.AddTags("handled")
115+
.Submit();
116+
}
117+
118+
return Ok(new { id });
119+
}
120+
}
121+
```
122+
123+
## Middleware Behavior
124+
125+
`app.UseExceptionless()`:
126+
127+
- Resolves the DI client or falls back to `ExceptionlessClient.Default`.
128+
- Calls `client.Startup()`.
129+
- Adds `ExceptionlessAspNetCorePlugin` and `IgnoreUserAgentPlugin`.
130+
- Subscribes to relevant diagnostic listener events.
131+
- Registers shutdown queue flushing if the hosting lifetime service is not already registered.
132+
- Adds middleware that records 404 responses.
133+
- Flushes the queue on response completion when `ProcessQueueOnCompletedRequest` is true.
134+
135+
## ASP.NET Core Configuration
136+
137+
```json
138+
{
139+
"Exceptionless": {
140+
"ApiKey": "VALID_API_KEY_12345",
141+
"ServerUrl": "https://collector.exceptionless.io",
142+
"IncludePrivateInformation": false,
143+
"ProcessQueueOnCompletedRequest": false,
144+
"DefaultData": {
145+
"Service": "payments-api"
146+
},
147+
"DefaultTags": [ "aspnetcore", "production" ],
148+
"Settings": {
149+
"@@log:*": "Warn",
150+
"enableLogSubmission": true
151+
}
152+
}
153+
}
154+
```
155+
156+
## Serverless ASP.NET Core
157+
158+
For AWS Lambda/Azure Functions style ASP.NET Core hosting, set `ProcessQueueOnCompletedRequest` when each request must flush before the runtime freezes. This is safer but more expensive per request.
159+
160+
## Best Practices
161+
162+
- Keep `UseExceptionHandler()` before endpoints; call `UseExceptionless()` before endpoint mapping.
163+
- Add `AddProblemDetails()` or a custom exception response handler so HTTP errors get responses.
164+
- Prefer `ILogger` for normal application logs and `ExceptionlessClient` for feature usage, not-found, custom events, and handled exceptions with rich context.
165+
- Include privacy configuration in `appsettings.json`, not only in code.
166+
- Use `SetHttpContext` for manual events outside the normal request pipeline when request info matters.

0 commit comments

Comments
 (0)