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
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Last9.OpenTelemetry.BodyCapture" Version="0.1.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Last9.OpenTelemetry.BodyCapture" Version="0.1.0" />
                    
Directory.Packages.props
<PackageReference Include="Last9.OpenTelemetry.BodyCapture" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Last9.OpenTelemetry.BodyCapture --version 0.1.0
                    
#r "nuget: Last9.OpenTelemetry.BodyCapture, 0.1.0"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package Last9.OpenTelemetry.BodyCapture@0.1.0
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Last9.OpenTelemetry.BodyCapture&version=0.1.0
                    
Install as a Cake Addin
#tool nuget:?package=Last9.OpenTelemetry.BodyCapture&version=0.1.0
                    
Install as a Cake Tool

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 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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • 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