Last9.OpenTelemetry.BodyCapture
0.1.0
dotnet add package Last9.OpenTelemetry.BodyCapture --version 0.1.0
NuGet\Install-Package Last9.OpenTelemetry.BodyCapture -Version 0.1.0
<PackageReference Include="Last9.OpenTelemetry.BodyCapture" Version="0.1.0" />
<PackageVersion Include="Last9.OpenTelemetry.BodyCapture" Version="0.1.0" />
<PackageReference Include="Last9.OpenTelemetry.BodyCapture" />
paket add Last9.OpenTelemetry.BodyCapture --version 0.1.0
#r "nuget: Last9.OpenTelemetry.BodyCapture, 0.1.0"
#:package Last9.OpenTelemetry.BodyCapture@0.1.0
#addin nuget:?package=Last9.OpenTelemetry.BodyCapture&version=0.1.0
#tool nuget:?package=Last9.OpenTelemetry.BodyCapture&version=0.1.0
Last9.OpenTelemetry.BodyCapture
You're already sending traces. This package adds the request and response bodies to them. One call, no middleware wiring, works with .NET auto-instrumentation so your app stays clean.
Install
dotnet add package Last9.OpenTelemetry.BodyCapture
Setup
var builder = WebApplication.CreateBuilder(args);
builder.Services.AddHttpBodyCapture(builder.Configuration);
That's it. The middleware registers itself. No app.UseMiddleware<> needed.
Add to appsettings.json:
{
"BodyCapture": {
"Enabled": true,
"CaptureRequestBody": true,
"CaptureResponseBody": true
}
}
Span attributes http.request.body and http.response.body appear on every matching trace.
Configuration
| Key | Default | Description |
|---|---|---|
Enabled |
true |
Master on/off switch |
CaptureRequestBody |
true |
Capture incoming request bodies |
CaptureResponseBody |
true |
Capture outgoing response bodies |
MaxBodySizeBytes |
8192 |
Bodies larger than this get truncated with ...[TRUNCATED] |
CaptureOnErrorOnly |
false |
Set to true to only capture on 4xx/5xx — cheaper in production |
ContentTypes |
["application/json", "application/xml", "text/plain"] |
Only these content types are captured |
IncludePaths |
[] |
Restrict capture to these path prefixes. Empty means everything |
ExcludePaths |
["/health", "/ready", "/metrics"] |
Always skip these paths |
PII/PHI Redaction
Bodies land in spans as plain text. Redact at the collector, not the app — that way the pattern is centralized and no app deployment is needed to update it.
processors:
transform/redact-pii:
trace_statements:
- context: span
statements:
- replace_pattern(attributes["http.request.body"], "\\b\\d{3}-\\d{2}-\\d{4}\\b", "***-**-****")
- replace_pattern(attributes["http.response.body"], "\\b\\d{3}-\\d{2}-\\d{4}\\b", "***-**-****")
See the full working example with Docker Compose, HIPAA PHI patterns, and a Last9-wired collector config.
Requirements
- .NET 8.0+
- ASP.NET Core
License
Apache-2.0
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
-
net8.0
- No dependencies.
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 0.1.0 | 305 | 4/9/2026 |