Path: redb-route/redb.Route/Definitions/SpanTagDefinition.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/SpanTagDefinition.cs
----
using Microsoft.Extensions.Logging;
using redb.Route.Abstractions;
using redb.Route.Telemetry;
namespace redb.Route.Definitions;
///
/// Leaf definition of .SpanTag(key, value, target): one attribute on a span of the engine, so a trace can be
/// found by a business key. The key is checked when the route is built (SpanTagPolicy); the value is an
/// , a literal being a constant one.
///
public sealed class SpanTagDefinition : ProcessorDefinition
{
/// Creates a span-tag definition.
/// Attribute name: a constant, lowercase, dot-separated, outside the reserved namespaces.
/// Expression producing the value, evaluated per message.
/// Which span receives the attribute.
/// is refused by the policy.
public SpanTagDefinition(string key, IExpression value, SpanTarget target)
{
SpanTagPolicy.ValidateKey(key);
ArgumentNullException.ThrowIfNull(value);
if (!Enum.IsDefined(target))
throw new ArgumentOutOfRangeException(nameof(target), target, "Unknown span target.");
Key = key;
Value = value;
Target = target;
}
/// The attribute name.
public string Key { get; }
/// The expression producing the attribute value.
public IExpression Value { get; }
/// Which span receives the attribute.
public SpanTarget Target { get; }
///
public override IProcessor CreateProcessor(IRouteContext context)
=> new SpanTagProcessor(Key, Value, Target,
context.GetService()?.CreateLogger());
}