Skip to content

Commit

Permalink
Enhance Pagerduty oncalls API with logs (#248)
Browse files Browse the repository at this point in the history
  • Loading branch information
PeyGis authored Nov 30, 2023
1 parent 2d66906 commit 31e2f63
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 2 deletions.
7 changes: 7 additions & 0 deletions integrations/pagerduty/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,13 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

<!-- towncrier release notes start -->

# Port_Ocean 0.1.19 (2023-11-29)

### Improvements

- Enhance oncalls API with detailed logging (#19)


# Port_Ocean 0.1.18 (2023-11-29)

### Improvements
Expand Down
9 changes: 8 additions & 1 deletion integrations/pagerduty/clients/pagerduty.py
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,9 @@ async def create_webhooks_if_not_exists(self) -> None:
async def get_oncall_user(
self, *escalation_policy_ids: str
) -> list[dict[str, Any]]:
logger.info(
f"Fetching who is oncall for escalation poilices: {','.join(escalation_policy_ids)}"
)
params = {
"escalation_policy_ids[]": ",".join(escalation_policy_ids),
"include[]": "users",
Expand All @@ -163,14 +166,18 @@ async def get_oncall_user(
data_key="oncalls", params=params
):
logger.info(f"Received oncalls with batch size {len(oncall_batch)}")
logger.info(f"Listing received oncalls data: {oncall_batch}")
oncalls.extend(oncall_batch)

return oncalls

async def update_oncall_users(
self, services: list[dict[str, Any]]
) -> list[dict[str, Any]]:
logger.info("Fetching and matching who is on-call for services")
services_names = [service["name"] for service in services]
logger.info(
f"Fetching and matching who is on-call for {len(services)} services: {services_names}"
)
oncall_users = await self.get_oncall_user(
*[service["escalation_policy"]["id"] for service in services]
)
Expand Down
2 changes: 1 addition & 1 deletion integrations/pagerduty/pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "pagerduty"
version = "0.1.18"
version = "0.1.19"
description = "Pagerduty Integration"
authors = ["Port Team <[email protected]>"]

Expand Down

0 comments on commit 31e2f63

Please sign in to comment.