Skip to content

RunLabels

Namespace AgentPrism · Assembly AgentPrism.Abstractions.dll

The limits a run’s attribution must obey, and the single place they are enforced.

public static class RunLabels

objectRunLabels

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

Labels answer “which job was this run made for”. They are a small string-to-string map, kept deliberately small: a run label is a query dimension, and an unbounded set of them turns every breakdown query into a scan over an unbounded key space.

Breaking a limit REJECTS the value; it is never trimmed. A trimmed label set still looks like a complete measurement to whoever reads the report later, and that is worse than an error at the boundary.

The largest number of labels one run may carry.

public const int MaxCount = 8

int

The largest length of a label key.

public const int MaxKeyLength = 64

int

A key is usable as a breakdown dimension, so it stays short enough to group by.

The largest length of a user identity.

public const int MaxUserIdLength = 200

int

The value is stored in an INDEXED column. SQL Server cannot index nvarchar(max), so every indexed key column in this schema is bounded at 200 characters; the limit here matches that column.

The largest length of a label value.

public const int MaxValueLength = 256

int

This is not a free-text store; longer content belongs in the run’s own event stream.

Freeze(IReadOnlyDictionary<string, string>)

Section titled “ Freeze(IReadOnlyDictionary<string, string>)”

Copies a label set into an immutable, ordinally compared dictionary.

public static IReadOnlyDictionary<string, string> Freeze(IReadOnlyDictionary<string, string> labels)

labels IReadOnlyDictionary<string, string>

The labels to copy.

IReadOnlyDictionary<string, string>

A snapshot that later writes to the source cannot change.

The caller’s dictionary may be mutable and may even be a live request object; a run record must not change under the reader after the run ends.

ArgumentNullException

labels is null.

Validate(string?, IReadOnlyDictionary<string, string>?)

Section titled “ Validate(string?, IReadOnlyDictionary<string, string>?)”

Checks a complete attribution.

public static string? Validate(string? userId, IReadOnlyDictionary<string, string>? labels)

userId string?

The user identity, or null.

labels IReadOnlyDictionary<string, string>?

The labels, or null.

string?

null when the value is acceptable, otherwise a message naming the limit that was broken.

ValidateLabels(IReadOnlyDictionary<string, string>?)

Section titled “ ValidateLabels(IReadOnlyDictionary<string, string>?)”

Checks a label set on its own.

public static string? ValidateLabels(IReadOnlyDictionary<string, string>? labels)

labels IReadOnlyDictionary<string, string>?

The labels, or null.

string?

null when the value is acceptable, otherwise a message.

Checks a user identity on its own.

public static string? ValidateUserId(string? userId)

userId string?

The user identity, or null.

string?

null when the value is acceptable, otherwise a message.