Rig.TUnit.Observability.Tracing
0.1.0-beta.2
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
<PackageReference Include="Rig.TUnit.Observability.Tracing" Version="0.1.0-beta.2" />
<PackageVersion Include="Rig.TUnit.Observability.Tracing" Version="0.1.0-beta.2" />
<PackageReference Include="Rig.TUnit.Observability.Tracing" />
paket add Rig.TUnit.Observability.Tracing --version 0.1.0-beta.2
#r "nuget: Rig.TUnit.Observability.Tracing, 0.1.0-beta.2"
#:package Rig.TUnit.Observability.Tracing@0.1.0-beta.2
#addin nuget:?package=Rig.TUnit.Observability.Tracing&version=0.1.0-beta.2&prerelease
#tool nuget:?package=Rig.TUnit.Observability.Tracing&version=0.1.0-beta.2&prerelease
Rig.TUnit.Observability.Tracing
In-memory OpenTelemetry tracing fixture with
InMemoryExporterand fluentTraceAssertfor 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.TracingFixtureRig.TUnit.Observability.Tracing.Options.TracingFixtureOptionsRig.TUnit.Observability.Tracing.Builder.TracingRigBuilderRig.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-found —ActivitySourcename mismatch. Checkfx.ActivitySource.Namematches what the code under test uses.- Parent-child broken across
Task.Run—Activity.CurrentisAsyncLocaland does crossTask.Run, but a thread-pool worker executed before theActivitystarted loses context. Instrument with explicitActivityContextpropagation.
See docs/troubleshooting.md#tracing.
Provider quirks + edge cases
- Spans are immutable after
Stop— mutation attempts are silently ignored by OTEL SDK. InMemoryExporterkeeps all spans until fixture disposal; long test runs with millions of spans can OOM. Callfx.Clear()between test phases if needed.- Span status is
Unsetby default; promoting toOkorErrorrequires an explicitSetStatuscall.
Benchmarks
See TracingBenchmarks.cs;
baseline in benchmarks/baseline-005.json.
Related docs
- Architecture diagram
- Glossary
- Family base:
Rig.TUnit.Observability
License
MIT. See LICENSE.
| Product | Versions 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. |
-
net10.0
- Bogus (>= 35.6.1)
- Microsoft.Extensions.Configuration (>= 10.0.0)
- Microsoft.Extensions.Configuration.Binder (>= 10.0.0)
- Microsoft.Extensions.DependencyInjection (>= 10.0.0)
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 10.0.0)
- Microsoft.Extensions.Logging (>= 10.0.0)
- Microsoft.Extensions.Logging.Abstractions (>= 10.0.0)
- Microsoft.Extensions.Options (>= 10.0.0)
- Microsoft.Extensions.Options.ConfigurationExtensions (>= 10.0.0)
- Microsoft.Extensions.Options.DataAnnotations (>= 10.0.0)
- OpenTelemetry (>= 1.15.3)
- OpenTelemetry.Api (>= 1.15.3)
- OpenTelemetry.Exporter.InMemory (>= 1.15.3)
- Rig.TUnit.Observability (>= 0.1.0-beta.2)
- TUnit.Core (>= 1.34.5)
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 |