Skip to content

Some metrics are being skipped on rescuing Timeout Error  #310

@AkshayGoyal022

Description

@AkshayGoyal022

I have an application which supports background jobs (report generations). I have a use-case in which if a report is taking too long i timeout the report. Below is the pseudo code:

def generate_report(user_id)
  timeout_after = 10800 # In seconds # 3hours
  StatsD.increment('report_generation', 1, tags:["name:report_generation_start", "user_id:#{user_id}"])
  formats = [:csv, :xlsx]
  formats.each do |r_format|
    begin
      Timeout.timeout(timeout_after) do
        report = send("generate_#{r_format}")
      end
    rescue Timeout::Error => e
      StatsD.increment('report_generation', 1, tags:["name:report_generation_timeout_error", "user_id:#{user_id}"])
      break
    end
  end
  StatsD.increment('report_generation', 1, tags:["name:report_generation_completed", "user_id:#{user_id}"])
end

I ran 3 background jobs for different users (let's say id 1, 2, 3).

On successful generation i see all 3 metrics being pushed correctly. However, on timeout error i see name:report_generation_start being pushed 3 times but name:report_generation_timeout_error, name:report_generation_completed being pushed only once or twice (there's always a missing entry atleast)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions