bitfab 0.64.16 → 0.64.17

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: 663335d46afd24e88e03d2bb0e8614928b95ebe4f9e24abad0e4f2db68255784
4
- data.tar.gz: e0e696b4ed008232aaf21cce80b8f48fa95168500d8bf520874237a5ab54f1fa
3
+ metadata.gz: 8a86045717d7c97884ea2005ef2e965cf02e53afcc57b4ae9681b5d75d64303f
4
+ data.tar.gz: 9f4903a7ad1771622b2608838667441d4d5ea8b3fcab14597f7af9a70b16882a
5
5
  SHA512:
6
- metadata.gz: 52d0d805f4ffe7e66584885c853a9a5a8d26d04af5159ec174ac4c3befa079e33c977bbab0b3804644fd22e415f97bfe48a5358bd3eb51ab791d16861e97e9f9
7
- data.tar.gz: 3a345ad2555bff9970cfeae3bf9e965f0cf08c0ec30765526173ef394f4eb4b02c213d50d7b5352d923ca9b5a2d2fe06c46c19d0f494fb1d75ed82242d04b4d6
6
+ metadata.gz: 267f523ef41019703bc9c35c4c1c608d07583b7e1a50b4108ca7379cbf9d93dce08b057cccb723ca18504b794b7d460a4e0653cc1a64aee8476fb1c78a3fb862
7
+ data.tar.gz: 75a9dec7bf4ff1c8c8a2140f3ebd9a2a1fc04737ea691fc9560711fe035872d3990a31d2216a720e2da25581ec93988a60dadcf962854ff16a8bad078a3045a0
data/lib/bitfab/client.rb CHANGED
@@ -37,7 +37,7 @@ module Bitfab
37
37
 
38
38
  attr_reader :service_url
39
39
 
40
- attr_reader :datasets, :assertion_categories, :organization_members, :traces, :labels, :graders, :experiments
40
+ attr_reader :datasets, :assertion_categories, :organization_members, :traces, :spans, :labels, :graders, :experiments
41
41
 
42
42
  def initialize(api_key: nil, service_url: nil, capture_enabled: nil, enabled: nil, strict: false, simulation_plan: true, timeout: 120, trace_across_threads: nil, env_vars: nil, baml_client: nil, db_snapshot: nil)
43
43
  @db_snapshot = DbSnapshot.normalize_config(db_snapshot)
@@ -57,6 +57,7 @@ module Bitfab
57
57
  @assertion_categories = AssertionCategories.new(@http_client)
58
58
  @organization_members = OrganizationMembers.new(@http_client)
59
59
  @traces = Traces.new(@http_client)
60
+ @spans = Spans.new(@http_client)
60
61
  @labels = Labels.new(@http_client)
61
62
  @graders = Graders.new(@http_client)
62
63
  @experiments = Experiments.new(@http_client)
@@ -370,24 +371,28 @@ module Bitfab
370
371
  end
371
372
 
372
373
  # Fetch one persisted span without loading the full trace.
373
- # Exactly one of id or name is required. Name lookups return the last
374
- # matching span by default; occurrence also accepts "first" or a zero-based
375
- # Integer index.
376
- def get_trace_span(trace_id, id: nil, name: nil, occurrence: "last")
374
+ # Pass id alone, or name and/or type (llm, agent, function, guardrail,
375
+ # handoff, custom). Name and type lookups return the last matching span by
376
+ # default; occurrence also accepts "first" or a zero-based Integer index.
377
+ # Raises ArgumentError before sending for any other combination or an
378
+ # unknown type.
379
+ def get_trace_span(trace_id, id: nil, name: nil, type: nil, occurrence: "last")
377
380
  validate_trace_id(trace_id)
378
- raise ArgumentError, "Provide exactly one of id or name" if id.nil? == name.nil?
381
+ has_position_selector = !name.nil? || !type.nil?
382
+ raise ArgumentError, "Provide id, or name and/or type" if id.nil? != has_position_selector
379
383
 
380
384
  validate_span_id(id) unless id.nil?
381
385
  if !name.nil? && (!name.is_a?(String) || name.empty?)
382
386
  raise ArgumentError, "name must be a non-empty string"
383
387
  end
388
+ validate_span_type!(type) unless type.nil?
384
389
 
385
390
  valid_occurrence = ["first", "last"].include?(occurrence) || (occurrence.is_a?(Integer) && occurrence >= 0)
386
391
  unless valid_occurrence
387
392
  raise ArgumentError, 'occurrence must be "first", "last", or a non-negative integer'
388
393
  end
389
394
 
390
- @http_client.get_trace_span(trace_id, id:, name:, occurrence:)
395
+ @http_client.get_trace_span(trace_id, id:, name:, type:, occurrence:)
391
396
  end
392
397
 
393
398
  def get_span(span_id)
@@ -321,11 +321,11 @@ module Bitfab
321
321
  get("/api/sdk/externalSpans/#{span_id}#{query}", timeout: 30)
322
322
  end
323
323
 
324
- def get_trace_span(trace_id, id: nil, name: nil, occurrence: "last")
324
+ def get_trace_span(trace_id, id: nil, name: nil, type: nil, occurrence: "last")
325
325
  query = if id
326
326
  {id:}
327
327
  else
328
- {name:, occurrence: occurrence.to_s}
328
+ {name:, type: type&.to_s, occurrence: occurrence.to_s}.compact
329
329
  end
330
330
  encoded_trace_id = URI.encode_www_form_component(trace_id)
331
331
  get(
@@ -0,0 +1,19 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Bitfab
4
+ class Spans
5
+ def initialize(http_client)
6
+ @http_client = http_client
7
+ end
8
+
9
+ def list(trace_id, span_type: nil, span_name: nil, fields: nil, cursor: nil, limit: nil)
10
+ payload = {"traceId" => trace_id}
11
+ payload["spanType"] = span_type unless span_type.nil?
12
+ payload["spanName"] = span_name unless span_name.nil?
13
+ payload["fields"] = fields unless fields.nil?
14
+ payload["cursor"] = cursor unless cursor.nil?
15
+ payload["limit"] = limit unless limit.nil?
16
+ @http_client.request("/api/sdk/spans/list", payload)
17
+ end
18
+ end
19
+ end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Bitfab
4
- VERSION = "0.64.16"
4
+ VERSION = "0.64.17"
5
5
  end
data/lib/bitfab.rb CHANGED
@@ -18,6 +18,7 @@ require_relative "bitfab/datasets"
18
18
  require_relative "bitfab/assertion_categories"
19
19
  require_relative "bitfab/organization_members"
20
20
  require_relative "bitfab/traces"
21
+ require_relative "bitfab/spans"
21
22
  require_relative "bitfab/assertions"
22
23
  require_relative "bitfab/scenarios"
23
24
  require_relative "bitfab/labels"
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bitfab
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.64.16
4
+ version: 0.64.17
5
5
  platform: ruby
6
6
  authors:
7
7
  - Harvest Team
@@ -197,6 +197,7 @@ files:
197
197
  - lib/bitfab/simulation_plan.rb
198
198
  - lib/bitfab/span_context.rb
199
199
  - lib/bitfab/span_origin.rb
200
+ - lib/bitfab/spans.rb
200
201
  - lib/bitfab/subtree.rb
201
202
  - lib/bitfab/thread_propagation.rb
202
203
  - lib/bitfab/timestamp.rb