Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP]Add New Monitors to track Requests Success Rate #454

Closed

Conversation

shafiq-muhammad
Copy link
Contributor

Added following monitors to test requests success rate

  • ZyteAPIErrorRatioMonitor
  • SPMErrorRatioMonitor

@shafiq-muhammad shafiq-muhammad changed the title Add New Monitors to track Requests Success Rate [WIP]Add New Monitors to track Requests Success Rate Aug 22, 2024
Copy link
Member

@curita curita left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks Muhammad for these changes!

I pointed some few things to update, but these monitors are nearly done already :)

I'll be tagging @vineettomar06 for any further feedback about these monitors, and also so they can serve as a base for the new 429 error monitors.


threshold = self.crawler.settings.getint(SPIDERMON_MAX_SPM_ERROR_RATIO, -1)
if threshold < 0:
return
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

suggestion: I think in this case we should notify that the monitor is not configured. Either via a regular log message, or by skipping the test with a message saying that SPIDERMON_MAX_SPM_ERROR_RATIO is not set.

Otherwise this monitor will be marked as "OK", when it didn't really run, which could make debugging harder.


errors = self.stats[self.stat_name]
requests = self.stats["zyte_smartproxy/request"]
ratio = errors / requests
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

todo: We should handle the case where requests is zero, otherwise this will throw a ZeroDivisionError.

We could consider that case to have a ratio of zero, or we can skip it otherwise.

@@ -297,6 +299,59 @@ def test_minimum_successful_requests(self):
self.assertGreaterEqual(requests, threshold, msg=msg)


@monitors.name("Zyte API Error Ratio monitor")
class ZyteAPIErrorRatioMonitor(Monitor, BaseStatMonitor):
Copy link
Member

@curita curita Oct 22, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

todo: We'll have to add unitttests for the new monitor checks and fix the CI checks.

@curita
Copy link
Member

curita commented Oct 22, 2024

Ah, didn't notice these were issued here instead of the common monitors repo.

We might want to submit them to the common monitors repo for the time being @shafiq-muhammad, while we finalize the repo with the Zyte product monitors.

@scrapinghub scrapinghub deleted a comment from curita Oct 30, 2024
@VMRuiz VMRuiz closed this Oct 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants