langfuse_client/metrics
GET /api/public/v2/metrics — server-side aggregations over Langfuse
score data. Build a query with score_count_query /
score_value_query and pass it to the matching list_* function.
The Langfuse v2 metrics endpoint is BETA. This module exposes score
count + avg-value queries grouped by (name, dataType, source);
broader surface (other measures, views, dimensions) will follow the
same shape once the endpoint stabilises.
Types
Filters for list_score_counts. Build with score_count_query and
pass to list_score_counts. Window is [from_timestamp, to_timestamp)
in ISO 8601.
pub type ScoreCountQuery {
ScoreCountQuery(
view: ScoreView,
from_timestamp: String,
to_timestamp: String,
)
}
Constructors
-
ScoreCountQuery( view: ScoreView, from_timestamp: String, to_timestamp: String, )
One row of the data array: the count of scores grouped by the
(name, data_type, source) triple. count is the sum_count measure
decoded from its string representation.
pub type ScoreCountRow {
ScoreCountRow(
name: String,
data_type: String,
source: String,
count: Int,
)
}
Constructors
-
ScoreCountRow( name: String, data_type: String, source: String, count: Int, )
Filters for list_score_values. The view is implicitly numeric — the
API rejects value measure on categorical scores. Build with
score_value_query.
pub type ScoreValueQuery {
ScoreValueQuery(from_timestamp: String, to_timestamp: String)
}
Constructors
-
ScoreValueQuery(from_timestamp: String, to_timestamp: String)
One row from a score-value query: the avg value of scores grouped by
(name, data_type, source). The Langfuse API restricts the value
measure to numeric/boolean scores; categorical scores are not included.
pub type ScoreValueRow {
ScoreValueRow(
name: String,
data_type: String,
source: String,
avg_value: Float,
)
}
Constructors
-
ScoreValueRow( name: String, data_type: String, source: String, avg_value: Float, )
Values
pub fn decode(
body: String,
) -> Result(List(ScoreCountRow), json.DecodeError)
Parse a GET /api/public/v2/metrics response body for a score-count
query. Useful if you already have the raw body in hand (e.g. from a
cached/recorded response).
pub fn decode_score_values(
body: String,
) -> Result(List(ScoreValueRow), json.DecodeError)
Parse a GET /api/public/v2/metrics response body for a score-value
query.
pub fn list_score_counts(
c: client.Client,
q: ScoreCountQuery,
) -> Result(List(ScoreCountRow), client.Error)
Aggregate score counts for the query. Returns one row per distinct
(name, data_type, source) combination present in the window.
Erlang-only — see langfuse_client/client module docs.
pub fn list_score_values(
c: client.Client,
q: ScoreValueQuery,
) -> Result(List(ScoreValueRow), client.Error)
Aggregate avg score values for the query. One row per (name, data_type, source) combination over the window. Erlang-only — see
langfuse_client/client module docs.
pub fn score_count_query(
view view: ScoreView,
from from_timestamp: String,
to to_timestamp: String,
) -> ScoreCountQuery
Build a query for counts of scores grouped by (name, data_type, source) in the given window.
pub fn score_value_query(
from from_timestamp: String,
to to_timestamp: String,
) -> ScoreValueQuery
Build a query for avg score values grouped by (name, data_type, source) in the given window. Only numeric and boolean scores are
returned.