Skip to content

DefaultRunAttributionContext

Namespace AgentPrism · Assembly AgentPrism.Core.dll

The built-in IRunAttributionContext. It reports whatever AmbientRunAttributionScope carries, and nothing otherwise.

public sealed class DefaultRunAttributionContext : IRunAttributionContext

objectDefaultRunAttributionContext

IRunAttributionContext

object.GetType(), object.ToString(), object.Equals(object?), object.Equals(object?, object?), object.ReferenceEquals(object?, object?), object.GetHashCode()

An application that registers nothing gets exactly its previous behaviour: both members are null, the user_id and labels columns stay NULL, and no other behaviour changes. This is the the no-surprises rule “no surprises” default.

The ambient scope is still honoured here so that a queued job, a scheduled run or a direct.NET call can attribute itself without the consumer having to write an implementation first — the same courtesy HttpTenantContext extends to AmbientTenantScope.

The registration uses TryAdd, so a consumer implementation that binds the interface to a real identity pipeline always wins.

public DefaultRunAttributionContext()

Gets the labels of the current run, or null when there are none.

public IReadOnlyDictionary<string, string>? Labels { get; }

IReadOnlyDictionary<string, string>?

Labels are a query dimension, not a metric dimension. They live in the runs table and are never added to agentprism.tokens or agentprism.run.cost: turning a free label set into a metric dimension blows up time-series cardinality. The same rule applies to IRunAttributionContext.UserId. The limits are on RunLabels.

Gets the user the current run belongs to, or null when it is unknown.

public string? UserId { get; }

string?

The value is an opaque string. AgentPrism neither resolves nor validates its meaning, and stores no personal detail of its own; the consumer decides what the identifier means. This is the same stance IDataSubjectResolver takes, and the data subject erasure flow covers this column too.