Skip to content

Commit

Permalink
Send metrics about succeeded and failed workflow runs for gitea
Browse files Browse the repository at this point in the history
  • Loading branch information
krauselukas authored and eduardoj committed Sep 27, 2022
1 parent 5ab04ff commit 54f38f1
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/api/app/services/gitea_status_reporter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,16 @@ def call
gitea_client.create_commit_status(owner: owner, repo: repository_name,
sha: @event_subscription_payload[:commit_sha],
state: @state, **status_options)
@workflow_run.save_scm_report_success(request_context) if @workflow_run.present?
if @workflow_run.present?
@workflow_run.save_scm_report_success(request_context)
RabbitmqBus.send_to_bus('metrics', "scm_status_report,status=success,scm=#{@event_subscription_payload[:scm]} value=1")
end
rescue Faraday::ConnectionFailed => e
@workflow_run.save_scm_report_failure("Failed to report back to Gitea: #{e.message}", request_context) if @workflow_run.present?
rescue GiteaAPI::V1::Client::GiteaApiError => e
rescue_with_handler(e) || raise(e)
ensure
RabbitmqBus.send_to_bus('metrics', "scm_status_report,status=fail,scm=#{@event_subscription_payload[:scm]},exception=#{e.class} value=1") if e.present? && @workflow_run.present?
end

private
Expand Down

0 comments on commit 54f38f1

Please sign in to comment.