langfuse-rb 0.4.0 → 0.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e356e95702ea99ed80bfc258a3a1dbfa6c71985bb8a31110f26c09e6ac8c8b8d
4
- data.tar.gz: 742033eb63885f9a1b33377258c423a25c0fe6af8554965de8fd76b1807d3a93
3
+ metadata.gz: 3b2a00b43e48c855cee6d5ccf6b12c36641c469182ddb65231323dcc566d01f2
4
+ data.tar.gz: 21b9bc01d7297bf7130b4530f25e4fffc8a0ac18036a7e6e97562767b2a4657a
5
5
  SHA512:
6
- metadata.gz: d26c930cf723cbdbd5fdd738fcbae8b2181aca3f340eb0929c3ab2d76720aa3b1f217fe8f71804607f0cac32a3b115b7a625e02cf982d30ceceb1c0c45c0d603
7
- data.tar.gz: a4667dc7d5abe11b7facd78c26e406a394696f9d0ca6663a200ad0232adcd7bd45d7d4bf495b2f98c7a7ed23b5f7b62ab7c2ba7b76a606b546859072b98cedec
6
+ metadata.gz: b121586667150434548323b0734f456f51fb06c21513bb59aaf7d8bbd07b8077ef23bbf2b87f2cac1514f5b220f54cff19175d97c11d19472306367a888aa97f
7
+ data.tar.gz: 9b5790ee2504681417cb7fa77fc2ebcb3c4e484bcfd512ba04abd6fbad215b609235d4bf109b0481c7855822d0643203873d49754b485aba487f6e85fb84260e
data/CHANGELOG.md CHANGED
@@ -7,6 +7,14 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
7
7
 
8
8
  ## [Unreleased]
9
9
 
