# RunLabels

> Tracon documentation. Tracon is a .NET package family that adds a control
> plane on Microsoft Agent Framework, published as NuGet packages that run
> inside your own ASP.NET Core application.
>
> Page: https://tracon.dev/api/tracon.runlabels/
> Summary: RunLabels: The limits a run's attribution must obey, and the single place they are enforced.

<div class="api-provenance">Namespace Tracon · Assembly <code>Tracon.Abstractions.dll</code></div>

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

```csharp
public static class RunLabels
```

<dl class="api-relations"><dt>Inheritance</dt><dd><a href="https://learn.microsoft.com/dotnet/api/system.object">object</a> ← <a href="/api/tracon.runlabels/">RunLabels</a></dd><dt>Inherited Members</dt><dd><a href="https://learn.microsoft.com/dotnet/api/system.object.gettype">object.GetType()</a>, <a href="https://learn.microsoft.com/dotnet/api/system.object.memberwiseclone">object.MemberwiseClone()</a>, <a href="https://learn.microsoft.com/dotnet/api/system.object.tostring">object.ToString()</a>, <a href="https://learn.microsoft.com/dotnet/api/system.object.equals#system-object-equals(system-object)">object.Equals(object?)</a>, <a href="https://learn.microsoft.com/dotnet/api/system.object.equals#system-object-equals(system-object-system-object)">object.Equals(object?, object?)</a>, <a href="https://learn.microsoft.com/dotnet/api/system.object.referenceequals">object.ReferenceEquals(object?, object?)</a>, <a href="https://learn.microsoft.com/dotnet/api/system.object.gethashcode">object.GetHashCode()</a></dd></dl>

## Remarks

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.

## Fields

### <a id="Tracon_RunLabels_MaxCount"></a> MaxCount

The largest number of labels one run may carry.

```csharp
public const int MaxCount = 8
```

#### Field Value

 [int](https://learn.microsoft.com/dotnet/api/system.int32)

### <a id="Tracon_RunLabels_MaxKeyLength"></a> MaxKeyLength

The largest length of a label key.

```csharp
public const int MaxKeyLength = 64
```

#### Field Value

 [int](https://learn.microsoft.com/dotnet/api/system.int32)

#### Remarks

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

### <a id="Tracon_RunLabels_MaxUserIdLength"></a> MaxUserIdLength

The largest length of a user identity.

```csharp
public const int MaxUserIdLength = 200
```

#### Field Value

 [int](https://learn.microsoft.com/dotnet/api/system.int32)

#### Remarks

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.

### <a id="Tracon_RunLabels_MaxValueLength"></a> MaxValueLength

The largest length of a label value.

```csharp
public const int MaxValueLength = 256
```

#### Field Value

 [int](https://learn.microsoft.com/dotnet/api/system.int32)

#### Remarks

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

## Methods

### <a id="Tracon_RunLabels_Freeze_System_Collections_Generic_IReadOnlyDictionary_System_String_System_String__"></a> Freeze\(IReadOnlyDictionary<string, string\>\)

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

```csharp
public static IReadOnlyDictionary<string, string> Freeze(IReadOnlyDictionary<string, string> labels)
```

#### Parameters

`labels` [IReadOnlyDictionary](https://learn.microsoft.com/dotnet/api/system.collections.generic.ireadonlydictionary\-2)<[string](https://learn.microsoft.com/dotnet/api/system.string), [string](https://learn.microsoft.com/dotnet/api/system.string)\>

The labels to copy.

#### Returns

 [IReadOnlyDictionary](https://learn.microsoft.com/dotnet/api/system.collections.generic.ireadonlydictionary\-2)<[string](https://learn.microsoft.com/dotnet/api/system.string), [string](https://learn.microsoft.com/dotnet/api/system.string)\>

A snapshot that later writes to the source cannot change.

#### Remarks

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.

#### Exceptions

 [ArgumentNullException](https://learn.microsoft.com/dotnet/api/system.argumentnullexception)

`labels` is [null](https://learn.microsoft.com/dotnet/csharp/language-reference/keywords/null).

### <a id="Tracon_RunLabels_Validate_System_String_System_Collections_Generic_IReadOnlyDictionary_System_String_System_String__"></a> Validate\(string?, IReadOnlyDictionary<string, string\>?\)

Checks a complete attribution.

```csharp
public static string? Validate(string? userId, IReadOnlyDictionary<string, string>? labels)
```

#### Parameters

`userId` [string](https://learn.microsoft.com/dotnet/api/system.string)?

The user identity, or [null](https://learn.microsoft.com/dotnet/csharp/language-reference/keywords/null).

`labels` [IReadOnlyDictionary](https://learn.microsoft.com/dotnet/api/system.collections.generic.ireadonlydictionary\-2)<[string](https://learn.microsoft.com/dotnet/api/system.string), [string](https://learn.microsoft.com/dotnet/api/system.string)\>?

The labels, or [null](https://learn.microsoft.com/dotnet/csharp/language-reference/keywords/null).

#### Returns

 [string](https://learn.microsoft.com/dotnet/api/system.string)?

[null](https://learn.microsoft.com/dotnet/csharp/language-reference/keywords/null) when the value is acceptable, otherwise a message
naming the limit that was broken.

### <a id="Tracon_RunLabels_ValidateLabels_System_Collections_Generic_IReadOnlyDictionary_System_String_System_String__"></a> ValidateLabels\(IReadOnlyDictionary<string, string\>?\)

Checks a label set on its own.

```csharp
public static string? ValidateLabels(IReadOnlyDictionary<string, string>? labels)
```

#### Parameters

`labels` [IReadOnlyDictionary](https://learn.microsoft.com/dotnet/api/system.collections.generic.ireadonlydictionary\-2)<[string](https://learn.microsoft.com/dotnet/api/system.string), [string](https://learn.microsoft.com/dotnet/api/system.string)\>?

The labels, or [null](https://learn.microsoft.com/dotnet/csharp/language-reference/keywords/null).

#### Returns

 [string](https://learn.microsoft.com/dotnet/api/system.string)?

[null](https://learn.microsoft.com/dotnet/csharp/language-reference/keywords/null) when the value is acceptable, otherwise a message.

### <a id="Tracon_RunLabels_ValidateUserId_System_String_"></a> ValidateUserId\(string?\)

Checks a user identity on its own.

```csharp
public static string? ValidateUserId(string? userId)
```

#### Parameters

`userId` [string](https://learn.microsoft.com/dotnet/api/system.string)?

The user identity, or [null](https://learn.microsoft.com/dotnet/csharp/language-reference/keywords/null).

#### Returns

 [string](https://learn.microsoft.com/dotnet/api/system.string)?

[null](https://learn.microsoft.com/dotnet/csharp/language-reference/keywords/null) when the value is acceptable, otherwise a message.
