Skip to content

Conversation

@langfuse-bot
Copy link
Collaborator

@langfuse-bot langfuse-bot commented Dec 17, 2025

Important

Add new V2 endpoints for metrics and observations with optimized performance and new features.

  • New Endpoints:
    • Add metrics_v_2 and observations_v_2 modules with optimized performance.
  • Clients:
    • Add MetricsV2Client and AsyncMetricsV2Client in metrics_v_2/client.py.
    • Add ObservationsV2Client and AsyncObservationsV2Client in observations_v_2/client.py.
  • Response Types:
    • Add MetricsV2Response in metrics_v_2/types/metrics_v_2_response.py.
    • Add ObservationsV2Response and ObservationsV2Meta in observations_v_2/types/.
  • API Initialization:
    • Update __init__.py files to include new modules and response types.

This description was created by Ellipsis for 49ca980. You can customize this summary. It will automatically update as commits are pushed.

Disclaimer: Experimental PR review

Greptile Summary

Auto-generated API client update adding V2 endpoints for metrics and observations with optimized performance and new features.

Key Changes:

  • Added MetricsV2Client with optimized query endpoint supporting observations, scores-numeric, and scores-categorical views
  • Added ObservationsV2Client with cursor-based pagination and flexible field selection via get_many method
  • Introduced new response types: MetricsV2Response, ObservationsV2Response, and ObservationsV2Meta
  • Updated main client classes (FernLangfuse and AsyncFernLangfuse) to include metrics_v_2 and observations_v_2 attributes
  • All imports properly positioned at module level, following Python best practices
  • Comprehensive documentation included in docstrings with detailed parameter descriptions and examples

Confidence Score: 5/5

  • This PR is safe to merge with minimal risk
  • This is an auto-generated PR from Fern with well-structured code following Python best practices. All imports are at module level, proper error handling is in place, type hints are used throughout, and comprehensive documentation is included. The changes are purely additive (no breaking changes), and the code follows the existing patterns in the codebase.
  • No files require special attention

Important Files Changed

Filename Overview
langfuse/api/client.py Added metrics_v_2 and observations_v_2 client attributes to both sync and async clients
langfuse/api/resources/metrics_v_2/client.py New V2 metrics client with optimized query endpoint supporting observations, scores-numeric, and scores-categorical views
langfuse/api/resources/metrics_v_2/types/metrics_v_2_response.py Pydantic model for V2 metrics response containing flexible data structure for metrics query results
langfuse/api/resources/observations_v_2/client.py New V2 observations client with cursor-based pagination and flexible field selection via get_many endpoint
langfuse/api/resources/observations_v_2/types/observations_v_2_response.py Pydantic model for V2 observations response with flexible field groups and pagination metadata

Sequence Diagram

sequenceDiagram
    participant Client
    participant FernLangfuse
    participant MetricsV2Client
    participant ObservationsV2Client
    participant HTTPClient
    participant API

    Note over Client,API: Initialize Client
    Client->>FernLangfuse: __init__(credentials)
    FernLangfuse->>MetricsV2Client: Initialize metrics_v_2
    FernLangfuse->>ObservationsV2Client: Initialize observations_v_2

    Note over Client,API: V2 Metrics Query
    Client->>FernLangfuse: client.metrics_v_2.metrics(query)
    FernLangfuse->>MetricsV2Client: metrics(query)
    MetricsV2Client->>HTTPClient: GET /api/public/v2/metrics
    HTTPClient->>API: Request with query params
    API-->>HTTPClient: JSON Response
    HTTPClient-->>MetricsV2Client: Response data
    MetricsV2Client-->>FernLangfuse: MetricsV2Response
    FernLangfuse-->>Client: MetricsV2Response(data)

    Note over Client,API: V2 Observations Query
    Client->>FernLangfuse: client.observations_v_2.get_many(filters)
    FernLangfuse->>ObservationsV2Client: get_many(fields, cursor, filters)
    ObservationsV2Client->>HTTPClient: GET /api/public/v2/observations
    HTTPClient->>API: Request with query params
    API-->>HTTPClient: JSON Response
    HTTPClient-->>ObservationsV2Client: Response data
    ObservationsV2Client-->>FernLangfuse: ObservationsV2Response
    FernLangfuse-->>Client: ObservationsV2Response(data, meta)

    Note over Client,API: Cursor-based Pagination
    Client->>FernLangfuse: client.observations_v_2.get_many(cursor=meta.cursor)
    FernLangfuse->>ObservationsV2Client: get_many(cursor)
    ObservationsV2Client->>HTTPClient: GET /api/public/v2/observations?cursor=...
    HTTPClient->>API: Request with cursor
    API-->>HTTPClient: Next page
    HTTPClient-->>ObservationsV2Client: Response data
    ObservationsV2Client-->>FernLangfuse: ObservationsV2Response
    FernLangfuse-->>Client: ObservationsV2Response(next_page_data, meta)
Loading

@hassiebp hassiebp merged commit 32dddd5 into main Dec 18, 2025
10 of 12 checks passed
@hassiebp hassiebp deleted the api-spec-bot-3dbec46 branch December 18, 2025 09:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants