: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.
Python ab-testingai-analyticsanalyticscdpdata-warehouseexperimentsfeature-flagsjavascriptproduct-analyticspythonreactsession-replaysurveystypescriptweb-analytics
feat(honeybadger): sync uptime checks, comments, check-ins and alarms (#111884)
Tom Owersc456075acdb8
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.mdindex 023cdfae9af9..1c9a3df37a98 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@@ -4078,21 +4078,21 @@ Note: The Redoc page at hightouch.com/docs/api-reference loads its spec from htt## Honeybadger — gaps-Today (9): `affected_users`, `deploys`, `environments`, `faults`, `notices`, `occurrences`, `outages`, `projects`, `sites`+Today (13): `affected_users`, `alarm_history`, `check_ins`, `comments`, `deploys`, `environments`, `faults`, `notices`, `occurrences`, `outages`, `projects`, `sites`, `uptime_checks`Diffed against: <https://docs.honeybadger.io/api/>- [x] `projects/{id}/occurrences` — error occurrence counts over time - Honeybadger's headline volume metric, and we already sync faults (high)- [ ] `projects/{id}/faults/{id}/occurrences` — per-fault occurrence counts over time; skipped, one request per fault for a rolling window, and per-fault history is derivable from `notices` (low)-- [ ] `projects/{id}/sites/{id}/uptime_checks` — the actual uptime measurements behind the sites table we already sync (high)+- [x] `projects/{id}/sites/{id}/uptime_checks` — the actual uptime measurements behind the sites table we already sync (high). Added as `uptime_checks` (fan-out over `sites`, incremental on `created_at`; off by default).- [x] `projects/{id}/sites/{id}/outages` — downtime events per monitored site - the core availability fact table (high)- [x] `projects/{id}/faults/{id}/affected_users` — user impact per fault, needed to rank errors by blast radius (high)- [x] `projects/{id}/environments` — lookup table resolving the environment names carried on faults and deploys (high)- [ ] `projects/{id}/reports/notices_per_day` — prebuilt daily error volume breakdown (medium)- [ ] `projects/{id}/reports/notices_by_class` — error-class breakdown dimension for triage dashboards (medium)-- [ ] `projects/{id}/check_ins` — cron/heartbeat monitor state, a separate reliability signal from faults (medium)-- [ ] `projects/{id}/alarms/{id}/history` — alarm state transition history - classic state-change fact table (medium)-- [ ] `projects/{id}/faults/{id}/comments` — triage discussion attached to faults we already sync (medium)+- [x] `projects/{id}/check_ins` — cron/heartbeat monitor state, a separate reliability signal from faults (medium). Added as `check_ins` (full refresh).+- [x] `projects/{id}/alarms/{id}/history` — alarm state transition history - classic state-change fact table (medium). Added as `alarm_history` (fan-out over alarms, full refresh; off by default).+- [x] `projects/{id}/faults/{id}/comments` — triage discussion attached to faults we already sync (medium). Added as `comments` (fan-out over `faults`, full refresh; off by default).- [ ] `teams/{id}/team_members` — membership table resolving assignee/owner references (low)- [ ] `accounts (and accounts/{id}/users)` — account-level roster for multi-account orgs (low)diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/honeybadger/canonical_descriptions.py b/products/warehouse_sources/backend/temporal/data_imports/sources/honeybadger/canonical_descriptions.pyindex 2dbb96dc338d..39c4c802302a 100644--- a/products/warehouse_sources/backend/temporal/data_imports/sources/honeybadger/canonical_descriptions.py+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/honeybadger/canonical_descriptions.py@@ -139,4 +139,63 @@ CANONICAL_DESCRIPTIONS: CanonicalDescriptions = {"headers": "Response headers returned when the check failed.",},},+ "uptime_checks": {+ "description": "The result of a single uptime check of a site from one location.",+ "docs_url": "https://docs.honeybadger.io/api/uptime/",+ "columns": {+ "project_id": "Identifier of the project the uptime check belongs to.",+ "site_id": "Identifier (UUID) of the site that was checked.",+ "created_at": "When the check ran.",+ "duration": "How long the check took to get a response.",+ "location": "Where the check ran from (e.g. Virginia, Frankfurt, Singapore).",+ "up": "Whether the check passed.",+ },+ },+ "comments": {+ "description": "A comment or activity entry on an error (fault).",+ "docs_url": "https://docs.honeybadger.io/api/comments/",+ "columns": {+ "id": "Unique identifier for the comment.",+ "project_id": "Identifier of the project the fault belongs to.",+ "fault_id": "Identifier of the fault the comment belongs to.",+ "event": "The fault event the comment records, if any.",+ "source": "Where the comment came from.",+ "notices_count": "Number of occurrences of the fault when the comment was made.",+ "created_at": "When the comment was made.",+ "author": "Name of the person who wrote the comment.",+ "body": "Text of the comment.",+ },+ },+ "check_ins": {+ "description": "A check-in that monitors a cron job or scheduled task, with its current state.",+ "docs_url": "https://docs.honeybadger.io/api/check-ins/",+ "columns": {+ "id": "Unique identifier for the check-in.",+ "project_id": "Identifier of the project the check-in belongs to.",+ "name": "Name of the check-in.",+ "slug": "Human-friendly identifier used in the check-in URL.",+ "state": "Current state of the check-in (e.g. pending, reporting, missing).",+ "schedule_type": "How the check-in is scheduled: simple or cron.",+ "reported_at": "When the check-in last reported.",+ "expected_at": "When the next report is expected.",+ "missed_count": "Number of consecutive missed reports.",+ "report_period": "For simple check-ins, how long can pass between reports before it is missing.",+ "grace_period": "Extra time allowed after the expected report before it is missing.",+ "cron_schedule": "For cron check-ins, the cron expression that defines when reports are expected.",+ "cron_timezone": "For cron check-ins, the timezone of the cron schedule.",+ "url": "URL the monitored job calls to report in.",+ },+ },+ "alarm_history": {+ "description": "An evaluation of a Honeybadger Insights alarm that changed the alarm's state.",+ "docs_url": "https://docs.honeybadger.io/api/alarms/",+ "columns": {+ "id": "Unique identifier for the trigger event.",+ "project_id": "Identifier of the project the alarm belongs to.",+ "alarm_id": "Identifier (UUID) of the alarm.",+ "state": "State of the alarm after the evaluation: ok, alarm, or error.",+ "result": "The query result that caused the state change.",+ "created_at": "When the evaluation ran.",+ },+ },}diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/honeybadger/honeybadger.py b/products/warehouse_sources/backend/temporal/data_imports/sources/honeybadger/honeybadger.pyindex b2e49de33b65..9460378d2a35 100644--- a/products/warehouse_sources/backend/temporal/data_imports/sources/honeybadger/honeybadger.py+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/honeybadger/honeybadger.py@@ -41,10 +41,11 @@ class HoneybadgerResumeConfig:project_id: int | None = Nonefault_id: int | None = Nonesite_id: str | None = None+ alarm_id: str | None = None# Fan-out parent list under a project -> the child row column / resume bookmark holding its id.-_FAN_OUT_PARENT_KEYS = {"faults": "fault_id", "sites": "site_id"}+_FAN_OUT_PARENT_KEYS = {"faults": "fault_id", "sites": "site_id", "alarms": "alarm_id"}def _make_session(api_key: str) -> requests.Session:@@ -138,11 +139,11 @@ def validate_credentials(api_key: str) -> bool:return False-def _parse_page(data: Any) -> tuple[list[Any], str | None]:+def _parse_page(data: Any, data_selector: str = "results") -> tuple[list[Any], str | None]:"""Split a response into (results, next_url). Some endpoints return a bare array with no paging."""if isinstance(data, list):return data, None- return data.get("results") or [], (data.get("links") or {}).get("next")+ return data.get(data_selector) or [], (data.get("links") or {}).get("next")def _collect_items(session: requests.Session, first_url: str, logger: FilteringBoundLogger) -> list[dict]:@@ -219,12 +220,13 @@ def _iter_pages(session: requests.Session,first_url: str,logger: FilteringBoundLogger,+ data_selector: str = "results",) -> Iterator[tuple[list[dict], str | None]]:"""Yield (results, next_url) per page. The docs note a `next` link may point at an emptypage, so empty results don't terminate the walk — only a missing `next` link does."""url: str | None = first_urlwhile url:- results, next_url = _parse_page(_fetch_page(session, url, logger))+ results, next_url = _parse_page(_fetch_page(session, url, logger), data_selector)if next_url == url:next_url = Noneyield results, next_url@@ -276,7 +278,7 @@ def _get_project_child_rows()resume_url = None # only the resumed-into project uses the saved URL- for results, next_url in _iter_pages(session, first_url, logger):+ for results, next_url in _iter_pages(session, first_url, logger, config.data_selector):if not results:continueif config.time_series:@@ -302,7 +304,7 @@ def _get_nested_rows(params: dict[str, Any],parent_params: dict[str, Any],) -> Iterator[list[dict]]:- """Two-level fan-out: projects -> faults or sites -> {endpoint}.+ """Two-level fan-out: projects -> faults, sites, or alarms -> {endpoint}.On incremental syncs of fault children, the watermark also bounds the fault enumeration(`occurred_after`): only faults whose last notice is newer than the watermark can have new@@ -347,7 +349,7 @@ def _get_nested_rows()resume_url = None- for results, next_url in _iter_pages(session, first_url, logger):+ for results, next_url in _iter_pages(session, first_url, logger, config.data_selector):if not results:continueyield [diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/honeybadger/settings.py b/products/warehouse_sources/backend/temporal/data_imports/sources/honeybadger/settings.pyindex f8e193bec2a2..e40cb2504ba3 100644--- a/products/warehouse_sources/backend/temporal/data_imports/sources/honeybadger/settings.py+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/honeybadger/settings.py@@ -19,9 +19,12 @@ class HoneybadgerEndpointConfig:# Fan-out parent field -> column injected into each child row.parent_fields: dict[str, str] = field(default_factory=dict)partition_key: str | None = None # Stable creation-time field; never a mutating timestamp- fan_out_parent: Literal["faults", "sites"] | None = None # Two-level fan-out: projects -> {parent} -> {endpoint}+ # Two-level fan-out: projects -> {parent} -> {endpoint}+ fan_out_parent: Literal["faults", "sites", "alarms"] | None = None# False for endpoints that return a bare JSON array with no `limit` / `links.next` paging.paginated: bool = True+ # Key of the row array in a wrapped response.+ data_selector: str = "results"# Response is `[epoch_seconds, count]` pairs instead of objects.time_series: bool = Falsequery_params: dict[str, str] = field(default_factory=dict)@@ -146,6 +149,51 @@ HONEYBADGER_ENDPOINTS: dict[str, HoneybadgerEndpointConfig] = {partition_key="created_at",fan_out_parent="sites",),+ "uptime_checks": HoneybadgerEndpointConfig(+ name="uptime_checks",+ path="/projects/{project_id}/sites/{site_id}/uptime_checks",+ # Individual check results have no id; a site is checked once per location per run.+ primary_keys=["project_id", "site_id", "created_at", "location"],+ incremental_fields=[_created_at_field],+ incremental_params={"created_at": "created_after"},+ default_incremental_field="created_at",+ partition_key="created_at",+ fan_out_parent="sites",+ # A site checked every minute from every location produces thousands of rows a day,+ # 25 per request against a 360 req/hour quota — opt-in only.+ should_sync_default=False,+ ),+ "comments": HoneybadgerEndpointConfig(+ name="comments",+ path="/projects/{project_id}/faults/{fault_id}/comments",+ primary_keys=["project_id", "fault_id", "id"],+ # The comments list has no server-side timestamp filter, and new comments don't move the+ # fault's last notice time, so neither the child nor the fault listing can be bounded.+ incremental_fields=[],+ partition_key="created_at",+ fan_out_parent="faults",+ # One request per fault against a 360 req/hour quota — opt-in only.+ should_sync_default=False,+ ),+ "check_ins": HoneybadgerEndpointConfig(+ name="check_ins",+ path="/projects/{project_id}/check_ins",+ primary_keys=["project_id", "id"],+ # Check-ins are monitor definitions plus current state, with no timestamp filter.+ incremental_fields=[],+ ),+ "alarm_history": HoneybadgerEndpointConfig(+ name="alarm_history",+ path="/projects/{project_id}/alarms/{alarm_id}/history",+ primary_keys=["project_id", "alarm_id", "id"],+ # The history list has no server-side timestamp filter.+ incremental_fields=[],+ partition_key="created_at",+ fan_out_parent="alarms",+ data_selector="triggers",+ # Alarms are part of Honeybadger Insights, which not every account uses — opt-in only.+ should_sync_default=False,+ ),}ENDPOINTS = tuple(HONEYBADGER_ENDPOINTS.keys())diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/honeybadger/source.py b/products/warehouse_sources/backend/temporal/data_imports/sources/honeybadger/source.pyindex 7b97b7099570..5d5d68fb4d9f 100644--- a/products/warehouse_sources/backend/temporal/data_imports/sources/honeybadger/source.py+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/honeybadger/source.py@@ -46,11 +46,11 @@ class HoneybadgerSource(ResumableSource[HoneybadgerSourceConfig, HoneybadgerResucategory=DataWarehouseSourceCategory.ENGINEERING___MONITORING,label="Honeybadger",releaseStatus=ReleaseStatus.ALPHA,- caption="""Enter your Honeybadger personal authentication token to pull your error monitoring data (projects, environments, errors, occurrences, affected users, deployments, uptime checks, and outages) into the PostHog Data warehouse.+ caption="""Enter your Honeybadger personal authentication token to pull your error monitoring data (projects, environments, errors, occurrences, affected users, comments, deployments, uptime checks and their results, outages, check-ins, and alarm history) into the PostHog Data warehouse.You can find your personal authentication token on your [Honeybadger profile page](https://app.honeybadger.io/users/edit).-Note that Honeybadger's API is limited to 360 requests per hour, so large backfills (especially of the notices and affected_users tables) can take a while.""",+Note that Honeybadger's API is limited to 360 requests per hour, so large backfills (especially of the notices, affected_users, comments, and uptime_checks tables) can take a while.""",iconPath="/static/services/honeybadger.png",docsUrl="https://posthog.com/docs/cdp/sources/honeybadger",fields=cast(@@ -110,6 +110,18 @@ Note that Honeybadger's API is limited to 360 requests per hour, so large backfi"Daily error occurrence counts per project. Honeybadger only serves the most recent month, ""so each sync replaces it; use the notices table for older history")+ if endpoint == "uptime_checks":+ return (+ "One row per uptime check result, per site and location. Frequent checks produce many rows, "+ "so syncing is slow against Honeybadger's 360 requests/hour limit. Prefer incremental sync"+ )+ if endpoint == "comments":+ return (+ "Comments on each error. Fetched per fault with no time filter, so every sync is slow "+ "against Honeybadger's 360 requests/hour limit"+ )+ if endpoint == "alarm_history":+ return "State changes of each Honeybadger Insights alarm"return Noneschemas = [diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/honeybadger/tests/test_honeybadger.py b/products/warehouse_sources/backend/temporal/data_imports/sources/honeybadger/tests/test_honeybadger.pyindex a8c3395668b1..4576b777d727 100644--- a/products/warehouse_sources/backend/temporal/data_imports/sources/honeybadger/tests/test_honeybadger.py+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/honeybadger/tests/test_honeybadger.py@@ -496,20 +496,21 @@ class TestHoneybadger:]manager.save_state.assert_called_once_with(HoneybadgerResumeConfig(project_id=1, fault_id=11))- def test_outages_fan_out_over_sites(self) -> None:- outages_url = f"{HONEYBADGER_BASE_URL}/projects/1/sites/site-a/outages?limit=25&created_after={WATERMARK_TS}"- next_url = f"{HONEYBADGER_BASE_URL}/projects/1/sites/site-a/outages?limit=25&page=2"+ @pytest.mark.parametrize("endpoint", ["outages", "uptime_checks"])+ def test_site_children_fan_out_over_sites(self, endpoint: str) -> None:+ child_url = f"{HONEYBADGER_BASE_URL}/projects/1/sites/site-a/{endpoint}?limit=25&created_after={WATERMARK_TS}"+ next_url = f"{HONEYBADGER_BASE_URL}/projects/1/sites/site-a/{endpoint}?limit=25&page=2"routes = {f"{HONEYBADGER_BASE_URL}/projects?limit=25": {"results": [{"id": 1}], "links": {}},- # The sites list has no time filter, so it is not bounded by the outage watermark.+ # The sites list has no time filter, so it is not bounded by the child watermark.f"{HONEYBADGER_BASE_URL}/projects/1/sites?limit=25": {"results": [{"id": "site-a"}], "links": {}},- outages_url: {"results": [{"created_at": "2023-11-15T00:00:00Z"}], "links": {"next": next_url}},+ child_url: {"results": [{"created_at": "2023-11-15T00:00:00Z"}], "links": {"next": next_url}},next_url: {"results": [{"created_at": "2023-11-14T23:00:00Z"}], "links": {}},}batches, _, manager = _run(routes,- "outages",+ endpoint,should_use_incremental_field=True,db_incremental_field_last_value=WATERMARK,incremental_field="created_at",@@ -523,6 +524,35 @@ class TestHoneybadger:HoneybadgerResumeConfig(next_url=next_url, project_id=1, site_id="site-a"))+ def test_alarm_history_reads_triggers_and_resumes_from_alarm_bookmark(self) -> None:+ next_url = f"{HONEYBADGER_BASE_URL}/projects/1/alarms/alarm-b/history?limit=25&page=2"+ routes = {+ f"{HONEYBADGER_BASE_URL}/projects?limit=25": {"results": [{"id": 1}], "links": {}},+ f"{HONEYBADGER_BASE_URL}/projects/1/alarms?limit=25": {+ "results": [{"id": "alarm-a"}, {"id": "alarm-b"}],+ "links": {},+ },+ # History pages wrap their rows in `triggers`, not `results`.+ f"{HONEYBADGER_BASE_URL}/projects/1/alarms/alarm-b/history?limit=25": {+ "triggers": [{"id": "trigger-2", "state": "alarm"}],+ "links": {"next": next_url},+ },+ next_url: {"triggers": [{"id": "trigger-1", "state": "ok"}], "links": {}},+ }++ batches, session, manager = _run(+ routes, "alarm_history", manager=_make_manager(HoneybadgerResumeConfig(project_id=1, alarm_id="alarm-b"))+ )++ assert f"{HONEYBADGER_BASE_URL}/projects/1/alarms/alarm-a/history?limit=25" not in session.calls+ assert batches == [+ [{"project_id": 1, "alarm_id": "alarm-b", "id": "trigger-2", "state": "alarm"}],+ [{"project_id": 1, "alarm_id": "alarm-b", "id": "trigger-1", "state": "ok"}],+ ]+ manager.save_state.assert_called_once_with(+ HoneybadgerResumeConfig(next_url=next_url, project_id=1, alarm_id="alarm-b")+ )+def test_outages_resume_from_site_bookmark(self) -> None:resume_url = f"{HONEYBADGER_BASE_URL}/projects/1/sites/site-b/outages?limit=25&page=3"routes = {diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/honeybadger/tests/test_honeybadger_source.py b/products/warehouse_sources/backend/temporal/data_imports/sources/honeybadger/tests/test_honeybadger_source.pyindex d3fa13d7d974..46c15315cebc 100644--- a/products/warehouse_sources/backend/temporal/data_imports/sources/honeybadger/tests/test_honeybadger_source.py+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/honeybadger/tests/test_honeybadger_source.py@@ -39,14 +39,14 @@ class TestHoneybadgerSource:assert schemas[endpoint].supports_append is Falseassert schemas[endpoint].incremental_fields == []- def test_per_fault_tables_are_opt_in_by_default(self) -> None:+ def test_high_request_tables_are_opt_in_by_default(self) -> None:schemas = {s.name: s for s in self.source.get_schemas(self.config, self.team_id)}- # Per-fault tables fan out one request per fault against a 360 req/hour quota, so they- # must not be part of the default table selection.- per_fault = {"notices", "affected_users"}- assert all(schemas[name].should_sync_default is False for name in per_fault)- assert all(schema.should_sync_default for name, schema in schemas.items() if name not in per_fault)+ # These tables cost one or more requests per fault, site, or alarm against a 360 req/hour+ # quota, so they must not be part of the default table selection.+ opt_in = {"notices", "affected_users", "comments", "uptime_checks", "alarm_history"}+ assert all(schemas[name].should_sync_default is False for name in opt_in)+ assert all(schema.should_sync_default for name, schema in schemas.items() if name not in opt_in)def test_get_schemas_filtered_by_names(self) -> None:schemas = self.source.get_schemas(self.config, self.team_id, names=["faults"])