: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): support Datadog API version v2 (#74164)
Tom Owers28fa751eaf70
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/datadog/settings.py b/products/warehouse_sources/backend/temporal/data_imports/sources/datadog/settings.pyindex 53be7ec54bae..fdc8b91129d2 100644--- a/products/warehouse_sources/backend/temporal/data_imports/sources/datadog/settings.py+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/datadog/settings.py@@ -178,6 +178,16 @@ DATADOG_ENDPOINTS: dict[str, DatadogEndpointConfig] = {),}+# Vendor API versions. Datadog serves each resource under a fixed API version, so this source+# already reads logs/audit_logs/events/users/incidents/downtimes at /api/v2 and+# dashboards/monitors/slos/synthetic_tests at /api/v1 (those four have no v2 list endpoint). Both+# labels therefore resolve to the identical request paths; the pin only selects the version a new+# source is stamped with and drives the deprecation warning for v1.+DATADOG_API_VERSION_V1 = "v1"+DATADOG_API_VERSION_V2 = "v2"+DATADOG_SUPPORTED_VERSIONS = (DATADOG_API_VERSION_V1, DATADOG_API_VERSION_V2)+DATADOG_DEFAULT_VERSION = DATADOG_API_VERSION_V2+ENDPOINTS = tuple(DATADOG_ENDPOINTS.keys())INCREMENTAL_FIELDS: dict[str, list[IncrementalField]] = {diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/datadog/source.py b/products/warehouse_sources/backend/temporal/data_imports/sources/datadog/source.pyindex 58a2373e9662..427a6ced14e0 100644--- a/products/warehouse_sources/backend/temporal/data_imports/sources/datadog/source.py+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/datadog/source.py@@ -15,7 +15,11 @@ from products.warehouse_sources.backend.temporal.data_imports.pipelines.pipelineSourceInputs,SourceResponse,)-from products.warehouse_sources.backend.temporal.data_imports.sources.common.base import FieldType, ResumableSource+from products.warehouse_sources.backend.temporal.data_imports.sources.common.base import (+ FieldType,+ ResumableSource,+ VersionDeprecation,+)from products.warehouse_sources.backend.temporal.data_imports.sources.common.canonical_descriptions import (CanonicalDescriptions,)@@ -28,7 +32,10 @@ from products.warehouse_sources.backend.temporal.data_imports.sources.datadog.davalidate_credentials as validate_datadog_credentials,)from products.warehouse_sources.backend.temporal.data_imports.sources.datadog.settings import (+ DATADOG_API_VERSION_V1,+ DATADOG_DEFAULT_VERSION,DATADOG_ENDPOINTS,+ DATADOG_SUPPORTED_VERSIONS,ENDPOINTS,INCREMENTAL_FIELDS,LIMITED_RETENTION_ENDPOINTS,@@ -43,6 +50,11 @@ from products.warehouse_sources.backend.types import ExternalDataSourceTypeclass DatadogSource(ResumableSource[DatadogSourceConfig, DatadogResumeConfig]):api_docs_url = "https://docs.datadoghq.com/api/latest/"+ supported_versions = DATADOG_SUPPORTED_VERSIONS+ default_version = DATADOG_DEFAULT_VERSION+ # Datadog deprecates its v1 API per-endpoint with no wholesale sunset date, so no date is set.+ deprecated_versions = (VersionDeprecation(version=DATADOG_API_VERSION_V1),)+lists_tables_without_credentials = True # static endpoint catalog — safe for public docs@propertydiff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/datadog/tests/test_datadog_source.py b/products/warehouse_sources/backend/temporal/data_imports/sources/datadog/tests/test_datadog_source.pyindex ae553a8c2b67..c67ead33c578 100644--- a/products/warehouse_sources/backend/temporal/data_imports/sources/datadog/tests/test_datadog_source.py+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/datadog/tests/test_datadog_source.py@@ -162,6 +162,16 @@ class TestDatadogSource:assert isinstance(manager, ResumableSourceManager)assert manager._data_class is DatadogResumeConfig+ def test_version_metadata_declares_v2_default_and_deprecates_v1(self) -> None:+ # The repin migration and the in-product deprecation banner both key off this metadata;+ # the registry invariant test only checks generic invariants, not v1-deprecated / v2-default.+ assert self.source.supported_versions == ("v1", "v2")+ assert self.source.default_version == "v2"++ deprecated = {d.version: d for d in self.source.deprecated_versions}+ assert set(deprecated) == {"v1"}+ assert deprecated["v1"].sunset_at is None+@mock.patch("products.warehouse_sources.backend.temporal.data_imports.sources.datadog.source.datadog_source")def test_source_for_pipeline_plumbs_arguments(self, mock_source: mock.MagicMock) -> None:inputs = _make_inputs(schema_name="monitors", team_id=99, job_id="job-xyz")