Skip to content

:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.

feat(data-warehouse): add 2 missing tables to the PagerDuty source (#124740)

Tom Owers754a8d5e4824
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/COVERAGE_GAPS_APPENDIX.md b/products/warehouse_sources/backend/temporal/data_imports/sources/COVERAGE_GAPS_APPENDIX.md
index 17637ba93525..475efb6ac397 100644
--- a/products/warehouse_sources/backend/temporal/data_imports/sources/COVERAGE_GAPS_APPENDIX.md
+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/COVERAGE_GAPS_APPENDIX.md
@@ -9090,8 +9090,8 @@ Diffed against: <https://raw.githubusercontent.com/PagerDuty/api-schema/main/ref
- [x] `/incidents/{id}/notes` — responder notes attached to incidents, for postmortem/context analysis (medium). Added as `incident_notes` (fan-out over `incidents`)
- [ ] `/schedules/{id}/users` — skipped: the endpoint lists the users on call in a time window, not schedule membership; membership is already in the `users` column of `schedules`, and who is on call is in `oncalls` (medium)
- [ ] `/v3/schedules/{id}/rotations (and /overrides)` — skipped: these belong to the separate v3 shift-based schedules API, not the REST v2 API this source implements; v3 schedules need their own `/v3/schedules` parent, and overrides require a `since`/`until` shift window, so a synced table would silently drop history outside it (medium)
-- [ ] `/business_services` — business service layer plus /business_services/impacts, needed to roll incidents up to business impact (medium)
-- [ ] `/maintenance_windows` — suppression windows; without them uptime and alert-volume math is wrong (medium)
+- [x] `/business_services` — business service layer plus /business_services/impacts, needed to roll incidents up to business impact (medium). Added as `business_services` (full refresh); `/business_services/impacts` is a live top-200 snapshot, not synced
+- [x] `/maintenance_windows` — suppression windows; without them uptime and alert-volume math is wrong (medium). Added as `maintenance_windows` (full refresh, `filter=all`)
- [ ] `/audit/records` — state/transition history across services, schedules, and policies (medium)
- [ ] `/notifications` — notifications actually sent to responders, for pager fatigue analysis (low)
- [ ] `/incidents/{id}/scribe_transcripts` — skipped: each row exists to carry a presigned transcript download link that expires after one hour, so a synced copy is stale by the next query; the rest is Scribe start and end times that cost one request per incident on every sync (low)
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/pagerduty/canonical_descriptions.py b/products/warehouse_sources/backend/temporal/data_imports/sources/pagerduty/canonical_descriptions.py
index 1094fc387f80..e877f3d1faa9 100644
--- a/products/warehouse_sources/backend/temporal/data_imports/sources/pagerduty/canonical_descriptions.py
+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/pagerduty/canonical_descriptions.py
@@ -209,6 +209,29 @@ CANONICAL_DESCRIPTIONS: CanonicalDescriptions = {
"updated_at": "Time at which the note was last updated.",
},
},
+ "business_services": {
+ "description": "A business service: a capability that spans several technical services and can be owned by several teams.",
+ "docs_url": "https://developer.pagerduty.com/api-reference",
+ "columns": _columns(
+ name="The name of the business service.",
+ description="The user-provided description of the business service.",
+ point_of_contact="The point of contact assigned to the business service.",
+ team="Reference to the team that owns the business service, if any.",
+ ),
+ },
+ "maintenance_windows": {
+ "description": "A maintenance window: a period during which one or more services do not create incidents.",
+ "docs_url": "https://developer.pagerduty.com/api-reference",
+ "columns": _columns(
+ sequence_number="The order in which the maintenance window was created.",
+ start_time="Time at which the services stop creating incidents.",
+ end_time="Time at which the services start creating incidents again.",
+ description="Description of the maintenance window.",
+ created_by="Reference to the user who created the maintenance window.",
+ services="Services that the maintenance window applies to.",
+ teams="Teams associated with the maintenance window.",
+ ),
+ },
"incident_analytics": {
"description": "Per-incident metrics from the PagerDuty Analytics API, such as time to acknowledge, time to resolve, engaged time, and escalation counts.",
"docs_url": "https://developer.pagerduty.com/api-reference",
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/pagerduty/pagerduty.py b/products/warehouse_sources/backend/temporal/data_imports/sources/pagerduty/pagerduty.py
index 9c3ac4a95cf0..307c7eee9204 100644
--- a/products/warehouse_sources/backend/temporal/data_imports/sources/pagerduty/pagerduty.py
+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/pagerduty/pagerduty.py
@@ -224,7 +224,7 @@ def _row_map(endpoint: str, config: PagerDutyEndpointConfig) -> Optional[Callabl
def _list_params(config: PagerDutyEndpointConfig, should_use_incremental_field: bool) -> dict[str, Any]:
- params: dict[str, Any] = {}
+ params: dict[str, Any] = dict(config.extra_params)
if config.supports_since:
# created_at is immutable, so an ascending sort means new rows append to the end and never
# shift pages we've already read. Sent on every sync (not just incremental ones) so full
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/pagerduty/settings.py b/products/warehouse_sources/backend/temporal/data_imports/sources/pagerduty/settings.py
index 1a8b57b42fe2..e261f17cd180 100644
--- a/products/warehouse_sources/backend/temporal/data_imports/sources/pagerduty/settings.py
+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/pagerduty/settings.py
@@ -34,6 +34,8 @@ class PagerDutyEndpointConfig:
parent: Optional[str] = None
parent_id_column: Optional[str] = None
method: Literal["GET", "POST"] = "GET"
+ # Static query params sent on every list request of the endpoint.
+ extra_params: dict[str, str] = field(default_factory=dict)
# None when rows do not arrive in ascending order of the endpoint's incremental field.
sort_mode: Optional[Literal["asc"]] = "asc"
@@ -169,6 +171,18 @@ PAGERDUTY_ENDPOINTS: dict[str, PagerDutyEndpointConfig] = {
path="/vendors",
envelope_key="vendors",
),
+ "business_services": PagerDutyEndpointConfig(
+ path="/business_services",
+ envelope_key="business_services",
+ ),
+ "maintenance_windows": PagerDutyEndpointConfig(
+ path="/maintenance_windows",
+ envelope_key="maintenance_windows",
+ # The API documents no default for `filter`, so ask for past, ongoing, and future windows
+ # explicitly. There is no `since` filter or sort param, and `start_time` moves when a window
+ # is edited, so the table is full refresh with no partition key.
+ extra_params={"filter": "all"},
+ ),
}
ENDPOINTS = tuple(PAGERDUTY_ENDPOINTS.keys())
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/pagerduty/tests/test_pagerduty.py b/products/warehouse_sources/backend/temporal/data_imports/sources/pagerduty/tests/test_pagerduty.py
index 5758e1853662..b84eb32ef569 100644
--- a/products/warehouse_sources/backend/temporal/data_imports/sources/pagerduty/tests/test_pagerduty.py
+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/pagerduty/tests/test_pagerduty.py
@@ -66,6 +66,31 @@ class TestPagination:
assert offsets[-1] == "9900"
assert "10000" not in offsets
+ @pytest.mark.parametrize(
+ "endpoint,expected_filter",
+ [
+ # Without filter=all the table could miss past or future maintenance windows.
+ ("maintenance_windows", ["all", "all"]),
+ ("business_services", [None, None]),
+ ],
+ )
+ def test_walks_pages_and_sends_static_params_on_every_page(
+ self, endpoint: str, expected_filter: list[str | None]
+ ) -> None:
+ result = _driver().run(
+ endpoint,
+ [
+ ScriptedResponse(json={endpoint: [{"id": "R1"}], "more": True}),
+ ScriptedResponse(json={endpoint: [{"id": "R2"}], "more": False}),
+ ],
+ )
+
+ assert result.raised is None
+ assert result.paths == [f"/{endpoint}", f"/{endpoint}"]
+ assert result.params("offset") == ["0", str(PAGE_SIZE)]
+ assert result.params("filter") == expected_filter
+ assert [row["id"] for row in result.rows] == ["R1", "R2"]
+
class TestResume:
def test_resumes_from_saved_offset(self) -> None: