Skip to content

ILangfuseScoreClient

NexusLabs.Foundry.Langfuse

ILangfuseScoreClient Interface

Records Langfuse scores against a known trace id. Registered in dependency injection by AddFoundryLangfuse(this IServiceCollection) for ASP.NET Core and generic-host applications that score their own request traces.

public interface ILangfuseScoreClient

Remarks

In a host application the OTLP exporter assigns each operation an OpenTelemetry trace id (Activity.Current?.TraceId). Pass that id here to attach evaluation scores to the corresponding Langfuse trace. When creating a new trace, prefer BeginScenario(string, string, string, IEnumerable<string>, IReadOnlyDictionary<string,string>), which manages the trace for you.

Properties

ILangfuseScoreClient.IsEnabled Property

Gets a value indicating whether scores are being sent. false when Langfuse was not configured, in which case all record calls are no-ops.

bool IsEnabled { get; }

Property Value

System.Boolean

Methods

ILangfuseScoreClient.RecordEvaluationAsync(string, EvaluationResult) Method

Projects every metric in result to a Langfuse score against traceId, using the same mapping as RecordEvaluationAsync(EvaluationResult).

System.Threading.Tasks.Task RecordEvaluationAsync(string traceId, Microsoft.Extensions.AI.Evaluation.EvaluationResult result);

Parameters

traceId System.String

The Langfuse/OpenTelemetry trace id to attach the scores to.

result Microsoft.Extensions.AI.Evaluation.EvaluationResult

The evaluation result to project.

Returns

System.Threading.Tasks.Task
A task that completes when Langfuse has accepted all projected scores.

ILangfuseScoreClient.RecordEvaluationAsync(string, EvaluationResult, LangfuseEvaluationScoreOptions, CancellationToken) Method

Projects every metric in result to a Langfuse score against traceId, using the same mapping as RecordEvaluationAsync(EvaluationResult, LangfuseEvaluationScoreOptions, CancellationToken).

System.Threading.Tasks.Task RecordEvaluationAsync(string traceId, Microsoft.Extensions.AI.Evaluation.EvaluationResult result, NexusLabs.Foundry.Langfuse.LangfuseEvaluationScoreOptions? options, System.Threading.CancellationToken cancellationToken);

Parameters

traceId System.String

The Langfuse/OpenTelemetry trace id to attach the scores to.

result Microsoft.Extensions.AI.Evaluation.EvaluationResult

The evaluation result to project.

options LangfuseEvaluationScoreOptions

Stable identity settings for projected metric scores, or null.

cancellationToken System.Threading.CancellationToken

A cancellation token.

Returns

System.Threading.Tasks.Task
A task that completes when Langfuse has accepted all projected scores.

ILangfuseScoreClient.RecordObservationScoreAsync(string, string, string, bool) Method

Records a boolean score (stored as 1/0) against a specific observation.

System.Threading.Tasks.Task RecordObservationScoreAsync(string traceId, string observationId, string name, bool value);

Parameters

traceId System.String

The owning trace id.

observationId System.String

The observation id to attach the score to.

name System.String

The score name.

value System.Boolean

The boolean value.

Returns

System.Threading.Tasks.Task
A task that completes when Langfuse has accepted the score.

ILangfuseScoreClient.RecordObservationScoreAsync(string, string, string, bool, LangfuseScoreOptions, CancellationToken) Method

Records a boolean score (stored as 1/0) against a specific observation.

System.Threading.Tasks.Task RecordObservationScoreAsync(string traceId, string observationId, string name, bool value, NexusLabs.Foundry.Langfuse.LangfuseScoreOptions? options, System.Threading.CancellationToken cancellationToken);

Parameters

traceId System.String

The owning trace id.

observationId System.String

The observation id to attach the score to.

name System.String

The score name.

value System.Boolean

The boolean value.

options LangfuseScoreOptions

Score identity and comment settings, or null.

cancellationToken System.Threading.CancellationToken

A cancellation token.

Returns

System.Threading.Tasks.Task
A task that completes when Langfuse has accepted the score.

ILangfuseScoreClient.RecordObservationScoreAsync(string, string, string, double) Method

Records a numeric score against a specific observation within a trace.

System.Threading.Tasks.Task RecordObservationScoreAsync(string traceId, string observationId, string name, double value);

Parameters

traceId System.String

The owning trace id.

observationId System.String

The observation (span/generation) id to attach the score to.

name System.String

The score name.

value System.Double

The numeric value.

Returns

System.Threading.Tasks.Task
A task that completes when Langfuse has accepted the score.

