Skip to content
TraceStax Docs

.NET

The TraceStax .NET SDK supports Hangfire, MassTransit, and the generic IHostedService / BackgroundService pattern. It targets .NET 6+ and works with both ASP.NET Core and worker services.

  • .NET 6.0+
  • One of: Hangfire 1.8+, MassTransit 8.x, or any BackgroundService implementation
Terminal window
dotnet add package TraceStax

Or via the NuGet Package Manager:

Install-Package TraceStax

Program.cs
builder.Services.AddHangfire(config => config
.UseRecommendedSerializerSettings()
.UseSqlServerStorage(connectionString));
builder.Services.AddHangfireServer();
// Add TraceStax — registers a job filter automatically
builder.Services.AddTraceStax(options => {
options.ApiKey = builder.Configuration["TraceStax:ApiKey"];
});

The TraceStax job filter wraps all Hangfire job executions — no per-job changes needed.


builder.Services.AddTraceStax(options => {
options.ApiKey = "ts_live_xxxxxxxxxxxx"; // or from config
options.WorkerId = "worker-01"; // default: hostname + PID
options.Enabled = !builder.Environment.IsDevelopment();
options.TimeoutMs = 3000;
});

Or via appsettings.json:

{
"TraceStax": {
"ApiKey": "ts_live_xxxxxxxxxxxx",
"WorkerId": "worker-01",
"Enabled": true
}
}

// Register the no-op client in test projects
services.AddTraceStaxNoop();

Or set Enabled = false in your test appsettings.json.