: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(warehouse-sources): add honeybadger environments, occurrences, affected users and outages tables (#111304)
Tom Owers52d6ae9d10ad
diff --git a/posthog/test/repo_invariants/dataclass_frozen_baseline.txt b/posthog/test/repo_invariants/dataclass_frozen_baseline.txtindex 231ffb33a0ad..0a49f301202e 100644--- a/posthog/test/repo_invariants/dataclass_frozen_baseline.txt+++ b/posthog/test/repo_invariants/dataclass_frozen_baseline.txt@@ -664,8 +664,6 @@1 products/warehouse_sources/backend/temporal/data_imports/sources/hibob/settings.py1 products/warehouse_sources/backend/temporal/data_imports/sources/hightouch/hightouch.py1 products/warehouse_sources/backend/temporal/data_imports/sources/hightouch/settings.py-1 products/warehouse_sources/backend/temporal/data_imports/sources/honeybadger/honeybadger.py-1 products/warehouse_sources/backend/temporal/data_imports/sources/honeybadger/settings.py1 products/warehouse_sources/backend/temporal/data_imports/sources/honeycomb/honeycomb.py1 products/warehouse_sources/backend/temporal/data_imports/sources/honeycomb/settings.py1 products/warehouse_sources/backend/temporal/data_imports/sources/hookdeck/hookdeck.pydiff --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 65d28f7e028f..1580c6f5f9af 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,15 +4078,16 @@ Note: The Redoc page at hightouch.com/docs/api-reference loads its spec from htt## Honeybadger — gaps-Today (5): `deploys`, `faults`, `notices`, `projects`, `sites`+Today (9): `affected_users`, `deploys`, `environments`, `faults`, `notices`, `occurrences`, `outages`, `projects`, `sites`Diffed against: <https://docs.honeybadger.io/api/>-- [ ] `projects/{id}/faults/{id}/occurrences (and projects/{id}/occurrences)` — error occurrence counts over time - Honeybadger's headline volume metric, and we already sync faults (high)+- [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)-- [ ] `projects/{id}/sites/{id}/outages` — downtime events per monitored site - the core availability fact table (high)-- [ ] `projects/{id}/faults/{id}/affected_users` — user impact per fault, needed to rank errors by blast radius (high)-- [ ] `projects/{id}/environments` — lookup table resolving the environment names carried on faults and deploys (high)+- [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)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 6be7180d4e34..2dbb96dc338d 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@@ -93,4 +93,50 @@ CANONICAL_DESCRIPTIONS: CanonicalDescriptions = {"last_checked_at": "When the site was last checked.",},},+ "environments": {+ "description": "An environment (e.g. production, staging) that errors in a project are grouped by.",+ "docs_url": "https://docs.honeybadger.io/api/environments/",+ "columns": {+ "id": "Unique identifier for the environment.",+ "project_id": "Identifier of the project the environment belongs to.",+ "name": "Name of the environment (e.g. production).",+ "notifications": "Whether notifications are enabled for errors in this environment.",+ "created_at": "When the environment was recorded.",+ "updated_at": "When the environment was last updated.",+ },+ },+ "occurrences": {+ "description": "Number of error occurrences in a project per one-day bucket, for the most recent month.",+ "docs_url": "https://docs.honeybadger.io/api/projects/",+ "columns": {+ "project_id": "Identifier of the project the counts belong to.",+ "bucket_start": "Start of the one-day bucket (UTC).",+ "count": "Number of error occurrences in the bucket, across all environments.",+ },+ },+ "affected_users": {+ "description": "A user affected by an error (fault), with the number of occurrences that user hit.",+ "docs_url": "https://docs.honeybadger.io/api/faults/",+ "columns": {+ "project_id": "Identifier of the project the fault belongs to.",+ "fault_id": "Identifier of the fault the user was affected by.",+ "user": "The affected user, as reported in the error context (e.g. user id or email).",+ "count": "Number of occurrences of the fault for this user.",+ "fault_last_notice_at": "Timestamp of the fault's most recent occurrence when the row was synced.",+ },+ },+ "outages": {+ "description": "A period during which an uptime check ('site') was down.",+ "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 uptime check that went down.",+ "down_at": "When the site went down.",+ "up_at": "When the site came back up.",+ "created_at": "When the outage was recorded.",+ "status": "HTTP status code returned when the check failed.",+ "reason": "Why the check failed.",+ "headers": "Response headers returned when the check failed.",+ },+ },}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 9014dea183a2..b2e49de33b65 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@@ -32,7 +32,7 @@ class HoneybadgerRetryableError(Exception):pass[email protected](frozen=True)class HoneybadgerResumeConfig:# Next page URL to fetch. None means "start the bookmarked resource at its first page".next_url: str | None = None@@ -40,6 +40,11 @@ class HoneybadgerResumeConfig:# and the retry can't resume us into the wrong project/fault.project_id: int | None = Nonefault_id: int | None = None+ site_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"}def _make_session(api_key: str) -> requests.Session:@@ -83,7 +88,7 @@ def _to_unix_timestamp(value: Any) -> int:wait=wait_exponential_jitter(initial=2, max=30),reraise=True,)-def _fetch_page(session: requests.Session, url: str, logger: FilteringBoundLogger) -> dict:+def _fetch_page(session: requests.Session, url: str, logger: FilteringBoundLogger) -> Any:# Honeybadger paginates with a root-relative `links.next` (e.g. /v2/projects/1/faults?page=2),# so resolve against the API base before validating the origin. A foreign absolute URL keeps# its own netloc through urljoin, so it is still refused below.@@ -133,16 +138,26 @@ def validate_credentials(api_key: str) -> bool:return False-def _collect_ids(session: requests.Session, first_url: str, logger: FilteringBoundLogger) -> list[Any]:- """Walk every page of a list endpoint and return the ids, following `links.next`."""- ids: list[Any] = []+def _parse_page(data: Any) -> 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")+++def _collect_items(session: requests.Session, first_url: str, logger: FilteringBoundLogger) -> list[dict]:+ """Walk every page of a list endpoint and return the items, following `links.next`."""+ items: list[dict] = []url: str | None = first_urlwhile url:- data = _fetch_page(session, url, logger)- ids.extend(item["id"] for item in data.get("results") or [])- next_url = (data.get("links") or {}).get("next")+ results, next_url = _parse_page(_fetch_page(session, url, logger))+ items.extend(results)url = next_url if next_url != url else None- return ids+ return items+++def _collect_ids(session: requests.Session, first_url: str, logger: FilteringBoundLogger) -> list[Any]:+ return [item["id"] for item in _collect_items(session, first_url, logger)]def _build_params(@@ -152,7 +167,8 @@ def _build_params(db_incremental_field_last_value: Any,incremental_field: str | None,) -> dict[str, Any]:- params: dict[str, Any] = {"limit": PAGE_LIMIT}+ params: dict[str, Any] = {"limit": PAGE_LIMIT} if config.paginated else {}+ params.update(config.query_params)if not should_use_incremental_field or db_incremental_field_last_value is None:return params@@ -160,6 +176,8 @@ def _build_params(field_name = incremental_field or config.default_incremental_fieldquery_param = config.incremental_params.get(field_name) if field_name else Noneif query_param is None:+ if field_name in config.parent_incremental_params:+ return params# No server-side filter for the chosen cursor — walk the full history and let the# merge dedupe on the primary key rather than silently filtering on the wrong field.logger.warning(@@ -172,6 +190,31 @@ def _build_params(return params+def _build_parent_params(+ config: HoneybadgerEndpointConfig,+ should_use_incremental_field: bool,+ db_incremental_field_last_value: Any,+ incremental_field: str | None,+) -> dict[str, Any]:+ """Params for the fan-out parent list, bounded by the child's watermark where the parent allows it."""+ params: dict[str, Any] = {"limit": PAGE_LIMIT}+ if not should_use_incremental_field or db_incremental_field_last_value is None:+ return params++ field_name = incremental_field or config.default_incremental_field+ query_param = config.parent_incremental_params.get(field_name) if field_name else None+ if query_param is not None:+ params[query_param] = _to_unix_timestamp(db_incremental_field_last_value)+ return params+++def _time_series_rows(project_id: Any, pairs: list[Any]) -> list[dict]:+ return [+ {"project_id": project_id, "bucket_start": datetime.fromtimestamp(timestamp, tz=UTC), "count": count}+ for timestamp, count in pairs+ ]++def _iter_pages(session: requests.Session,first_url: str,@@ -181,9 +224,7 @@ def _iter_pages(page, so empty results don't terminate the walk — only a missing `next` link does."""url: str | None = first_urlwhile url:- data = _fetch_page(session, url, logger)- results = data.get("results") or []- next_url = (data.get("links") or {}).get("next")+ results, next_url = _parse_page(_fetch_page(session, url, logger))if next_url == url:next_url = Noneyield results, next_url@@ -238,9 +279,11 @@ def _get_project_child_rows(for results, next_url in _iter_pages(session, first_url, logger):if not results:continue- # Inject the parent project id: sites don't carry it, and it's part of the- # composite primary key. Faults/deploys already include it (theirs wins).- yield [{"project_id": project_id, **item} for item in results]+ if config.time_series:+ yield _time_series_rows(project_id, results)+ else:+ # The traversal determines the parent, so API rows cannot change their project attribution.+ yield [{**item, "project_id": project_id} for item in results]if next_url:resumable_source_manager.save_state(HoneybadgerResumeConfig(next_url=next_url, project_id=project_id))@@ -249,69 +292,76 @@ def _get_project_child_rows(resumable_source_manager.save_state(HoneybadgerResumeConfig(project_id=remaining[index + 1]))-def _get_notice_rows(+def _get_nested_rows(session: requests.Session,logger: FilteringBoundLogger,resumable_source_manager: ResumableSourceManager[HoneybadgerResumeConfig],resume: HoneybadgerResumeConfig | None,config: HoneybadgerEndpointConfig,+ fan_out_parent: str,params: dict[str, Any],+ parent_params: dict[str, Any],) -> Iterator[list[dict]]:- """Two-level fan-out: projects -> faults -> notices.+ """Two-level fan-out: projects -> faults or sites -> {endpoint}.- On incremental syncs the notice watermark also bounds the fault enumeration+ 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- notices, which keeps the per-fault request count away from the 360 req/hour quota.+ rows, which keeps the per-fault request count away from the 360 req/hour quota."""+ parent_key = _FAN_OUT_PARENT_KEYS[fan_out_parent]project_ids = _collect_ids(session, _build_url(f"{HONEYBADGER_BASE_URL}/projects", {"limit": PAGE_LIMIT}), logger)- fault_params: dict[str, Any] = {"limit": PAGE_LIMIT}- created_after = params.get("created_after")- if created_after is not None:- fault_params["occurred_after"] = created_after-remaining_projects = project_ids- resume_fault_id: int | None = None+ resume_parent_id: Any = Noneresume_url: str | None = Noneif resume is not None and resume.project_id is not None and resume.project_id in project_ids:remaining_projects = project_ids[project_ids.index(resume.project_id) :]- resume_fault_id = resume.fault_id+ resume_parent_id = getattr(resume, parent_key)resume_url = resume.next_urlfor project_index, project_id in enumerate(remaining_projects):- fault_ids = _collect_ids(+ parents = _collect_items(session,- _build_url(f"{HONEYBADGER_BASE_URL}/projects/{project_id}/faults", fault_params),+ _build_url(f"{HONEYBADGER_BASE_URL}/projects/{project_id}/{fan_out_parent}", parent_params),logger,)-- remaining_faults = fault_ids- if resume_fault_id is not None and resume_fault_id in fault_ids:- remaining_faults = fault_ids[fault_ids.index(resume_fault_id) :]+ parent_ids = [parent["id"] for parent in parents]+ parent_columns = {+ parent["id"]: {column: parent.get(field_name) for field_name, column in config.parent_fields.items()}+ for parent in parents+ }++ remaining_parents = parent_ids+ if resume_parent_id is not None and resume_parent_id in parent_ids:+ remaining_parents = parent_ids[parent_ids.index(resume_parent_id) :]else:- # No (or unresolvable) fault bookmark: the saved page URL belongs to a fault we're- # not resuming into, so it must not seed another fault's pagination.+ # No (or unresolvable) parent bookmark: the saved page URL belongs to a parent we're+ # not resuming into, so it must not seed another parent's pagination.resume_url = None- resume_fault_id = None # only the resumed-into project uses the fault bookmark+ resume_parent_id = None # only the resumed-into project uses the parent bookmark- for fault_index, fault_id in enumerate(remaining_faults):+ for parent_index, parent_id in enumerate(remaining_parents):first_url = resume_url or _build_url(- f"{HONEYBADGER_BASE_URL}{config.path.format(project_id=project_id, fault_id=fault_id)}", params+ f"{HONEYBADGER_BASE_URL}{config.path.format(project_id=project_id, **{parent_key: parent_id})}",+ params,)resume_url = Nonefor results, next_url in _iter_pages(session, first_url, logger):if not results:continue- yield [{"project_id": project_id, **item} for item in results]+ yield [+ {**item, "project_id": project_id, parent_key: parent_id, **parent_columns[parent_id]}+ for item in results+ ]if next_url:resumable_source_manager.save_state(- HoneybadgerResumeConfig(next_url=next_url, project_id=project_id, fault_id=fault_id)+ HoneybadgerResumeConfig(next_url=next_url, project_id=project_id, **{parent_key: parent_id}))- if fault_index + 1 < len(remaining_faults):+ if parent_index + 1 < len(remaining_parents):resumable_source_manager.save_state(- HoneybadgerResumeConfig(project_id=project_id, fault_id=remaining_faults[fault_index + 1])+ HoneybadgerResumeConfig(project_id=project_id, **{parent_key: remaining_parents[parent_index + 1]}))if project_index + 1 < len(remaining_projects):@@ -339,8 +389,13 @@ def get_rows()resume = resumable_source_manager.load_state() if resumable_source_manager.can_resume() else None- if config.fan_out_over_faults:- yield from _get_notice_rows(session, logger, resumable_source_manager, resume, config, params)+ if config.fan_out_parent is not None:+ parent_params = _build_parent_params(+ config, should_use_incremental_field, db_incremental_field_last_value, incremental_field+ )+ yield from _get_nested_rows(+ session, logger, resumable_source_manager, resume, config, config.fan_out_parent, params, parent_params+ )elif "{project_id}" in config.path:yield from _get_project_child_rows(session, logger, resumable_source_manager, resume, config, params)else: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 0f3af7dad708..f8e193bec2a2 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@@ -1,20 +1,30 @@from dataclasses import dataclass, field+from typing import Literalfrom products.warehouse_sources.backend.types import IncrementalField, IncrementalFieldType-@dataclass+@dataclass(frozen=True)class HoneybadgerEndpointConfig:name: str- # Path template under the v2 base URL; `{project_id}` / `{fault_id}` are filled in by the fan-out.+ # Path template under the v2 base URL; `{project_id}` / `{fault_id}` / `{site_id}` are filled in by the fan-out.path: strprimary_keys: list[str] = field(default_factory=lambda: ["id"])incremental_fields: list[IncrementalField] = field(default_factory=list)# Incremental field name -> query param that server-side filters on it (Unix timestamp).incremental_params: dict[str, str] = field(default_factory=dict)default_incremental_field: str | None = None+ # Incremental field name -> query param on the fan-out parent list that the watermark also bounds.+ parent_incremental_params: dict[str, str] = field(default_factory=dict)+ # 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_over_faults: bool = False # Two-level fan-out: projects -> faults -> {endpoint}+ fan_out_parent: Literal["faults", "sites"] | None = None # Two-level fan-out: projects -> {parent} -> {endpoint}+ # False for endpoints that return a bare JSON array with no `limit` / `links.next` paging.+ paginated: bool = True+ # Response is `[epoch_seconds, count]` pairs instead of objects.+ time_series: bool = False+ query_params: dict[str, str] = field(default_factory=dict)should_sync_default: bool = True@@ -61,8 +71,9 @@ HONEYBADGER_ENDPOINTS: dict[str, HoneybadgerEndpointConfig] = {incremental_fields=[_created_at_field],incremental_params={"created_at": "created_after"},default_incremental_field="created_at",+ parent_incremental_params={"created_at": "occurred_after"},partition_key="created_at",- fan_out_over_faults=True,+ fan_out_parent="faults",# One request per fault minimum against a 360 req/hour quota — opt-in only.should_sync_default=False,),@@ -83,6 +94,58 @@ HONEYBADGER_ENDPOINTS: dict[str, HoneybadgerEndpointConfig] = {# The sites (uptime checks) list has no server-side timestamp filter.incremental_fields=[],),+ "environments": HoneybadgerEndpointConfig(+ name="environments",+ path="/projects/{project_id}/environments",+ primary_keys=["project_id", "id"],+ incremental_fields=[],+ partition_key="created_at",+ ),+ "occurrences": HoneybadgerEndpointConfig(+ name="occurrences",+ path="/projects/{project_id}/occurrences",+ primary_keys=["project_id", "bucket_start"],+ # The API only serves a rolling window of buckets with no time filter; `month` returns+ # the most recent month in one-day buckets.+ incremental_fields=[],+ partition_key="bucket_start",+ paginated=False,+ time_series=True,+ query_params={"period": "month"},+ ),+ "affected_users": HoneybadgerEndpointConfig(+ name="affected_users",+ path="/projects/{project_id}/faults/{fault_id}/affected_users",+ primary_keys=["project_id", "fault_id", "user"],+ # The endpoint has no time filter, but a fault's affected users only change when it gets+ # a new notice, so the fault's last notice time bounds the fault enumeration instead.+ incremental_fields=[+ {+ "label": "fault_last_notice_at",+ "type": IncrementalFieldType.DateTime,+ "field": "fault_last_notice_at",+ "field_type": IncrementalFieldType.DateTime,+ }+ ],+ default_incremental_field="fault_last_notice_at",+ parent_incremental_params={"fault_last_notice_at": "occurred_after"},+ parent_fields={"last_notice_at": "fault_last_notice_at"},+ fan_out_parent="faults",+ paginated=False,+ # One request per fault against a 360 req/hour quota — opt-in only.+ should_sync_default=False,+ ),+ "outages": HoneybadgerEndpointConfig(+ name="outages",+ path="/projects/{project_id}/sites/{site_id}/outages",+ # Outages have no id of their own.+ primary_keys=["project_id", "site_id", "created_at"],+ incremental_fields=[_created_at_field],+ incremental_params={"created_at": "created_after"},+ default_incremental_field="created_at",+ partition_key="created_at",+ fan_out_parent="sites",+ ),}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 5973e8a5dd5d..7b97b7099570 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, errors, occurrences, deployments, and uptime checks) into the PostHog Data warehouse.+ 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.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 table) can take a while.""",+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.""",iconPath="/static/services/honeybadger.png",docsUrl="https://posthog.com/docs/cdp/sources/honeybadger",fields=cast(@@ -99,6 +99,17 @@ Note that Honeybadger's API is limited to 360 requests per hour, so large backfi"One row per error occurrence. Fetched per fault, so syncing large accounts is slow ""against Honeybadger's 360 requests/hour limit — prefer incremental sync")+ if endpoint == "affected_users":+ return (+ "Users affected by each error, with an occurrence count per user. Fetched per fault, so "+ "syncing large accounts is slow against Honeybadger's 360 requests/hour limit — prefer "+ "incremental sync"+ )+ if endpoint == "occurrences":+ return (+ "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"+ )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 0686d85c7de9..a8c3395668b1 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@@ -293,7 +293,7 @@ class TestHoneybadger:routes = {f"{HONEYBADGER_BASE_URL}/projects?limit=25": {"results": [{"id": 7}], "links": {}},f"{HONEYBADGER_BASE_URL}/projects/7/sites?limit=25": {- "results": [{"id": "site-uuid", "name": "Main site"}],+ "results": [{"id": "site-uuid", "project_id": 999, "name": "Main site"}],"links": {},},}@@ -451,6 +451,113 @@ class TestHoneybadger:assert "https://app.honeybadger.io/stale" not in session.callsassert batches == [[{"project_id": 1, "id": "uuid-1", "fault_id": 10}]]+ def test_affected_users_fan_out_injects_fault_columns_and_bounds_faults(self) -> None:+ faults_url = f"{HONEYBADGER_BASE_URL}/projects/1/faults?limit=25&occurred_after={WATERMARK_TS}"+ routes = {+ f"{HONEYBADGER_BASE_URL}/projects?limit=25": {"results": [{"id": 1}], "links": {}},+ faults_url: {+ "results": [+ {"id": 10, "last_notice_at": "2023-11-15T00:00:00Z"},+ {"id": 11, "last_notice_at": "2023-11-16T00:00:00Z"},+ ],+ "links": {},+ },+ # Bare arrays with no paging, and the endpoint takes no time filter.+ f"{HONEYBADGER_BASE_URL}/projects/1/faults/10/affected_users": [+ {+ "project_id": 999,+ "fault_id": 999,+ "fault_last_notice_at": "2020-01-01T00:00:00Z",+ "user": "[email protected]",+ "count": 4,+ }+ ],+ f"{HONEYBADGER_BASE_URL}/projects/1/faults/11/affected_users": [],+ }++ batches, _, manager = _run(+ routes,+ "affected_users",+ should_use_incremental_field=True,+ db_incremental_field_last_value=WATERMARK,+ incremental_field="fault_last_notice_at",+ )++ assert batches == [+ [+ {+ "project_id": 1,+ "fault_id": 10,+ "fault_last_notice_at": "2023-11-15T00:00:00Z",+ "user": "[email protected]",+ "count": 4,+ }+ ]+ ]+ 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"+ 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.+ 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}},+ next_url: {"results": [{"created_at": "2023-11-14T23:00:00Z"}], "links": {}},+ }++ batches, _, manager = _run(+ routes,+ "outages",+ should_use_incremental_field=True,+ db_incremental_field_last_value=WATERMARK,+ incremental_field="created_at",+ )++ assert batches == [+ [{"project_id": 1, "site_id": "site-a", "created_at": "2023-11-15T00:00:00Z"}],+ [{"project_id": 1, "site_id": "site-a", "created_at": "2023-11-14T23:00:00Z"}],+ ]+ manager.save_state.assert_called_once_with(+ HoneybadgerResumeConfig(next_url=next_url, project_id=1, site_id="site-a")+ )++ 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 = {+ f"{HONEYBADGER_BASE_URL}/projects?limit=25": {"results": [{"id": 1}], "links": {}},+ f"{HONEYBADGER_BASE_URL}/projects/1/sites?limit=25": {+ "results": [{"id": "site-a"}, {"id": "site-b"}],+ "links": {},+ },+ resume_url: {"results": [{"created_at": "2023-11-15T00:00:00Z"}], "links": {}},+ }++ batches, session, _ = _run(+ routes,+ "outages",+ manager=_make_manager(HoneybadgerResumeConfig(next_url=resume_url, project_id=1, site_id="site-b")),+ )++ assert f"{HONEYBADGER_BASE_URL}/projects/1/sites/site-a/outages?limit=25" not in session.calls+ assert batches == [[{"project_id": 1, "site_id": "site-b", "created_at": "2023-11-15T00:00:00Z"}]]++ def test_occurrences_maps_time_series_pairs_to_rows(self) -> None:+ routes = {+ f"{HONEYBADGER_BASE_URL}/projects?limit=25": {"results": [{"id": 1}], "links": {}},+ f"{HONEYBADGER_BASE_URL}/projects/1/occurrences?period=month": [[1510963200, 3], [1511049600, 0]],+ }++ batches, _, _ = _run(routes, "occurrences")++ assert batches == [+ [+ {"project_id": 1, "bucket_start": datetime(2017, 11, 18, tzinfo=UTC), "count": 3},+ {"project_id": 1, "bucket_start": datetime(2017, 11, 19, tzinfo=UTC), "count": 0},+ ]+ ]+def test_mid_fault_checkpoint_saved_after_yield(self) -> None:next_url = f"{HONEYBADGER_BASE_URL}/projects/1/faults?limit=25&page=2"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 d372ff039859..d3fa13d7d974 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,13 +39,14 @@ class TestHoneybadgerSource:assert schemas[endpoint].supports_append is Falseassert schemas[endpoint].incremental_fields == []- def test_notices_are_opt_in_by_default(self) -> None:+ def test_per_fault_tables_are_opt_in_by_default(self) -> None:schemas = {s.name: s for s in self.source.get_schemas(self.config, self.team_id)}- # Notices fan out one request per fault against a 360 req/hour quota, so they must- # not be part of the default table selection.- assert schemas["notices"].should_sync_default is False- assert all(schema.should_sync_default for name, schema in schemas.items() if name != "notices")+ # 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)def test_get_schemas_filtered_by_names(self) -> None:schemas = self.source.get_schemas(self.config, self.team_id, names=["faults"])