feat(api): update API spec from langfuse/langfuse 2eaf041#1556
Open
langfuse-bot wants to merge 2 commits intomainfrom
Open
feat(api): update API spec from langfuse/langfuse 2eaf041#1556langfuse-bot wants to merge 2 commits intomainfrom
langfuse-bot wants to merge 2 commits intomainfrom
Conversation
Comment on lines
184
to
188
|
|
||
| Returns | ||
| ------- | ||
| HttpResponse[MetricsResponse] | ||
| HttpResponse[MetricsV2Response] | ||
| """ |
Contributor
There was a problem hiding this comment.
Silent endpoint promotion may break existing callers
RawMetricsClient.metrics (and its async counterpart) previously called api/public/metrics (the v1 endpoint). After this PR it calls api/public/v2/metrics. Any code that was already using client.metrics.metrics(...) will silently start hitting the v2 endpoint, which has different semantics:
- The
"traces"view is no longer supported and will now return a 400 error. - High-cardinality dimensions such as
userIdandsessionIdcannot be used as grouping dimensions in v2, raising 400 errors where they previously worked. - Default
row_limitchanges to 100 (vs. unspecified before).
The legacy v1 endpoint is still available at client.legacy.metrics_v1.metrics(...), but users who don't read release notes will hit unexpected 400s. Consider adding a deprecation warning or release note callout in the changelog.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Disclaimer: Experimental PR review
Greptile Summary
This auto-generated PR (via Fern) reshapes the Langfuse Python SDK's API module layout to promote v2 endpoints as the canonical defaults and move v1 legacy endpoints under a new
langfuse.api.legacy.*namespace.Key changes:
client.metricsnow callsapi/public/v2/metricsinstead ofapi/public/metrics. This is a silent breaking change for any caller using the"traces"view or high-cardinality grouping dimensions — both will begin receiving 400 errors without any code change on the caller's side. The old v1 behavior is preserved atclient.legacy.metrics_v1.client.observationsnow exposesObservationsV2Meta/ObservationsV2Response(previouslyobservations_v2); old v1 types (Observations,ObservationsViews) are underclient.legacy.observations_v1.client.scoresreplaces the formerclient.score_v2; oldclient.scoreis nowclient.legacy.score_v1.CreateScoreRequest,CreateScoreResponse,MetricsResponse,Observations,ObservationsViews. Callers importing these directly fromlangfuse.apiwill getImportError/AttributeErrorat runtime.from … import … # noqa: E402) inside property methods follow a pattern already present in the codebase but violate the project's custom import-ordering rule across all new and modified client files.Confidence Score: 3/5
client.metricsnow silently calls the v2 endpoint, which rejects previously valid"traces"view queries.metricsclient endpoint promotion (v1→v2) is silent — no deprecation warning, no version bump signal at the call site — meaning users relying on the"traces"view or high-cardinality dimensions will receive unexpected 400 errors after upgrading. The inline-import pattern violates the custom rule but is a pre-existing style issue in the codebase. Removed top-level exports (CreateScoreRequest,MetricsResponse, etc.) are additional breaking changes that should be called out in the changelog.langfuse/api/metrics/raw_client.py— endpoint silently promoted to v2;langfuse/api/__init__.py— multiple symbols removed from public exports.Important Files Changed
MetricsResponse,Observations,ObservationsViews,CreateScoreRequest,CreateScoreResponseremoved from top-level exports and replaced with v2 equivalents; old names are now accessible vialegacy.*.metrics_v2,observations_v2,score, andscore_v2removed;legacyandscoresadded. Newlegacyandscoresproperties use inline imports inside methods, violating the top-level import convention.metrics_v1,observations_v1,score_v1. All six sub-client properties (sync + async) use inline imports inside method bodies, inconsistent with the project's top-level import convention.api/public/metrics(v1) toapi/public/v2/metrics(v2) and response type changed toMetricsV2Response. This is a silent breaking change for existing callers relying on the"traces"view or high-cardinality group dimensions.api/public/metrics) wrapped asRawMetricsV1Client. Logic is correct and path imports updated properly for the deeper nesting level.observations_v2/raw_client.py; URL corrected toapi/public/observations(v1) and a newgetmethod added for single-observation retrieval. Import paths updated for the deeper nesting. Looks correct.score_v2/client.pytoscores/client.pywith classes renamed accordingly. No logic changes detected.score/raw_client.py; import paths updated for the additional nesting level. No functional changes.Flowchart
%%{init: {'theme': 'neutral'}}%% flowchart TD A[LangfuseAPI / AsyncLangfuseAPI] --> B[client.metrics\n→ api/public/v2/metrics\nMetricsV2Response] A --> C[client.observations\n→ api/public/v2/observations\nObservationsV2Response] A --> D[client.scores\n→ /scores endpoints\nGetScoresResponse] A --> E[client.legacy\nLegacyClient] E --> F[legacy.metrics_v1\n→ api/public/metrics\nMetricsResponse] E --> G[legacy.observations_v1\n→ api/public/observations\nObservationsViews] E --> H[legacy.score_v1\n→ /score endpoints\nCreateScoreResponse] subgraph Removed R1[client.metrics_v2 ✗] R2[client.observations_v2 ✗] R3[client.score ✗] R4[client.score_v2 ✗] end style B fill:#f9a,stroke:#c00 style Removed fill:#fee,stroke:#c00Last reviewed commit: 2bd5eb4
Context used:
dashboard- Move imports to the top of the module instead of placing them within functions or methods. (source)