Class: ActiveAgent::Dashboard::Api::TracesController
- Inherits:
-
ActionController::API
- Object
- ActionController::API
- ActiveAgent::Dashboard::Api::TracesController
- Defined in:
- lib/active_agent/dashboard/app/controllers/active_agent/dashboard/api/traces_controller.rb
Overview
Telemetry ingestion endpoint.
Receives traces from ActiveAgent::Telemetry::Reporter and stores them for analysis and visualization in the dashboard.
Supports two modes:
- Local mode: synchronous processing; unauthenticated unless ActiveAgent::Dashboard.ingest_api_key is set (set it whenever the mount is reachable beyond your own machine)
- Multi-tenant mode: per-account Bearer token auth, async processing via job
Constant Summary collapse
- MAX_TRACES_PER_REQUEST =
Maximum traces accepted per request (mirrors ProcessTelemetryTracesJob::MAX_TRACES_PER_JOB).
100
Instance Method Summary collapse
-
#create ⇒ Object
POST
/api/traces (e.g. /activeagents/api/traces).
Instance Method Details
#create ⇒ Object
POST
46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 |
# File 'lib/active_agent/dashboard/app/controllers/active_agent/dashboard/api/traces_controller.rb', line 46 def create traces = Array(params[:traces]).take(MAX_TRACES_PER_REQUEST) sdk_info = params[:sdk] || {} return head :accepted if traces.empty? if ActiveAgent::Dashboard.multi_tenant? # Multi-tenant mode: process in background ActiveAgent::ProcessTelemetryTracesJob.perform_later( account_id: @account&.id, traces: traces.as_json, sdk_info: sdk_info.as_json, received_at: Time.current.iso8601(6) ) else # Local mode: process synchronously process_traces_synchronously(traces, sdk_info) end head :accepted rescue ActionController::ParameterMissing => e render json: { error: e. }, status: :bad_request rescue StandardError => e Rails.logger.error("[ActiveAgent::Dashboard] Trace ingestion error: #{e.}") render json: { error: "Internal server error" }, status: :internal_server_error end |