-
Notifications
You must be signed in to change notification settings - Fork 56
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
[Integration][PagerDuty] Fix Rate limit from querying Pagerduty service analytics #1085
Conversation
… thrown and resync stops due to unexpected 429 errors. Implements a wait_time and retry mechanism for 429 errors in service analytics
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
looks good overall, left some suggestions
…s and errors, Cleans up get_service_analytics to be more focused on get service analytics functionality.
- Use send_api_request in paginate_request_to_pager_duty, get_singular_from_pager_duty, get_incident_analytics, create_webhooks_if_not_exists - Simplify exception handling remove redundant _handle_rate_limiting - Centralize API request logic in send_api_request
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this looks good. just one minor comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm
… and rate limiting handled by the client.
data = await self.send_api_request( | ||
endpoint=data_key, query_params={"offset": offset, **(params or {})} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am confused how data_key maps to an endpoint
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the Pagerduty API is organized well based on resources and it follows some pattern. For example, to get incidents, you may hit https://api.pagerduty.com/incident. the response schema will be something like this
{
"incidents": [
{
"incident_number": 1,
"title": "Authentication Issues",
"description": "Authentication Issues",
"created_at": "2023-05-15T13:57:24Z",
"updated_at": "2023-05-15T13:57:24Z",
"status": "triggered",
"incident_key": "a4b73cf5d5dd4e9f96a7f0b5a2fc7773",
...}]}
that's why endpoint and data_key (the root key from the response) are the same
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@shariff-6 let's rename the data_key to point to avoid this confusion
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Missing pyproject.toml |
- Renamed `data_key` parameter to `resource` in `paginate_request_to_pager_duty` for clarity. - Updated all function calls to use `resource` instead of `data_key`.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
requested one change
integrations/pagerduty/poetry.lock
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why did this change
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm
- Extract first item from analytics data - Handle cases where analytics data might be empty
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm
Description
What - Implemented rate limiter on PagerDuty
Why - Lots of requests are failing as 429.
How - Used a single sephamore since concurrent requests are not advised
Type of change
All tests should be run against the port production environment(using a testing org).
Core testing checklist
Integration testing checklist
examples
folder in the integration directory.Preflight checklist
Screenshots
Include screenshots from your environment showing how the resources of the integration will look.
API Documentation
Provide links to the API documentation used for this integration.