Class GetMetricsV2Request.Builder

java.lang.Object
com.langfuse.client.resources.metricsv2.requests.GetMetricsV2Request.Builder
All Implemented Interfaces:
GetMetricsV2Request._FinalStage, GetMetricsV2Request.QueryStage
Enclosing class:
GetMetricsV2Request

public static final class GetMetricsV2Request.Builder extends Object implements GetMetricsV2Request.QueryStage, GetMetricsV2Request._FinalStage
  • Method Details

    • from

      Specified by:
      from in interface GetMetricsV2Request.QueryStage
    • query

      public GetMetricsV2Request._FinalStage query(@NotNull String query)

      JSON string containing the query parameters with the following structure:

      {
         "view": string,           // Required. One of "observations", "scores-numeric", "scores-categorical"
         "dimensions": [           // Optional. Default: []
           {
             "field": string       // Field to group by (see available dimensions above)
           }
         ],
         "metrics": [              // Required. At least one metric must be provided
           {
             "measure": string,    // What to measure (see available measures above)
             "aggregation": string // How to aggregate: "sum", "avg", "count", "max", "min", "p50", "p75", "p90", "p95", "p99", "histogram"
           }
         ],
         "filters": [              // Optional. Default: []
           {
             "column": string,     // Column to filter on (any dimension field)
             "operator": string,   // Operator based on type:
                                   // - datetime: ">", "<", ">=", "<="
                                   // - string: "=", "contains", "does not contain", "starts with", "ends with"
                                   // - stringOptions: "any of", "none of"
                                   // - arrayOptions: "any of", "none of", "all of"
                                   // - number: "=", ">", "<", ">=", "<="
                                   // - stringObject/numberObject: same as string/number with required "key"
                                   // - boolean: "=", "<>"
                                   // - null: "is null", "is not null"
             "value": any,         // Value to compare against
             "type": string,       // Data type: "datetime", "string", "number", "stringOptions", "categoryOptions", "arrayOptions", "stringObject", "numberObject", "boolean", "null"
             "key": string         // Required only for stringObject/numberObject types (e.g., metadata filtering)
           }
         ],
         "timeDimension": {        // Optional. Default: null. If provided, results will be grouped by time
           "granularity": string   // One of "auto", "minute", "hour", "day", "week", "month"
         },
         "fromTimestamp": string,  // Required. ISO datetime string for start of time range
         "toTimestamp": string,    // Required. ISO datetime string for end of time range (must be after fromTimestamp)
         "orderBy": [              // Optional. Default: null
           {
             "field": string,      // Field to order by (dimension or metric alias)
             "direction": string   // "asc" or "desc"
           }
         ],
         "config": {               // Optional. Query-specific configuration
           "bins": number,         // Optional. Number of bins for histogram aggregation (1-100), default: 10
           "row_limit": number     // Optional. Maximum number of rows to return (1-1000), default: 100
         }
       }
       

      JSON string containing the query parameters with the following structure:

      {
         "view": string,           // Required. One of "observations", "scores-numeric", "scores-categorical"
         "dimensions": [           // Optional. Default: []
           {
             "field": string       // Field to group by (see available dimensions above)
           }
         ],
         "metrics": [              // Required. At least one metric must be provided
           {
             "measure": string,    // What to measure (see available measures above)
             "aggregation": string // How to aggregate: "sum", "avg", "count", "max", "min", "p50", "p75", "p90", "p95", "p99", "histogram"
           }
         ],
         "filters": [              // Optional. Default: []
           {
             "column": string,     // Column to filter on (any dimension field)
             "operator": string,   // Operator based on type:
                                   // - datetime: ">", "<", ">=", "<="
                                   // - string: "=", "contains", "does not contain", "starts with", "ends with"
                                   // - stringOptions: "any of", "none of"
                                   // - arrayOptions: "any of", "none of", "all of"
                                   // - number: "=", ">", "<", ">=", "<="
                                   // - stringObject/numberObject: same as string/number with required "key"
                                   // - boolean: "=", "<>"
                                   // - null: "is null", "is not null"
             "value": any,         // Value to compare against
             "type": string,       // Data type: "datetime", "string", "number", "stringOptions", "categoryOptions", "arrayOptions", "stringObject", "numberObject", "boolean", "null"
             "key": string         // Required only for stringObject/numberObject types (e.g., metadata filtering)
           }
         ],
         "timeDimension": {        // Optional. Default: null. If provided, results will be grouped by time
           "granularity": string   // One of "auto", "minute", "hour", "day", "week", "month"
         },
         "fromTimestamp": string,  // Required. ISO datetime string for start of time range
         "toTimestamp": string,    // Required. ISO datetime string for end of time range (must be after fromTimestamp)
         "orderBy": [              // Optional. Default: null
           {
             "field": string,      // Field to order by (dimension or metric alias)
             "direction": string   // "asc" or "desc"
           }
         ],
         "config": {               // Optional. Query-specific configuration
           "bins": number,         // Optional. Number of bins for histogram aggregation (1-100), default: 10
           "row_limit": number     // Optional. Maximum number of rows to return (1-1000), default: 100
         }
       }
       
      Specified by:
      query in interface GetMetricsV2Request.QueryStage
      Returns:
      Reference to this so that method calls can be chained together.
    • build

      public GetMetricsV2Request build()
      Specified by:
      build in interface GetMetricsV2Request._FinalStage
    • additionalProperty

      public GetMetricsV2Request.Builder additionalProperty(String key, Object value)
      Specified by:
      additionalProperty in interface GetMetricsV2Request._FinalStage
    • additionalProperties

      public GetMetricsV2Request.Builder additionalProperties(Map<String,Object> additionalProperties)
      Specified by:
      additionalProperties in interface GetMetricsV2Request._FinalStage