# DefaultRunAttributionContext

> 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.defaultrunattributioncontext/
> Summary: DefaultRunAttributionContext: The built-in IRunAttributionContext. It reports whatever AmbientRunAttributionScope carries, and nothing otherwise.

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

The built-in [IRunAttributionContext](/api/tracon.irunattributioncontext/). It reports whatever
[AmbientRunAttributionScope](/api/tracon.ambientrunattributionscope/) carries, and nothing otherwise.

```csharp
public sealed class DefaultRunAttributionContext : IRunAttributionContext
```

<dl class="api-relations"><dt>Inheritance</dt><dd><a href="https://learn.microsoft.com/dotnet/api/system.object">object</a> ← <a href="/api/tracon.defaultrunattributioncontext/">DefaultRunAttributionContext</a></dd><dt>Implements</dt><dd><a href="/api/tracon.irunattributioncontext/">IRunAttributionContext</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.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

An application that registers nothing gets exactly its previous behaviour:
both members are [null](https://learn.microsoft.com/dotnet/csharp/language-reference/keywords/null), the `user_id` and
`labels` columns stay NULL, and no other behaviour changes. This is the
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](/api/tracon.ambienttenantscope/).

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

## Properties

### <a id="Tracon_DefaultRunAttributionContext_Labels"></a> Labels

Gets the labels of the current run, or [null](https://learn.microsoft.com/dotnet/csharp/language-reference/keywords/null) when
there are none.

```csharp
public IReadOnlyDictionary<string, string>? Labels { get; }
```

#### Property Value

 [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)\>?

#### Remarks

Labels are a **query dimension, not a metric dimension**.
They live in the `runs` table and are never added to
`tracon.tokens` or `tracon.run.cost`: turning a free
label set into a metric dimension blows up time-series cardinality. The
same rule applies to [IRunAttributionContext.UserId](/api/tracon.irunattributioncontext/#Tracon_IRunAttributionContext_UserId).
The limits are on [RunLabels](/api/tracon.runlabels/).

### <a id="Tracon_DefaultRunAttributionContext_UserId"></a> UserId

Gets the user the current run belongs to, or [null](https://learn.microsoft.com/dotnet/csharp/language-reference/keywords/null)
when it is unknown.

```csharp
public string? UserId { get; }
```

#### Property Value

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

The value is an **opaque string**. Tracon 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.
