Rig.TUnit.Observability.Tracing 0.1.0-beta.2

This is a prerelease version of Rig.TUnit.Observability.Tracing.
dotnet add package Rig.TUnit.Observability.Tracing --version 0.1.0-beta.2
                    
NuGet\Install-Package Rig.TUnit.Observability.Tracing -Version 0.1.0-beta.2
                    
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="Rig.TUnit.Observability.Tracing" Version="0.1.0-beta.2" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Rig.TUnit.Observability.Tracing" Version="0.1.0-beta.2" />
                    
Directory.Packages.props
<PackageReference Include="Rig.TUnit.Observability.Tracing" />
                    
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 Rig.TUnit.Observability.Tracing --version 0.1.0-beta.2
                    
#r "nuget: Rig.TUnit.Observability.Tracing, 0.1.0-beta.2"
                    
#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 Rig.TUnit.Observability.Tracing@0.1.0-beta.2
                    
#: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=Rig.TUnit.Observability.Tracing&version=0.1.0-beta.2&prerelease
                    
Install as a Cake Addin
#tool nuget:?package=Rig.TUnit.Observability.Tracing&version=0.1.0-beta.2&prerelease
                    
Install as a Cake Tool

Rig.TUnit.Observability.Tracing

In-memory OpenTelemetry tracing fixture with InMemoryExporter and fluent TraceAssert for span / tag / status / parent-child verification.

What this package is

The tracing counterpart to Rig.TUnit.Observability.Logging. TracingFixture wires a TracerProvider with an InMemoryExporter so every Activity emitted through a known ActivitySource gets captured. TraceAssert is the fluent DSL: .HasSpan(name).WithTag(…).WithStatus (Ok).DurationLessThan(1s).

When to use it

  • Integration tests verifying spans are emitted at the right code sites.
  • Asserting tag values and status codes on critical-path operations.
  • Verifying parent/child relationships across async boundaries.
  • Not for: E2E tests against a real OTLP collector.

Prerequisites

  • .NET 10 SDK
  • OpenTelemetry + .Exporter.InMemory (transitive)

Quick start

using System.Diagnostics;
using Rig.TUnit.Observability.Tracing.Fixtures;
using Rig.TUnit.Observability.Tracing.Options;

await using var fx = new TracingFixture(new TracingFixtureOptions { ServiceName = "my-svc" });
await fx.InitializeAsync();

using (var act = fx.ActivitySource.StartActivity("op.work"))
{
    act?.SetStatus(ActivityStatusCode.Ok);
}

Options

Property Type Default Description
ServiceName string $"rigtunit-{IsolationKey}" OTEL resource attribute
ActivitySourceName string "Rig.TUnit.Tests" Source name listened to
RecordException bool true Auto-record exceptions as span events

Fixture + helper APIs

  • Rig.TUnit.Observability.Tracing.Fixtures.TracingFixture
  • Rig.TUnit.Observability.Tracing.Options.TracingFixtureOptions
  • Rig.TUnit.Observability.Tracing.Builder.TracingRigBuilder
  • Rig.TUnit.Observability.Tracing.Assertions.TraceAssert

Per-test isolation

Each TracingFixture owns its exporter. ServiceName includes IsolationKey so spans stay distinguishable across parallel fixtures.

Parallelism + performance

  • Fixture construction: ~3 ms.
  • Per-span overhead: ~2 µs (no network).
  • Safe under full parallelism.

Troubleshooting

  • HasSpan("name") reports not-foundActivitySource name mismatch. Check fx.ActivitySource.Name matches what the code under test uses.
  • Parent-child broken across Task.RunActivity.Current is AsyncLocal and does cross Task.Run, but a thread-pool worker executed before the Activity started loses context. Instrument with explicit ActivityContext propagation.

See docs/troubleshooting.md#tracing.

Provider quirks + edge cases

  • Spans are immutable after Stop — mutation attempts are silently ignored by OTEL SDK.
  • InMemoryExporter keeps all spans until fixture disposal; long test runs with millions of spans can OOM. Call fx.Clear() between test phases if needed.
  • Span status is Unset by default; promoting to Ok or Error requires an explicit SetStatus call.

Benchmarks

See TracingBenchmarks.cs; baseline in benchmarks/baseline-005.json.

License

MIT. See LICENSE.

Product Compatible and additional computed target framework versions.
.NET net10.0 is compatible.  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.

NuGet packages (2)

Showing the top 2 NuGet packages that depend on Rig.TUnit.Observability.Tracing:

Package Downloads
Rig.TUnit.All

Meta-package containing every Rig.TUnit.* package. DISCOURAGED — prefer per-feature or per-stack meta-packages (Rig.TUnit, Rig.TUnit.Microservices).

Rig.TUnit.Microservices

Meta-package: Core + Mediator + Grpc + Outbox + Tracing + Jwt + Seq — the opinionated microservice testing kit.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
0.1.0-beta.2 45 4/27/2026
0.0.0-alpha.0.14 51 4/26/2026