28
29
30
31
32
33
34
35
36
37
38
|
# File 'lib/legion/cli/chat/tools/detect_anomalies.rb', line 28
def execute(threshold: 2.0)
data = api_get("/api/traces/anomalies?threshold=#{threshold.to_f}")
return "API error: #{data[:error][:message]}" if data[:error]
format_report(data[:data] || data)
rescue Errno::ECONNREFUSED
'Legion daemon not running (cannot reach anomaly detection API).'
rescue StandardError => e
Legion::Logging.warn("DetectAnomalies#execute failed: #{e.message}") if defined?(Legion::Logging)
"Error detecting anomalies: #{e.message}"
end
|