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 +4 -4
- data/lib/bitfab/client.rb +12 -7
- data/lib/bitfab/http_client.rb +2 -2
- data/lib/bitfab/spans.rb +19 -0
- data/lib/bitfab/version.rb +1 -1
- data/lib/bitfab.rb +1 -0
- metadata +2 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 8a86045717d7c97884ea2005ef2e965cf02e53afcc57b4ae9681b5d75d64303f
|
|
4
|
+
data.tar.gz: 9f4903a7ad1771622b2608838667441d4d5ea8b3fcab14597f7af9a70b16882a
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
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
|
-
#
|
|
374
|
-
#
|
|
375
|
-
# Integer index.
|
|
376
|
-
|
|
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
|
-
|
|
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)
|
data/lib/bitfab/http_client.rb
CHANGED
|
@@ -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(
|
data/lib/bitfab/spans.rb
ADDED
|
@@ -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
|
data/lib/bitfab/version.rb
CHANGED
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.
|
|
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
|