Class: Dri::Commands::Analyze::StackTraces
- Inherits:
-
Dri::Command
- Object
- Dri::Command
- Dri::Commands::Analyze::StackTraces
- Includes:
- Amatch, Utils::Constants::Triage::Labels, Utils::Table
- Defined in:
- lib/dri/commands/analyze/stack_traces.rb
Constant Summary
Constants included from Utils::Constants::Triage::Labels
Utils::Constants::Triage::Labels::FAILURE, Utils::Constants::Triage::Labels::FAILURE_NEW, Utils::Constants::Triage::Labels::FOUND, Utils::Constants::Triage::Labels::INCIDENT, Utils::Constants::Triage::Labels::QA, Utils::Constants::Triage::Labels::QUALITY, Utils::Constants::Triage::Labels::QUARANTINE, Utils::Constants::Triage::Labels::SERVICE
Instance Method Summary collapse
-
#execute(_input: $stdin, output: $stdout) ⇒ Object
rubocop:disable Metrics/AbcSize.
-
#initialize(options) ⇒ StackTraces
constructor
A new instance of StackTraces.
Methods included from Utils::Table
Methods inherited from Dri::Command
#add_color, #api_client, #bold, #command, #config, #cursor, #editor, #emoji, #handover_report_path, #logger, #ops_token, #pastel, #profile, #prompt, #spinner, #timezone, #token, #username, #verify_config_exists
Constructor Details
#initialize(options) ⇒ StackTraces
Returns a new instance of StackTraces.
17 18 19 20 21 |
# File 'lib/dri/commands/analyze/stack_traces.rb', line 17 def initialize() @options = @labels = [:labels] || FAILURE_NEW @similarity_score_threshold = [:similarity_score_threshold] || 0.9 end |
Instance Method Details
#execute(_input: $stdin, output: $stdout) ⇒ Object
rubocop:disable Metrics/AbcSize
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 |
# File 'lib/dri/commands/analyze/stack_traces.rb', line 23 def execute(_input: $stdin, output: $stdout) # rubocop:disable Metrics/AbcSize verify_config_exists logger.info "#{Time.now.utc} Fetching issues" data = [] spinner.run do response = api_client.fetch_test_failure_issues(labels: @labels) logger.info "#{Time.now.utc} API response completed" if response.empty? logger.info "There are no #{FAILURE_NEW} issues identified!" exit 0 end data = identify_similar_issues(response) logger.info "#{Time.now.utc} Processing Data Complete" end similar_stack_traces = data.each_with_object([]) do |item, similar_items| next if item[:stack_trace].empty? next if item[:related_errors].length < 2 similar_items << [item[:stack_trace], item[:related_errors]] end FileUtils.mkdir_p("#{Dir.pwd}/analyze_reports/stacktraces") report_path = "analyze_reports/stacktraces/report-#{Time.now.utc.to_i}.md" write_report(similar_stack_traces, report_path) logger.success "Analyze StackTraces report is ready at: #{report_path}" errors_count = similar_stack_traces.count issues_count = similar_stack_traces.sum { |st| st[1].size } output.puts "Found #{errors_count} common errors across a combination of #{issues_count} issues" end |