Path: redb-route/redb.Route/Definitions/TracedDefinition.cs
Snapshot: redb-route, development snapshot 2026-12-06. This is the development state of the public mirrors; it may differ from the published packages.
License: Apache-2.0. Repository: https://github.com/redbase-app/redb-route
Page: https://redbase.app/src/dev-2026-12-06/redb-route/redb.Route/Definitions/TracedDefinition.cs
----
using redb.Route.Abstractions;
using redb.Route.Processors;
using redb.Route.Telemetry;
namespace redb.Route.Definitions;
///
/// Scope-opener definition for OpenTelemetry tracing.
/// All child steps run inside a single span
/// named . Transports (AMQP, RabbitMQ, etc.) create child spans
/// automatically from the parent activity propagated on the exchange.
/// Inherits the leaf DSL from ;
/// close with or the universal .
///
public class TracedDefinition : RouteDefinitionBase, IRouteScope
{
/// Operation name used as the Activity span name.
public string OperationName { get; }
internal TracedDefinition(string operationName)
{
ArgumentException.ThrowIfNullOrWhiteSpace(operationName);
OperationName = operationName;
}
// ── Navigation ─────────────────────────────────────────────────────────────
/// Closes this traced scope and returns the parent route definition.
/// Thrown if no parent route is set.
public IRouteDefinition EndTraced()
=> (IRouteDefinition)(Parent ?? throw new InvalidOperationException(
"EndTraced() called without a parent route. Ensure Traced() was called on a route definition."));
///
public IRouteDefinition End() => EndTraced();
// ── IProcessorDefinition ───────────────────────────────────────────────────
///
public override IProcessor CreateProcessor(IRouteContext context)
{
IProcessor body = BuildPipeline(Outputs, context);
return new InstrumentedProcessor(body, OperationName);
}
private static IProcessor BuildPipeline(IList outputs, IRouteContext context)
=> NodePipeline.Body(context, outputs);
}