10
+ ## [0.5.0] - 2026-02-09
11
+
12
+ ### Added
13
+ - Trace listing and retrieval endpoints (`list_traces`, `get_trace`) (#47)
14
+
15
+ ### Documentation
16
+ - Improved documentation readability and formatting (#46)
17
+
10
18
  ## [0.4.0] - 2026-02-08
11
19
 
12
20
  ### Added
@@ -54,7 +62,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
54
62
  - Migrated from legacy ingestion API to OTLP endpoint
55
63
  - Removed `tracing_enabled` configuration flag (#2)
56
64
 
57
- [Unreleased]: https://github.com/simplepractice/langfuse-rb/compare/v0.4.0...HEAD
65
+ [Unreleased]: https://github.com/simplepractice/langfuse-rb/compare/v0.5.0...HEAD
66
+ [0.5.0]: https://github.com/simplepractice/langfuse-rb/compare/v0.4.0...v0.5.0
58
67
  [0.4.0]: https://github.com/simplepractice/langfuse-rb/compare/v0.3.0...v0.4.0
59
68
  [0.3.0]: https://github.com/simplepractice/langfuse-rb/compare/v0.2.0...v0.3.0
60
69
  [0.2.0]: https://github.com/simplepractice/langfuse-rb/compare/v0.1.0...v0.2.0
@@ -285,6 +285,85 @@ module Langfuse
285
285
  cache.shutdown if cache.respond_to?(:shutdown)
286
286
  end
287
287
 
288
+ # List traces in the project
289
+ #
290
+ # @param page [Integer, nil] Optional page number for pagination
291
+ # @param limit [Integer, nil] Optional limit per page
292
+ # @param user_id [String, nil] Filter by user ID
293
+ # @param name [String, nil] Filter by trace name
294
+ # @param session_id [String, nil] Filter by session ID
295
+ # @param from_timestamp [Time, nil] Filter traces after this time
296
+ # @param to_timestamp [Time, nil] Filter traces before this time
297
+ # @param order_by [String, nil] Order by field
298
+ # @param tags [Array<String>, nil] Filter by tags
299
+ # @param version [String, nil] Filter by version
300
+ # @param release [String, nil] Filter by release
301
+ # @param environment [String, nil] Filter by environment
302
+ # @param fields [String, nil] Comma-separated field groups to include (e.g. "core,scores,metrics")
303
+ # @param filter [String, nil] JSON string for advanced filtering
304
+ # @return [Array<Hash>] Array of trace hashes
305
+ # @raise [UnauthorizedError] if authentication fails
306
+ # @raise [ApiError] for other API errors
307
+ #
308
+ # @example
309
+ # traces = api_client.list_traces(page: 1, limit: 10, name: "my-trace")
310
+ # rubocop:disable Metrics/ParameterLists
311
+ def list_traces(page: nil, limit: nil, user_id: nil, name: nil, session_id: nil,
312
+ from_timestamp: nil, to_timestamp: nil, order_by: nil,
313
+ tags: nil, version: nil, release: nil, environment: nil,
314
+ fields: nil, filter: nil)
315
+ result = list_traces_paginated(
316
+ page: page, limit: limit, user_id: user_id, name: name,
317
+ session_id: session_id, from_timestamp: from_timestamp,
318
+ to_timestamp: to_timestamp, order_by: order_by, tags: tags,
319
+ version: version, release: release, environment: environment,
320
+ fields: fields, filter: filter
321
+ )
322
+ result["data"] || []
323
+ end
324
+ # rubocop:enable Metrics/ParameterLists
325
+
326
+ # Full paginated response including "meta" for internal pagination use
327
+ #
328
+ # @api private
329
+ # @return [Hash] Full response hash with "data" array and "meta" pagination info
330
+ # rubocop:disable Metrics/ParameterLists
331
+ def list_traces_paginated(page: nil, limit: nil, user_id: nil, name: nil, session_id: nil,
332
+ from_timestamp: nil, to_timestamp: nil, order_by: nil,
333
+ tags: nil, version: nil, release: nil, environment: nil,
334
+ fields: nil, filter: nil)
335
+ with_faraday_error_handling do
336
+ params = build_traces_params(
337
+ page: page, limit: limit, user_id: user_id, name: name,
338
+ session_id: session_id, from_timestamp: from_timestamp,
339
+ to_timestamp: to_timestamp, order_by: order_by, tags: tags,
340
+ version: version, release: release, environment: environment,
341
+ fields: fields, filter: filter
342
+ )
343
+ response = connection.get("/api/public/traces", params)
344
+ handle_response(response)
345
+ end
346
+ end
347
+ # rubocop:enable Metrics/ParameterLists
348
+
349
+ # Fetch a trace by ID
350
+ #
351
+ # @param id [String] Trace ID
352
+ # @return [Hash] The trace data
353
+ # @raise [NotFoundError] if the trace is not found
354
+ # @raise [UnauthorizedError] if authentication fails
355
+ # @raise [ApiError] for other API errors
356
+ #
357
+ # @example
358
+ # trace = api_client.get_trace("trace-uuid-123")
359
+ def get_trace(id)
360
+ with_faraday_error_handling do
361
+ encoded_id = URI.encode_uri_component(id)
362
+ response = connection.get("/api/public/traces/#{encoded_id}")
363
+ handle_response(response)
364
+ end
365
+ end
366
+
288
367
  # List all datasets in the project
289
368
  #
290
369
  # @param page [Integer, nil] Optional page number for pagination
@@ -525,6 +604,23 @@ module Langfuse
525
604
  }.compact
526
605
  end
527
606
 
607
+ # Build query params for list_traces, mapping snake_case to camelCase
608
+ # rubocop:disable Metrics/ParameterLists
609
+ def build_traces_params(page:, limit:, user_id:, name:, session_id:,
610
+ from_timestamp:, to_timestamp:, order_by:,
611
+ tags:, version:, release:, environment:, fields:, filter:)
612
+ {
613
+ page: page, limit: limit, userId: user_id, name: name,
614
+ sessionId: session_id,
615
+ fromTimestamp: from_timestamp&.iso8601,
616
+ toTimestamp: to_timestamp&.iso8601,
617
+ orderBy: order_by, tags: tags, version: version,
618
+ release: release, environment: environment, fields: fields,
619
+ filter: filter
620
+ }.compact
621
+ end
622
+ # rubocop:enable Metrics/ParameterLists
623
+
528
624
  # Fetch with SWR cache
529
625
  def fetch_with_swr_cache(cache_key, name, version, label)
530
626
  cache.fetch_with_stale_while_revalidate(cache_key) do
@@ -439,6 +439,35 @@ module Langfuse
439
439
  api_client.list_datasets(page: page, limit: limit)
440
440
  end
441
441
 
442
+ # List traces in the project
443
+ #
444
+ # @param page [Integer, nil] Optional page number for pagination
445
+ # @param limit [Integer, nil] Optional limit per page
446
+ # @param filters [Hash] Additional filters (user_id, name, session_id, etc.)
447
+ # @return [Array<Hash>] Array of trace hashes
448
+ # @raise [UnauthorizedError] if authentication fails
449
+ # @raise [ApiError] for other API errors
450
+ #
451
+ # @example
452
+ # traces = client.list_traces(page: 1, limit: 10, name: "my-trace")
453
+ def list_traces(page: nil, limit: nil, **filters)
454
+ api_client.list_traces(page: page, limit: limit, **filters)
455
+ end
456
+
457
+ # Fetch a trace by ID
458
+ #
459
+ # @param id [String] Trace ID
460
+ # @return [Hash] The trace data
461
+ # @raise [NotFoundError] if the trace is not found
462
+ # @raise [UnauthorizedError] if authentication fails
463
+ # @raise [ApiError] for other API errors
464
+ #
465
+ # @example
466
+ # trace = client.get_trace("trace-uuid-123")
467
+ def get_trace(id)
468
+ api_client.get_trace(id)
469
+ end
470
+
442
471
  # Create a new dataset item
443
472
  #
444
473
  # @param dataset_name [String] Name of the dataset to add item to (required)
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Langfuse
4
- VERSION = "0.4.0"
4
+ VERSION = "0.5.0"
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: langfuse-rb
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.0
4
+ version: 0.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - SimplePractice