ILangfuseScoreClient.RecordObservationScoreAsync(string, string, string, double, LangfuseScoreOptions, CancellationToken) Method

Records a numeric score against a specific observation within a trace.

System.Threading.Tasks.Task RecordObservationScoreAsync(string traceId, string observationId, string name, double value, NexusLabs.Foundry.Langfuse.LangfuseScoreOptions? options, System.Threading.CancellationToken cancellationToken);

Parameters

traceId System.String

The owning trace id.

observationId System.String

The observation (span/generation) id to attach the score to.

name System.String

The score name.

value System.Double

The numeric value.

options LangfuseScoreOptions

Score identity and comment settings, or null.

cancellationToken System.Threading.CancellationToken

A cancellation token.

Returns

System.Threading.Tasks.Task
A task that completes when Langfuse has accepted the score.

ILangfuseScoreClient.RecordObservationScoreAsync(string, string, string, string) Method

Records a categorical score against a specific observation.

System.Threading.Tasks.Task RecordObservationScoreAsync(string traceId, string observationId, string name, string value);

Parameters

traceId System.String

The owning trace id.

observationId System.String

The observation id to attach the score to.

name System.String

The score name.

value System.String

The category label.

Returns

System.Threading.Tasks.Task
A task that completes when Langfuse has accepted the score.

ILangfuseScoreClient.RecordObservationScoreAsync(string, string, string, string, LangfuseScoreOptions, CancellationToken) Method

Records a categorical score against a specific observation.

System.Threading.Tasks.Task RecordObservationScoreAsync(string traceId, string observationId, string name, string value, NexusLabs.Foundry.Langfuse.LangfuseScoreOptions? options, System.Threading.CancellationToken cancellationToken);

Parameters

traceId System.String

The owning trace id.

observationId System.String

The observation id to attach the score to.

name System.String

The score name.

value System.String

The category label.

options LangfuseScoreOptions

Score identity and comment settings, or null.

cancellationToken System.Threading.CancellationToken

A cancellation token.

Returns

System.Threading.Tasks.Task
A task that completes when Langfuse has accepted the score.

ILangfuseScoreClient.RecordScoreAsync(string, string, bool) Method

Records a boolean score (stored as 1/0) against traceId.

System.Threading.Tasks.Task RecordScoreAsync(string traceId, string name, bool value);

Parameters

traceId System.String

The Langfuse/OpenTelemetry trace id to attach the score to.

name System.String

The score name.

value System.Boolean

The boolean value.

Returns

System.Threading.Tasks.Task
A task that completes when Langfuse has accepted the score.

ILangfuseScoreClient.RecordScoreAsync(string, string, bool, LangfuseScoreOptions, CancellationToken) Method

Records a boolean score (stored as 1/0) against traceId.

System.Threading.Tasks.Task RecordScoreAsync(string traceId, string name, bool value, NexusLabs.Foundry.Langfuse.LangfuseScoreOptions? options, System.Threading.CancellationToken cancellationToken);

Parameters

traceId System.String

The Langfuse/OpenTelemetry trace id to attach the score to.

name System.String

The score name.

value System.Boolean

The boolean value.

options LangfuseScoreOptions

Score identity and comment settings, or null.

cancellationToken System.Threading.CancellationToken

A cancellation token.

Returns

System.Threading.Tasks.Task
A task that completes when Langfuse has accepted the score.

ILangfuseScoreClient.RecordScoreAsync(string, string, double) Method

Records a numeric score against traceId.

System.Threading.Tasks.Task RecordScoreAsync(string traceId, string name, double value);

Parameters

traceId System.String

The Langfuse/OpenTelemetry trace id to attach the score to.

name System.String

The score name.

value System.Double

The numeric value.

Returns

System.Threading.Tasks.Task
A task that completes when Langfuse has accepted the score.

ILangfuseScoreClient.RecordScoreAsync(string, string, double, LangfuseScoreOptions, CancellationToken) Method

Records a numeric score against traceId.

System.Threading.Tasks.Task RecordScoreAsync(string traceId, string name, double value, NexusLabs.Foundry.Langfuse.LangfuseScoreOptions? options, System.Threading.CancellationToken cancellationToken);

Parameters

traceId System.String

The Langfuse/OpenTelemetry trace id to attach the score to.

name System.String

The score name.

value System.Double

The numeric value.

options LangfuseScoreOptions

Score identity and comment settings, or null.

cancellationToken System.Threading.CancellationToken

A cancellation token.

Returns

System.Threading.Tasks.Task
A task that completes when Langfuse has accepted the score.

ILangfuseScoreClient.RecordScoreAsync(string, string, string) Method

Records a categorical score against traceId.

