Class: RcrewAI::Rails::ObservationsController
- Inherits:
-
ApplicationController
- Object
- ActionController::Base
- ApplicationController
- RcrewAI::Rails::ObservationsController
- Defined in:
- app/controllers/rcrewai/rails/observations_controller.rb
Constant Summary collapse
- MAX_SPAN_DEPTH =
Hard ceiling on how deep the span partial will recurse. Real traces are a handful of levels deep; this only exists so a malformed tree cannot recurse until the request dies.
50
Instance Method Summary collapse
Instance Method Details
#costs ⇒ Object
18 19 20 21 22 23 24 |
# File 'app/controllers/rcrewai/rails/observations_controller.rb', line 18 def costs @executions = Execution.where.not(total_cost_usd: nil) .order(created_at: :desc) .limit(100) @total_cost = @executions.sum(&:total_cost_usd) @total_tokens = @executions.sum { |e| e.total_tokens.to_i } end |
#show ⇒ Object
9 10 11 12 13 14 15 16 |
# File 'app/controllers/rcrewai/rails/observations_controller.rb', line 9 def show @execution = Execution.find(params[:execution_id]) # Load the whole tree in one query and nest in memory — a recursive # per-node query would be N+1 on deep traces. @spans = @execution.spans.ordered.to_a @children = @spans.group_by(&:parent_span_id) @roots = @children[nil] || [] end |