Skip to content

🪢 Open source agent evals & observability: Trace, evaluate, and improve LLM applications with one open platform.

chore: bump metrics-api rate limits and deprecate daily metrics (#6950)

Steffen Schmitzb69f0bda9da6
diff --git a/fern/apis/server/definition/metrics.yml b/fern/apis/server/definition/metrics.yml
index 0ce627b233..6e9098d965 100644
--- a/fern/apis/server/definition/metrics.yml
+++ b/fern/apis/server/definition/metrics.yml
@@ -54,40 +54,6 @@ service:
}
```
response: MetricsResponse
- daily:
- docs: Get daily metrics of the Langfuse project
- method: GET
- path: /metrics/daily
- request:
- name: GetDailyMetricsRequest
- query-parameters:
- page:
- type: optional<integer>
- docs: page number, starts at 1
- limit:
- type: optional<integer>
- docs: limit of items per page
- traceName:
- type: optional<string>
- docs: Optional filter by the name of the trace
- userId:
- type: optional<string>
- docs: Optional filter by the userId associated with the trace
- tags:
- type: optional<string>
- allow-multiple: true
- docs: Optional filter for metrics where traces include all of these tags
- environment:
- type: optional<string>
- allow-multiple: true
- docs: Optional filter for metrics where events include any of these environments
- fromTimestamp:
- type: optional<datetime>
- docs: Optional filter to only include traces and observations on or after a certain datetime (ISO 8601)
- toTimestamp:
- type: optional<datetime>
- docs: Optional filter to only include traces and observations before a certain datetime (ISO 8601)
- response: DailyMetrics
types:
MetricsResponse:
properties:
@@ -96,36 +62,3 @@ types:
docs: |
The metrics data. Each item in the list contains the metric values and dimensions requested in the query.
Format varies based on the query parameters.
- DailyMetrics:
- properties:
- data:
- type: list<DailyMetricsDetails>
- docs: A list of daily metrics, only days with ingested data are included.
- meta: pagination.MetaResponse
- DailyMetricsDetails:
- properties:
- date: date
- countTraces: integer
- countObservations: integer
- totalCost:
- type: double
- docs: Total model cost in USD
- usage: list<UsageByModel>
- UsageByModel:
- docs: Daily usage of a given model. Usage corresponds to the unit set for the specific model (e.g. tokens).
- properties:
- model: optional<string>
- inputUsage:
- type: integer
- docs: Total number of generation input units (e.g. tokens)
- outputUsage:
- type: integer
- docs: Total number of generation output units (e.g. tokens)
- totalUsage:
- type: integer
- docs: Total number of generation total units (e.g. tokens)
- countTraces: integer
- countObservations: integer
- totalCost:
- type: double
- docs: Total model cost in USD
diff --git a/packages/shared/src/interfaces/rate-limits.ts b/packages/shared/src/interfaces/rate-limits.ts
index 9e023d6e68..de35d76aa7 100644
--- a/packages/shared/src/interfaces/rate-limits.ts
+++ b/packages/shared/src/interfaces/rate-limits.ts
@@ -5,6 +5,7 @@ export const RateLimitResource = z.enum([
"ingestion",
"public-api",
"public-api-metrics",
+ "public-api-daily-metrics-legacy",
"prompts",
"legacy-ingestion",
"datasets",
diff --git a/web/public/generated/api/openapi.yml b/web/public/generated/api/openapi.yml
index 89f8ebe213..c1d6cb690e 100644
--- a/web/public/generated/api/openapi.yml
+++ b/web/public/generated/api/openapi.yml
@@ -1845,115 +1845,6 @@ paths:
schema: {}
security:
- BasicAuth: []
- /api/public/metrics/daily:
- get:
- description: Get daily metrics of the Langfuse project
- operationId: metrics_daily
- tags:
- - Metrics
- parameters:
- - name: page
- in: query
- description: page number, starts at 1
- required: false
- schema:
- type: integer
- nullable: true
- - name: limit
- in: query
- description: limit of items per page
- required: false
- schema:
- type: integer
- nullable: true
- - name: traceName
- in: query
- description: Optional filter by the name of the trace
- required: false
- schema:
- type: string
- nullable: true
- - name: userId
- in: query
- description: Optional filter by the userId associated with the trace
- required: false
- schema:
- type: string
- nullable: true
- - name: tags
- in: query
- description: Optional filter for metrics where traces include all of these tags
- required: false
- schema:
- type: array
- items:
- type: string
- nullable: true
- - name: environment
- in: query
- description: >-
- Optional filter for metrics where events include any of these
- environments
- required: false
- schema:
- type: array
- items:
- type: string
- nullable: true
- - name: fromTimestamp
- in: query
- description: >-
- Optional filter to only include traces and observations on or after
- a certain datetime (ISO 8601)
- required: false
- schema:
- type: string
- format: date-time
- nullable: true
- - name: toTimestamp
- in: query
- description: >-
- Optional filter to only include traces and observations before a
- certain datetime (ISO 8601)
- required: false
- schema:
- type: string
- format: date-time
- nullable: true
- responses:
- '200':
- description: ''
- content:
- application/json:
- schema:
- $ref: '#/components/schemas/DailyMetrics'
- '400':
- description: ''
- content:
- application/json:
- schema: {}
- '401':
- description: ''
- content:
- application/json:
- schema: {}
- '403':
- description: ''
- content:
- application/json:
- schema: {}
- '404':
- description: ''
- content:
- application/json:
- schema: {}
- '405':
- description: ''
- content:
- application/json:
- schema: {}
- security:
- - BasicAuth: []
/api/public/models:
post:
description: Create a model
@@ -6448,79 +6339,6 @@ components:
Format varies based on the query parameters.
required:
- data
- DailyMetrics:
- title: DailyMetrics
- type: object
- properties:
- data:
- type: array
- items:
- $ref: '#/components/schemas/DailyMetricsDetails'
- description: A list of daily metrics, only days with ingested data are included.
- meta:
- $ref: '#/components/schemas/utilsMetaResponse'
- required:
- - data
- - meta
- DailyMetricsDetails:
- title: DailyMetricsDetails
- type: object
- properties:
- date:
- type: string
- format: date
- countTraces:
- type: integer
- countObservations:
- type: integer
- totalCost:
- type: number
- format: double
- description: Total model cost in USD
- usage:
- type: array
- items:
- $ref: '#/components/schemas/UsageByModel'
- required:
- - date
- - countTraces
- - countObservations
- - totalCost
- - usage
- UsageByModel:
- title: UsageByModel
- type: object
- description: >-
- Daily usage of a given model. Usage corresponds to the unit set for the
- specific model (e.g. tokens).
- properties:
- model:
- type: string
- nullable: true
- inputUsage:
- type: integer
- description: Total number of generation input units (e.g. tokens)
- outputUsage:
- type: integer
- description: Total number of generation output units (e.g. tokens)
- totalUsage:
- type: integer
- description: Total number of generation total units (e.g. tokens)
- countTraces:
- type: integer
- countObservations:
- type: integer
- totalCost:
- type: number
- format: double
- description: Total model cost in USD
- required:
- - inputUsage
- - outputUsage
- - totalUsage
- - countTraces
- - countObservations
- - totalCost
PaginatedModels:
title: PaginatedModels
type: object
diff --git a/web/public/generated/postman/collection.json b/web/public/generated/postman/collection.json
index d145c876dc..153dc20841 100644
--- a/web/public/generated/postman/collection.json
+++ b/web/public/generated/postman/collection.json
@@ -1422,73 +1422,6 @@
"body": null
},
"response": []
- },
- {
- "_type": "endpoint",
- "name": "Daily",
- "request": {
- "description": "Get daily metrics of the Langfuse project",
- "url": {
- "raw": "{{baseUrl}}/api/public/metrics/daily?page=&limit=&traceName=&userId=&tags=&environment=&fromTimestamp=&toTimestamp=",
- "host": [
- "{{baseUrl}}"
- ],
- "path": [
- "api",
- "public",
- "metrics",
- "daily"
- ],
- "query": [
- {
- "key": "page",
- "value": "",
- "description": "page number, starts at 1"
- },
- {
- "key": "limit",
- "value": "",
- "description": "limit of items per page"
- },
- {
- "key": "traceName",
- "value": "",
- "description": "Optional filter by the name of the trace"
- },
- {
- "key": "userId",
- "value": "",
- "description": "Optional filter by the userId associated with the trace"
- },
- {
- "key": "tags",
- "value": "",
- "description": "Optional filter for metrics where traces include all of these tags"
- },
- {
- "key": "environment",
- "value": "",
- "description": "Optional filter for metrics where events include any of these environments"
- },
- {
- "key": "fromTimestamp",
- "value": "",
- "description": "Optional filter to only include traces and observations on or after a certain datetime (ISO 8601)"
- },
- {
- "key": "toTimestamp",
- "value": "",
- "description": "Optional filter to only include traces and observations before a certain datetime (ISO 8601)"
- }
- ],
- "variable": []
- },
- "header": [],
- "method": "GET",
- "auth": null,
- "body": null
- },
- "response": []
}
]
},
diff --git a/web/src/__tests__/queryBuilder.servertest.ts b/web/src/__tests__/queryBuilder.servertest.ts
index 8895d08ef1..bcac620284 100644
--- a/web/src/__tests__/queryBuilder.servertest.ts
+++ b/web/src/__tests__/queryBuilder.servertest.ts
@@ -3266,7 +3266,6 @@ describe("queryBuilder", () => {
expect(row.sum_inputTokens).toBe("300");
expect(row.sum_outputTokens).toBe("700");
expect(row.sum_totalTokens).toBe("1000");
- expect(row.avg_outputTokensPerSecond).toBe(700);
});
it("should filter observations by metadata correctly", async () => {
diff --git a/web/src/features/public-api/server/RateLimitService.ts b/web/src/features/public-api/server/RateLimitService.ts
index a3e925ba6a..a04e1e562d 100644
--- a/web/src/features/public-api/server/RateLimitService.ts
+++ b/web/src/features/public-api/server/RateLimitService.ts
@@ -255,6 +255,12 @@ const getPlanBasedRateLimitConfig = (
case "public-api-metrics":
return {
resource: "public-api-metrics",
+ points: 100,
+ durationInSec: 86400, // 100 requests per day
+ };
+ case "public-api-daily-metrics-legacy":
+ return {
+ resource: "public-api-daily-metrics-legacy",
points: 10,
durationInSec: 86400, // 10 requests per day
};
@@ -297,6 +303,12 @@ const getPlanBasedRateLimitConfig = (
case "public-api-metrics":
return {
resource: "public-api-metrics",
+ points: 200,
+ durationInSec: 86400, // 200 requests per day
+ };
+ case "public-api-daily-metrics-legacy":
+ return {
+ resource: "public-api-daily-metrics-legacy",
points: 20,
durationInSec: 86400, // 20 requests per day
};
@@ -341,6 +353,12 @@ const getPlanBasedRateLimitConfig = (
case "public-api-metrics":
return {
resource: "public-api-metrics",
+ points: 2000,
+ durationInSec: 86400, // 2000 requests per day
+ };
+ case "public-api-daily-metrics-legacy":
+ return {
+ resource: "public-api-daily-metrics-legacy",
points: 200,
durationInSec: 86400, // 200 requests per day
};
diff --git a/web/src/pages/api/public/metrics/daily.ts b/web/src/pages/api/public/metrics/daily.ts
index f4082d6fa8..c2a430e9b3 100644
--- a/web/src/pages/api/public/metrics/daily.ts
+++ b/web/src/pages/api/public/metrics/daily.ts
@@ -14,7 +14,7 @@ export default withMiddlewares({
name: "Get Daily Metrics",
querySchema: GetMetricsDailyV1Query,
responseSchema: GetMetricsDailyV1Response,
- rateLimitResource: "public-api-metrics",
+ rateLimitResource: "public-api-daily-metrics-legacy",
fn: async ({ query, auth }) => {
const filterProps = {
projectId: auth.scope.projectId,