Class AiGraphTracker
Records metrics for a single agent graph invocation.
Inherited Members
Namespace: LaunchDarkly.Sdk.Server.Ai.Graph
Assembly: LaunchDarkly.ServerSdk.Ai.dll
Syntax
public sealed class AiGraphTracker
Remarks
All events share a runId so LaunchDarkly can correlate them. Graph-level
tracking methods (TrackInvocationSuccess, TrackDuration, etc.) are
at-most-once — a second call logs a warning and is silently dropped. Edge-level
methods (TrackRedirect, TrackHandoffSuccess, TrackHandoffFailure)
are multi-fire and may be called once per edge traversal.
Constructors
| Edit this page View SourceAiGraphTracker(ILaunchDarklyClient, string, int, Context, string, string)
Constructs a new graph tracker. If runId is null, a new UUIDv4
is generated automatically.
Declaration
public AiGraphTracker(ILaunchDarklyClient ldClient, string graphKey, int version, Context context, string variationKey = null, string runId = null)
Parameters
| Type | Name | Description |
|---|---|---|
| ILaunchDarklyClient | ldClient | |
| string | graphKey | |
| int | version | |
| Context | context | |
| string | variationKey | |
| string | runId |
Properties
| Edit this page View SourceResumptionToken
The resumption token for cross-process continuation of this tracker.
Declaration
public string ResumptionToken { get; }
Property Value
| Type | Description |
|---|---|
| string |
Summary
A partial snapshot of the metrics tracked so far. Fields are null until the corresponding track method fires.
Declaration
public AiGraphMetricSummary Summary { get; }
Property Value
| Type | Description |
|---|---|
| AiGraphMetricSummary |
Methods
| Edit this page View SourceFromResumptionToken(string, ILaunchDarklyClient, Context)
Reconstructs a graph tracker from a resumption token, enabling cross-process scenarios where a tracker's run ID needs to be reused.
Declaration
public static AiGraphTracker FromResumptionToken(string token, ILaunchDarklyClient ldClient, Context context)
Parameters
| Type | Name | Description |
|---|---|---|
| string | token | |
| ILaunchDarklyClient | ldClient | |
| Context | context |
Returns
| Type | Description |
|---|---|
| AiGraphTracker |
GetTrackData()
Returns the track data included in every event fired by this tracker.
Declaration
public AiGraphTrackData GetTrackData()
Returns
| Type | Description |
|---|---|
| AiGraphTrackData |
TrackDuration(double)
Records the total duration of the graph invocation in milliseconds. At-most-once.
Declaration
public void TrackDuration(double durationMs)
Parameters
| Type | Name | Description |
|---|---|---|
| double | durationMs |
TrackHandoffFailure(string, string)
Records a failed handoff from one node to another. Multi-fire — may be called once per failed handoff that occurs.
Declaration
public void TrackHandoffFailure(string sourceKey, string targetKey)
Parameters
| Type | Name | Description |
|---|---|---|
| string | sourceKey | |
| string | targetKey |
TrackHandoffSuccess(string, string)
Records a successful handoff from one node to another. Multi-fire — may be called once per handoff that occurs.
Declaration
public void TrackHandoffSuccess(string sourceKey, string targetKey)
Parameters
| Type | Name | Description |
|---|---|---|
| string | sourceKey | |
| string | targetKey |
TrackInvocationFailure()
Records a failed graph invocation. At-most-once; shares a slot with TrackInvocationSuccess().
Declaration
public void TrackInvocationFailure()
TrackInvocationSuccess()
Records a successful graph invocation. At-most-once; shares a slot with TrackInvocationFailure().
Declaration
public void TrackInvocationSuccess()
TrackPath(IReadOnlyList<string>)
Records the path of node keys visited during graph execution. At-most-once.
Declaration
public void TrackPath(IReadOnlyList<string> path)
Parameters
| Type | Name | Description |
|---|---|---|
| IReadOnlyList<string> | path |
TrackRedirect(string, string)
Records that a node redirected execution to a different target than the configured edge. Multi-fire — may be called once per redirect that occurs.
Declaration
public void TrackRedirect(string sourceKey, string redirectedTarget)
Parameters
| Type | Name | Description |
|---|---|---|
| string | sourceKey | |
| string | redirectedTarget |
TrackTotalTokens(Usage)
Records the aggregate token usage across all nodes. At-most-once.
Declaration
public void TrackTotalTokens(Usage tokens)
Parameters
| Type | Name | Description |
|---|---|---|
| Usage | tokens |