Class: Braintrust::API::Internal::BTQL

Inherits:
Object
  • Object
show all
Defined in:
lib/braintrust/api/internal/btql.rb

Overview

Internal BTQL client for querying spans. Not part of the public API — instantiated directly where needed.

Instance Method Summary collapse

Constructor Details

#initialize(state) ⇒ BTQL

Returns a new instance of BTQL.



14
15
16
# File 'lib/braintrust/api/internal/btql.rb', line 14

def initialize(state)
  @state = state
end

Instance Method Details

#trace_spans(object_type:, object_id:, root_span_id:) ⇒ Array(Array<Hash>, String)

Query spans belonging to a specific trace within an object.

Builds a BTQL SQL query that matches the root_span_id and excludes scorer spans. Returns a single-shot result; callers are responsible for retry and error handling.

Parameters:

  • object_type (String)

    e.g. “experiment”

  • object_id (String)

    Object UUID

  • root_span_id (String)

    Hex trace ID of the root span

Returns:

  • (Array(Array<Hash>, String))
    rows, freshness


27
28
29
30
31
32
33
34
# File 'lib/braintrust/api/internal/btql.rb', line 27

def trace_spans(object_type:, object_id:, root_span_id:)
  query = build_trace_query(
    object_type: object_type,
    object_id: object_id,
    root_span_id: root_span_id
  )
  execute_query(query: query, fmt: "jsonl")
end