System.Threading.Tasks.Task RecordScoreAsync(string traceId, string name, string value);

Parameters

traceId System.String

The Langfuse/OpenTelemetry trace id to attach the score to.

name System.String

The score name.

value System.String

The category label.

Returns

System.Threading.Tasks.Task
A task that completes when Langfuse has accepted the score.

ILangfuseScoreClient.RecordScoreAsync(string, string, string, LangfuseScoreOptions, CancellationToken) Method

Records a categorical score against traceId.

System.Threading.Tasks.Task RecordScoreAsync(string traceId, string name, string value, NexusLabs.Foundry.Langfuse.LangfuseScoreOptions? options, System.Threading.CancellationToken cancellationToken);

Parameters

traceId System.String

The Langfuse/OpenTelemetry trace id to attach the score to.

name System.String

The score name.

value System.String

The category label.

options LangfuseScoreOptions

Score identity and comment settings, or null.

cancellationToken System.Threading.CancellationToken

A cancellation token.

Returns

System.Threading.Tasks.Task
A task that completes when Langfuse has accepted the score.

ILangfuseScoreClient.RecordSessionScoreAsync(string, string, bool) Method

Records a boolean session score (stored as 1/0).

System.Threading.Tasks.Task RecordSessionScoreAsync(string sessionId, string name, bool value);

Parameters

sessionId System.String

The session id to attach the score to.

name System.String

The score name.

value System.Boolean

The boolean value.

Returns

System.Threading.Tasks.Task
A task that completes when Langfuse has accepted the score.

ILangfuseScoreClient.RecordSessionScoreAsync(string, string, bool, LangfuseScoreOptions, CancellationToken) Method

Records a boolean session score (stored as 1/0).

System.Threading.Tasks.Task RecordSessionScoreAsync(string sessionId, string name, bool value, NexusLabs.Foundry.Langfuse.LangfuseScoreOptions? options, System.Threading.CancellationToken cancellationToken);

Parameters

sessionId System.String

The session id to attach the score to.

name System.String

The score name.

value System.Boolean

The boolean value.

options LangfuseScoreOptions

Score identity and comment settings, or null.

cancellationToken System.Threading.CancellationToken

A cancellation token.

Returns

System.Threading.Tasks.Task
A task that completes when Langfuse has accepted the score.

ILangfuseScoreClient.RecordSessionScoreAsync(string, string, double) Method

Records a numeric score against a whole session (across its traces).

System.Threading.Tasks.Task RecordSessionScoreAsync(string sessionId, string name, double value);

Parameters

sessionId System.String

The session id to attach the score to.

name System.String

The score name.

value System.Double

The numeric value.

Returns

System.Threading.Tasks.Task
A task that completes when Langfuse has accepted the score.

ILangfuseScoreClient.RecordSessionScoreAsync(string, string, double, LangfuseScoreOptions, CancellationToken) Method

Records a numeric score against a whole session (across its traces).

System.Threading.Tasks.Task RecordSessionScoreAsync(string sessionId, string name, double value, NexusLabs.Foundry.Langfuse.LangfuseScoreOptions? options, System.Threading.CancellationToken cancellationToken);

Parameters

sessionId System.String

The session id to attach the score to.

name System.String

The score name.

value System.Double

The numeric value.

options LangfuseScoreOptions

Score identity and comment settings, or null.

cancellationToken System.Threading.CancellationToken

A cancellation token.

Returns

System.Threading.Tasks.Task
A task that completes when Langfuse has accepted the score.

ILangfuseScoreClient.RecordSessionScoreAsync(string, string, string) Method

Records a categorical session score.

System.Threading.Tasks.Task RecordSessionScoreAsync(string sessionId, string name, string value);

Parameters

sessionId System.String

The session id to attach the score to.

name System.String

The score name.

value System.String

The category label.

Returns

System.Threading.Tasks.Task
A task that completes when Langfuse has accepted the score.

ILangfuseScoreClient.RecordSessionScoreAsync(string, string, string, LangfuseScoreOptions, CancellationToken) Method

Records a categorical session score.

System.Threading.Tasks.Task RecordSessionScoreAsync(string sessionId, string name, string value, NexusLabs.Foundry.Langfuse.LangfuseScoreOptions? options, System.Threading.CancellationToken cancellationToken);

Parameters

sessionId System.String

The session id to attach the score to.

name System.String

The score name.

value System.String

The category label.

options LangfuseScoreOptions

Score identity and comment settings, or null.

cancellationToken System.Threading.CancellationToken

A cancellation token.

Returns

System.Threading.Tasks.Task
A task that completes when Langfuse has accepted the score.