Class: ActionAgent::TraceRetentionJob

Inherits:
ApplicationJob
  • Object
show all
Defined in:
app/jobs/action_agent/trace_retention_job.rb

Overview

Prunes telemetry traces past the configured retention window.

NOT SCHEDULED BY DEFAULT: deleting trace history is a decision for the app that owns the data. To enable it, set a window and schedule the job:

ActionAgent.trace_retention = 30.days

# config/recurring.yml
trace_retention:
class: ActionAgent::TraceRetentionJob
schedule: every day at 4am

A host app with per-tenant retention rules (the activeagents.ai platform prunes per plan) passes a callable instead, receiving each owner and returning that owner's window.

Constant Summary collapse

BATCH_SIZE =
5_000

Instance Method Summary collapse

Instance Method Details

#performObject



24
25
26
27
28
29
30
31
32
33
# File 'app/jobs/action_agent/trace_retention_job.rb', line 24

def perform
  window = ActionAgent.trace_retention
  return if window.nil?

  if ActionAgent.multi_tenant? && (owners = ActionAgent.owner_class)
    owners.find_each { |owner| prune(traces.(owner), window_for(window, owner)) }
  else
    prune(traces.all, window_for(window, nil))
  end
end