-
Notifications
You must be signed in to change notification settings - Fork 5
feat(traces): add list_traces and get_trace endpoints #47
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -8,6 +8,7 @@ Complete method reference for the Langfuse Ruby SDK. | |
| - [Client Access](#client-access) | ||
| - [Prompt Management](#prompt-management) | ||
| - [Tracing & Observability](#tracing--observability) | ||
| - [Traces](#traces) | ||
| - [Scoring](#scoring) | ||
| - [Datasets](#datasets) | ||
| - [Experiments](#experiments) | ||
|
|
@@ -513,6 +514,92 @@ obs.update( | |
| ) | ||
| ``` | ||
|
|
||
| ## Traces | ||
|
|
||
| ### `Client#list_traces` | ||
|
|
||
| List traces in the project. | ||
|
|
||
| **Signature:** | ||
|
|
||
| ```ruby | ||
| list_traces(page: nil, limit: nil, **filters) | ||
| ``` | ||
|
|
||
| **Parameters:** | ||
|
|
||
| | Parameter | Type | Required | Description | | ||
| | ---------------- | ------------- | -------- | ----------------------------------------------------------------------------------------------------------------------------- | | ||
| | `page` | Integer | No | Page number | | ||
| | `limit` | Integer | No | Results per page | | ||
| | `user_id` | String | No | Filter by user ID | | ||
| | `name` | String | No | Filter by trace name | | ||
| | `session_id` | String | No | Filter by session ID | | ||
| | `from_timestamp` | Time | No | Filter traces after this time | | ||
| | `to_timestamp` | Time | No | Filter traces before this time | | ||
| | `order_by` | String | No | Order by field | | ||
| | `tags` | Array<String> | No | Filter by tags | | ||
| | `version` | String | No | Filter by version | | ||
| | `release` | String | No | Filter by release | | ||
| | `environment` | String | No | Filter by environment | | ||
| | `fields` | String | No | Comma-separated field groups to include (e.g. `"core,scores,metrics"`). Available: `core`, `io`, `scores`, `observations`, `metrics`. All fields returned if omitted. | | ||
| | `filter` | String | No | JSON string for advanced filtering | | ||
|
|
||
| **Returns:** `Array<Hash>` of trace data | ||
|
|
||
| **Raises:** | ||
|
|
||
| - `UnauthorizedError` if authentication fails | ||
| - `ApiError` for other API errors | ||
|
|
||
| **Examples:** | ||
|
|
||
| ```ruby | ||
| # Basic listing | ||
| traces = client.list_traces(page: 1, limit: 20) | ||
|
|
||
| # Filter by user and name | ||
| traces = client.list_traces(user_id: "user-123", name: "my-trace") | ||
|
|
||
| # Time range with field selection | ||
| traces = client.list_traces( | ||
| from_timestamp: Time.utc(2025, 1, 1), | ||
| to_timestamp: Time.utc(2025, 1, 31), | ||
| fields: "core,scores" | ||
| ) | ||
| ``` | ||
|
|
||
| ### `Client#get_trace` | ||
|
|
||
| Fetch a single trace by ID. | ||
|
|
||
| **Signature:** | ||
|
|
||
| ```ruby | ||
| get_trace(id) # => Hash | ||
| ``` | ||
|
|
||
| **Parameters:** | ||
|
|
||
| | Parameter | Type | Required | Description | | ||
| | --------- | ------ | -------- | ----------- | | ||
| | `id` | String | Yes | Trace ID | | ||
|
|
||
|
Comment on lines
+584
to
+587
|
||
| **Returns:** `Hash` of trace data | ||
|
|
||
| **Raises:** | ||
|
|
||
| - `NotFoundError` if the trace doesn't exist | ||
| - `UnauthorizedError` if authentication fails | ||
| - `ApiError` for other API errors | ||
|
|
||
| **Example:** | ||
|
|
||
| ```ruby | ||
| trace = client.get_trace("trace-uuid-123") | ||
| puts trace["name"] | ||
| ``` | ||
|
|
||
| ## Scoring | ||
|
|
||
| ### `Client#create_score` | ||
|
|
||
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
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
Oops, something went wrong.
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The parameters table markup uses double leading pipes (
|| ...) which breaks GitHub-flavored Markdown table rendering. Update the header and rows to use single pipes (| ... |) consistently so the table renders correctly.