scrapinghub / spidermon

Scrapy Extension for monitoring spiders execution.
https://spidermon.readthedocs.io
BSD 3-Clause "New" or "Revised" License
530 stars 96 forks source link

feature: Allow to filter jobs in ZyteJobsComparisonMonitor by close_reason #434

Open curita opened 7 months ago

curita commented 7 months ago

Background

ZyteJobsComparisonMonitor is a monitor that compares item_scraped_count from the current job against past jobs from ScrapyCloud.

By default, it will grab #SPIDERMON_JOBS_COMPARISON past jobs, and these jobs can be filtered using:

This works, but it's common to need more filtering options in practice.

Particularly, it would be nice to add to the filter by close_reason rather than state.

state can be "finished," "running," "pending," or "deleted," which is not quite helpful, as we mostly want to check "finished" jobs. close_reason, on the other hand, could allow us to keep only successful finished past jobs instead of failed or banned ones, which can have truncated item counts we wouldn't want to compare the current job against.

Proposal

Add a new SPIDERMON_JOBS_COMPARISON_CLOSE_REASONS setting to allow ZyteJobsComparisonMonitor to filter by the ScrapyCloud jobs' close_reason stat.

shafiq-muhammad commented 6 months ago

Hello, I would like to work on this feature.