Skip to content

ILangfuseMetricsClient

NexusLabs.Needlr.AgentFramework.Langfuse

ILangfuseMetricsClient Interface

Reads aggregates back from Langfuse via the Metrics API, so recorded eval scores (and observation metrics) can drive CI quality gates and dashboards from Langfuse as the source of truth.

public interface ILangfuseMetricsClient

Properties

ILangfuseMetricsClient.IsEnabled Property

Gets a value indicating whether metric queries are performed. false when Langfuse is not configured, in which case queries return empty results.

bool IsEnabled { get; }

Property Value

System.Boolean

Methods

ILangfuseMetricsClient.GetScoreAverageAsync(string, DateTimeOffset, DateTimeOffset, string, CancellationToken) Method

Convenience over QueryAsync(LangfuseMetricsQuery, CancellationToken): the average of a numeric score over a time window, optionally scoped to an environment. Returns null when there is no matching data (or Langfuse is not configured).

System.Threading.Tasks.Task<System.Nullable<double>> GetScoreAverageAsync(string scoreName, System.DateTimeOffset fromTimestamp, System.DateTimeOffset toTimestamp, string? environment=null, System.Threading.CancellationToken cancellationToken=default(System.Threading.CancellationToken));

Parameters

scoreName System.String

The score name to average.

fromTimestamp System.DateTimeOffset

The inclusive start of the window.

toTimestamp System.DateTimeOffset

The exclusive end of the window.

environment System.String

An optional environment to filter by.

cancellationToken System.Threading.CancellationToken

A cancellation token.

Returns

System.Threading.Tasks.Task<System.Nullable<System.Double>>
The average score value, or null.

ILangfuseMetricsClient.QueryAsync(LangfuseMetricsQuery, CancellationToken) Method

Runs a metrics query and returns the result rows.

System.Threading.Tasks.Task<NexusLabs.Needlr.AgentFramework.Langfuse.LangfuseMetricsResult> QueryAsync(NexusLabs.Needlr.AgentFramework.Langfuse.LangfuseMetricsQuery query, System.Threading.CancellationToken cancellationToken=default(System.Threading.CancellationToken));

Parameters

query LangfuseMetricsQuery

The query to run.

cancellationToken System.Threading.CancellationToken

A cancellation token.

Returns

System.Threading.Tasks.Task<LangfuseMetricsResult>
The query result (empty when disabled).