LaunchDarkly Dotnet Server AI SDK
Search Results for

    Show / Hide Table of Contents

    Interface ILdAiConfigTracker

    Records metrics for a single AI run.

    Namespace: LaunchDarkly.Sdk.Server.Ai.Interfaces
    Assembly: LaunchDarkly.ServerSdk.Ai.dll
    Syntax
    public interface ILdAiConfigTracker
    Remarks

    All events emitted by a tracker share a runId (a UUIDv4) so LaunchDarkly can correlate them. See individual track methods for their specific semantics. Call CreateTracker on the AI Config to start a new run. A ResumptionToken preserves the runId, so events emitted by a tracker reconstructed in another process correlate with the original tracker's runId.

    Properties

    | Edit this page View Source

    ResumptionToken

    A URL-safe Base64-encoded token that can be used to reconstruct this tracker in a different process or at a later time. The token contains the runId, configKey, variationKey, and version.

    Use LdAiConfigTracker.FromResumptionToken to reconstruct a tracker from this token.

    Declaration
    string ResumptionToken { get; }
    Property Value
    Type Description
    string
    | Edit this page View Source

    Summary

    A summary of the metrics tracked by this tracker.

    Declaration
    MetricSummary Summary { get; }
    Property Value
    Type Description
    MetricSummary

    Methods

    | Edit this page View Source

    TrackDuration(float)

    Tracks a duration metric related to this config. For example, if a particular operation related to usage of the AI model takes 100ms, this can be tracked and made available in LaunchDarkly.

    Declaration
    void TrackDuration(float durationMs)
    Parameters
    Type Name Description
    float durationMs

    the duration in milliseconds

    Remarks

    Records at most once per Tracker; further calls are ignored.

    | Edit this page View Source

    TrackDurationOfTask<T>(Task<T>)

    Tracks the duration of a task, and returns the result of the task.

    If the provided task throws, then this method will also throw.

    In the case the provided function throws, this function will still record the duration.

    Declaration
    Task<T> TrackDurationOfTask<T>(Task<T> task)
    Parameters
    Type Name Description
    Task<T> task

    the task

    Returns
    Type Description
    Task<T>

    the task

    Type Parameters
    Name Description
    T

    type of the task's result

    | Edit this page View Source

    TrackError()

    Tracks an unsuccessful generation event related to this config.

    Declaration
    void TrackError()
    Remarks

    Records at most once per Tracker. TrackSuccess and TrackError share state; only one of the two can record per Tracker, and subsequent calls are ignored.

    | Edit this page View Source

    TrackFeedback(Feedback)

    Tracks feedback (positive or negative) related to the output of the model.

    Declaration
    void TrackFeedback(Feedback feedback)
    Parameters
    Type Name Description
    Feedback feedback

    the feedback

    Remarks

    Records at most once per Tracker; further calls are ignored.

    Exceptions
    Type Condition
    ArgumentOutOfRangeException

    thrown if the feedback value is not Positive or Negative

    | Edit this page View Source

    TrackRequest(Task<Response>)

    Tracks a request to a provider. The request is a task that returns a Response, which contains information about the request such as token usage and metrics.

    This function will track the duration of the operation, the token usage, and the success or error status.

    If the provided function throws, then this method will also throw.

    In the case the provided function throws, this function will record the duration and an error.

    A failed operation will not have any token usage data.

    It is the responsibility of the caller to fill in the Response object with any details that should be tracked.

    Example:

    var response = tracker.TrackRequest(Task.Run(() => new Response {
        // 1. Make a request to the AI provider
        // 2. Identify relevant statistics returned in the response
        // 3. Return a Response object containing the relevant statistics
        Usage = new Usage { Total = 1, Input = 1, Output = 1 },
        Metrics = new Metrics { LatencyMs = 100 }
    }));

    If no latency statistic is explicitly returned in the Response, then the duration of the Task is automatically measured and recorded as the latency metric associated with this request.

    Declaration
    Task<Response> TrackRequest(Task<Response> request)
    Parameters
    Type Name Description
    Task<Response> request

    a task representing the request

    Returns
    Type Description
    Task<Response>

    the task

    Remarks

    Subsequent calls re-run the task but emit only metrics not already recorded on this Tracker. Call CreateTracker on the AI Config to start a new run.

    | Edit this page View Source

    TrackSuccess()

    Tracks a generation event related to this config.

    Declaration
    void TrackSuccess()
    Remarks

    Records at most once per Tracker. TrackSuccess and TrackError share state; only one of the two can record per Tracker, and subsequent calls are ignored.

    | Edit this page View Source

    TrackTimeToFirstToken(float)

    Tracks the time it takes for the first token to be generated.

    Declaration
    void TrackTimeToFirstToken(float timeToFirstTokenMs)
    Parameters
    Type Name Description
    float timeToFirstTokenMs

    the duration in milliseconds

    Remarks

    Records at most once per Tracker; further calls are ignored.

    | Edit this page View Source

    TrackTokens(Usage)

    Tracks token usage related to this config.

    Declaration
    void TrackTokens(Usage usage)
    Parameters
    Type Name Description
    Usage usage

    the token usage

    Remarks

    Records at most once per Tracker; further calls are ignored.

    Extension Methods

    PluginExtensions.GetPluginHooks<TClient, THook>(TClient, IEnumerable<PluginBase<TClient, THook>>, EnvironmentMetadata, Logger)
    PluginExtensions.GetPluginHooks<TClient, THook>(TClient, IEnumerable<PluginBase<TClient, THook>>, EnvironmentMetadata, Logger)
    PluginExtensions.GetPluginHooks<TClient, THook>(TClient, IEnumerable<PluginBase<TClient, THook>>, EnvironmentMetadata, Logger)
    PluginExtensions.GetPluginHooks<TClient, THook>(TClient, IEnumerable<PluginBase<TClient, THook>>, EnvironmentMetadata, Logger)
    PluginExtensions.GetPluginHooks<TClient, THook>(TClient, IEnumerable<PluginBase<TClient, THook>>, EnvironmentMetadata, Logger)
    PluginExtensions.GetPluginHooks<TClient, THook>(TClient, IEnumerable<PluginBase<TClient, THook>>, EnvironmentMetadata, Logger)
    PluginExtensions.GetPluginHooks<TClient, THook>(TClient, IEnumerable<PluginBase<TClient, THook>>, EnvironmentMetadata, Logger)
    PluginExtensions.RegisterPlugins<TClient, THook>(TClient, IEnumerable<PluginBase<TClient, THook>>, EnvironmentMetadata, Logger)
    PluginExtensions.RegisterPlugins<TClient, THook>(TClient, IEnumerable<PluginBase<TClient, THook>>, EnvironmentMetadata, Logger)
    PluginExtensions.RegisterPlugins<TClient, THook>(TClient, IEnumerable<PluginBase<TClient, THook>>, EnvironmentMetadata, Logger)
    PluginExtensions.RegisterPlugins<TClient, THook>(TClient, IEnumerable<PluginBase<TClient, THook>>, EnvironmentMetadata, Logger)
    PluginExtensions.RegisterPlugins<TClient, THook>(TClient, IEnumerable<PluginBase<TClient, THook>>, EnvironmentMetadata, Logger)
    PluginExtensions.RegisterPlugins<TClient, THook>(TClient, IEnumerable<PluginBase<TClient, THook>>, EnvironmentMetadata, Logger)
    PluginExtensions.RegisterPlugins<TClient, THook>(TClient, IEnumerable<PluginBase<TClient, THook>>, EnvironmentMetadata, Logger)
    • Edit this page
    • View Source
    In this article
    Back to top Generated by DocFX