: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 dynatrace entity type, tag and release tables (#107281)
Tom Owers31d3e7458048
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 a31a07908749..9201c9a8907c 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@@ -2699,24 +2699,26 @@ Note on the aggregation endpoints, added 2026-09-25: `/analytics` is imported as## Dynatrace — gaps-Today (20): `applications`, `audit_logs`, `cloud_applications`, `custom_devices`, `databases`, `disks`, `events`, `hosts`, `kubernetes_clusters`, `kubernetes_nodes`, `metric_data_points`, `metrics`, `problems`, `process_groups`, `queues`, `security_problems`, `services`, `slos`, `synthetic_executions`, `synthetic_monitors`+Today (23): `applications`, `audit_logs`, `cloud_applications`, `custom_devices`, `databases`, `disks`, `entity_tags`, `entity_types`, `events`, `hosts`, `kubernetes_clusters`, `kubernetes_nodes`, `metric_data_points`, `metrics`, `problems`, `process_groups`, `queues`, `releases`, `security_problems`, `services`, `slos`, `synthetic_executions`, `synthetic_monitors`Diffed against: <https://docs.dynatrace.com/docs/dynatrace-api/environment-api/metric-v2/get-data-points>- [x] `GET /api/v2/metrics/query` — actual metric data points; the existing `metrics` table is descriptor metadata only (settings.py hits GET /api/v2/metrics), so no timeseries values are syncable today (high)-- [ ] `GET /api/v2/entityTypes` — lookup of every monitored entity type and its properties/relationships - needed to interpret entity IDs and to know what else is syncable (high)+- [x] `GET /api/v2/entityTypes` — lookup of every monitored entity type and its properties/relationships - needed to interpret entity IDs and to know what else is syncable (high)- [x] `GET /api/v2/entities with entitySelector for types beyond HOST/SERVICE/APPLICATION/PROCESS_GROUP` — DATABASE, KUBERNETES_CLUSTER/NODE, CLOUD_APPLICATION, DISK, QUEUE and custom devices are all served by the same endpoint the source already calls, just with a different type selector (high)- [x] `GET /api/v1/synthetic/monitors` — synthetic monitor definitions - the availability side of the product is entirely absent (high)- [x] `GET /api/v2/synthetic/executions` — synthetic monitor execution results, the per-run success/duration facts you would actually chart (high)- [ ] `GET /api/v1/userSessionQueryLanguage/table` — RUM user sessions - session-level real-user data, currently only aggregate application entities are synced (medium)-- [ ] `GET /api/v2/tags` — entity tag lookup; management-zone and tag dimensions are how Dynatrace users slice everything (medium)-- [ ] `GET /api/v2/releases` — release inventory joining deployed versions to entities, for change-vs-problem correlation (medium)+- [x] `GET /api/v2/tags` — entity tag lookup; management-zone and tag dimensions are how Dynatrace users slice everything (medium)+- [x] `GET /api/v2/releases` — release inventory joining deployed versions to entities, for change-vs-problem correlation (medium)- [ ] `GET /api/v2/attacks` — application-security attack events, the transactional counterpart to the security_problems already synced (medium)- [ ] `GET /api/v2/securityProblems/{id}/remediationItems` — per-vulnerability remediation items and their tracking state (medium)- [ ] `GET /api/v2/logs/search` — log records; high volume but the standard analytical join partner for problems and events (medium)- [ ] `GET /api/v2/synthetic/locations` — synthetic location lookup resolving the location IDs on executions (low)-Note: Diffed against the Environment API section of docs.dynatrace.com/docs/sitemap.xml (770 URLs under /dynatrace-api/environment-api/), then confirmed individual paths on their doc pages (/api/v2/entityTypes, /api/v1/synthetic/monitors, /api/v2/synthetic/executions, /api/v2/releases, /api/v2/tags, /api/v2/attacks, /api/v2/logs/search, /api/v1/userSessionQueryLanguage/table). Important: the source's `metrics` table is descriptors, not values - verified in products/warehouse_sources/backend/temporal/data_imports/sources/dynatrace/settings.py. Entity tables are hardcoded per type via \_entity_endpoint(); no dynamic type discovery. Config-only areas (settings objects, extensions, credential vault, tokens, network zones, ActiveGate deployment) deliberately excluded. `DATABASE` is not a Dynatrace entity type, so the `databases` table selects `RELATIONAL_DATABASE_SERVICE`. `/api/v2/synthetic/executions` returns on-demand executions only, and Dynatrace serves at most the last six hours of them, so the watermark is clamped to that window. Synthetic monitors are read from the v1 listing: the v2 equivalent needs the broad `settings.read` scope and currently covers only browser and multi-protocol monitors.+`/api/v1/userSessionQueryLanguage/table` stays unticked: it runs a USQL query supplied by the caller and answers with `columnNames` plus positional `values` rows, so the table's schema is whatever the query asked for rather than anything the source can declare. Dynatrace also computes the result from a sample of the data when it needs to (`extrapolationLevel`), and paginates it by `pageOffset` over a live result set, so the rows are neither complete nor stable between pages. It needs a different token scope (`DTAQLAccess`) from every other endpoint here. A user who wants this should point the custom REST source at it with their own query.++Note: Diffed against the Environment API section of docs.dynatrace.com/docs/sitemap.xml (770 URLs under /dynatrace-api/environment-api/), then confirmed individual paths on their doc pages (/api/v2/entityTypes, /api/v1/synthetic/monitors, /api/v2/synthetic/executions, /api/v2/releases, /api/v2/tags, /api/v2/attacks, /api/v2/logs/search, /api/v1/userSessionQueryLanguage/table). Important: the source's `metrics` table is descriptors, not values - verified in products/warehouse_sources/backend/temporal/data_imports/sources/dynatrace/settings.py. Entity tables are hardcoded per type via \_entity_endpoint(); no dynamic type discovery. Config-only areas (settings objects, extensions, credential vault, tokens, network zones, ActiveGate deployment) deliberately excluded. `DATABASE` is not a Dynatrace entity type, so the `databases` table selects `RELATIONAL_DATABASE_SERVICE`. `/api/v2/synthetic/executions` returns on-demand executions only, and Dynatrace serves at most the last six hours of them, so the watermark is clamped to that window. Synthetic monitors are read from the v1 listing: the v2 equivalent needs the broad `settings.read` scope and currently covers only browser and multi-protocol monitors. `/api/v2/tags` requires an `entitySelector` naming a single entity type and returns no entity reference, so the `entity_tags` table reads it once per type the entity tables cover and keys each row on that type. `/api/v2/releases` needs its own `releases.read` scope, and a release row carries no timestamp, so the table is full refresh over a 30-day window rather than incremental.## E2B — gapsdiff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/dynatrace/canonical_descriptions.py b/products/warehouse_sources/backend/temporal/data_imports/sources/dynatrace/canonical_descriptions.pyindex 504b228b684c..459bb8b31a74 100644--- a/products/warehouse_sources/backend/temporal/data_imports/sources/dynatrace/canonical_descriptions.py+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/dynatrace/canonical_descriptions.py@@ -192,6 +192,52 @@ CANONICAL_DESCRIPTIONS: CanonicalDescriptions = {"relatedOpenProblems": "Number of open problems related to the SLO.",},},+ "releases": {+ "description": "Releases observed in the environment. A release is a component and version pair, reported by the process group instances running it.",+ "docs_url": "https://docs.dynatrace.com/docs/dynatrace-api/environment-api/releaseapi/get-releaseall",+ "columns": {+ "name": "Name of the entity the release belongs to.",+ "product": "Product name of the release.",+ "stage": "Stage the release is deployed to (e.g. staging, production).",+ "version": "Identified version of the release.",+ "releaseEntityId": "Identifier of the entity the release correlates to.",+ "instances": "Process group instances included in the release, with their build version, open problems and vulnerabilities.",+ "softwareTechs": "Software technologies used by the release, with their edition and version.",+ "running": "Whether the related process group instance is still running and monitored.",+ "affectedByProblems": "Whether the entity has one or more open problems.",+ "problemCount": "Number of problems of the entity.",+ "affectedBySecurityVulnerabilities": "Whether the entity has one or more security vulnerabilities.",+ "securityVulnerabilitiesCount": "Number of security vulnerabilities of the entity.",+ "securityVulnerabilitiesEnabled": "Whether the security vulnerabilities feature is enabled.",+ "throughput": "Bytes per second handled by the entity.",+ },+ },+ "entity_types": {+ "description": "Every type of monitored entity observed in the environment, with the properties and relationships an entity of that type can have. The properties are placeholders showing what is possible, not values of an actual entity.",+ "docs_url": "https://docs.dynatrace.com/docs/dynatrace-api/environment-api/entity-v2/get-all-entity-types",+ "columns": {+ "type": "Type of the monitored entity (e.g. HOST, SERVICE, APPLICATION).",+ "displayName": "Display name of the entity type.",+ "dimensionKey": "Dimension key used for this entity type within metrics.",+ "properties": "Additional properties an entity of this type can have, each with an id and a type.",+ "fromRelationships": "Relationships where this entity type occupies the FROM position.",+ "toRelationships": "Relationships where this entity type occupies the TO position.",+ "tags": "Placeholder for the tags of an actual entity.",+ "managementZones": "Placeholder for the management zones of an actual entity.",+ "entityLimitExceeded": "Whether the entity creation limit for this type has been exceeded.",+ },+ },+ "entity_tags": {+ "description": "Custom tags assigned to monitored entities, one row per tag and entity type. Tags Dynatrace applies automatically, and imported tags, are not included.",+ "docs_url": "https://docs.dynatrace.com/docs/dynatrace-api/environment-api/custom-tags/get-tags",+ "columns": {+ "entityType": "Entity type the tag was read for (e.g. HOST, SERVICE). Added by PostHog, because Dynatrace reads tags one entity type at a time.",+ "context": "Origin of the tag, such as AWS or Cloud Foundry. Custom tags use CONTEXTLESS.",+ "key": "Key of the tag.",+ "value": "Value of the tag. Empty for a tag that is just a key.",+ "stringRepresentation": "Canonical string form of the tag, combining the context, key and value.",+ },+ },"synthetic_monitors": {"description": "Synthetic monitors configured in the environment.","docs_url": "https://docs.dynatrace.com/docs/dynatrace-api/environment-api/synthetic/synthetic-monitors/get-all-monitors",diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/dynatrace/dynatrace.py b/products/warehouse_sources/backend/temporal/data_imports/sources/dynatrace/dynatrace.pyindex 6892bb5eb042..594e37d13572 100644--- a/products/warehouse_sources/backend/temporal/data_imports/sources/dynatrace/dynatrace.py+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/dynatrace/dynatrace.py@@ -23,6 +23,7 @@ from products.warehouse_sources.backend.temporal.data_imports.sources.common.typfrom products.warehouse_sources.backend.temporal.data_imports.sources.dynatrace.settings import (DYNATRACE_ENDPOINTS,ENDPOINT_SCOPES,+ TAGGED_ENTITY_TYPES,DynatraceEndpointConfig,)@@ -401,6 +402,66 @@ def check_endpoint_permissions(return results+def _endpoint_pages(+ base_url: str,+ api_token: str,+ endpoint: str,+ config: DynatraceEndpointConfig,+ params: dict[str, Any],+ team_id: int,+ job_id: str,+ db_incremental_field_last_value: Optional[Any],+ resume_hook: Optional[Callable[[Optional[dict[str, Any]]], None]] = None,+ initial_paginator_state: Optional[dict[str, Any]] = None,+) -> Iterator[list[dict[str, Any]]]:+ """Pages of one Dynatrace list endpoint, built on the shared REST framework.++ A fresh config (and so a fresh paginator) per call, which is what lets the tag fan-out walk+ each entity type without carrying the previous type's cursor into the next request.+ """+ rest_config: RESTAPIConfig = {+ "client": {+ "base_url": base_url,+ # Non-secret headers only; the token rides the framework api_key auth so it's redacted+ # from logs and raised error messages.+ "headers": {"Accept": "application/json"},+ "auth": {+ "type": "api_key",+ "api_key": f"Api-Token {api_token}",+ "name": "Authorization",+ "location": "header",+ },+ "paginator": DynatraceNextPageKeyPaginator(),+ # The environment URL is user-supplied: pin every request to its host and refuse any+ # redirect so the Authorization header can't be bounced off the validated target.+ "allowed_hosts": [],+ "allow_redirects": False,+ },+ "resource_defaults": {},+ "resources": [+ {+ "name": endpoint,+ "endpoint": {+ "path": config.path,+ "params": params,+ # Missing key / non-list body yields 0 rows (matches the previous behavior),+ # so no data_selector_required here.+ "data_selector": config.data_key,+ },+ }+ ],+ }++ yield from rest_api_resource(+ rest_config,+ team_id,+ job_id,+ db_incremental_field_last_value,+ resume_hook=resume_hook,+ initial_paginator_state=initial_paginator_state,+ )++def dynatrace_source(environment_url: str,api_token: str,@@ -424,6 +485,27 @@ def dynatrace_source(_check_host(environment_url, team_id)base_url = normalize_environment_url(environment_url)+ params = _build_request_params(config, metric_selector)++ if config.fans_out_over_entity_types:+ # /api/v2/tags needs an entitySelector naming a single type and reports no entity back,+ # so each type is read on its own and stamped onto its rows. The sweep is one+ # unpaginated request per type, so there is nothing worth checkpointing for resume.+ for entity_type in TAGGED_ENTITY_TYPES:+ pages = _endpoint_pages(+ base_url,+ api_token,+ endpoint,+ config,+ {**params, "entitySelector": f'type("{entity_type}")'},+ team_id,+ job_id,+ db_incremental_field_last_value,+ )+ for page in pages:+ yield [{**row, "entityType": entity_type} for row in page]+ return+initial_paginator_state: Optional[dict[str, Any]] = Noneif resumable_source_manager.can_resume():resume = resumable_source_manager.load_state()@@ -436,41 +518,12 @@ def dynatrace_source(if state and state.get("next_page_key"):resumable_source_manager.save_state(DynatraceResumeConfig(next_page_key=state["next_page_key"]))- rest_config: RESTAPIConfig = {- "client": {- "base_url": base_url,- # Non-secret headers only; the token rides the framework api_key auth so it's redacted- # from logs and raised error messages.- "headers": {"Accept": "application/json"},- "auth": {- "type": "api_key",- "api_key": f"Api-Token {api_token}",- "name": "Authorization",- "location": "header",- },- "paginator": DynatraceNextPageKeyPaginator(),- # The environment URL is user-supplied: pin every request to its host and refuse any- # redirect so the Authorization header can't be bounced off the validated target.- "allowed_hosts": [],- "allow_redirects": False,- },- "resource_defaults": {},- "resources": [- {- "name": endpoint,- "endpoint": {- "path": config.path,- "params": _build_request_params(config, metric_selector),- # Missing key / non-list body yields 0 rows (matches the previous behavior),- # so no data_selector_required here.- "data_selector": config.data_key,- },- }- ],- }-- resource = rest_api_resource(- rest_config,+ resource = _endpoint_pages(+ base_url,+ api_token,+ endpoint,+ config,+ params,team_id,job_id,db_incremental_field_last_value,diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/dynatrace/settings.py b/products/warehouse_sources/backend/temporal/data_imports/sources/dynatrace/settings.pyindex fd2a550eea6e..6bda20db7c45 100644--- a/products/warehouse_sources/backend/temporal/data_imports/sources/dynatrace/settings.py+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/dynatrace/settings.py@@ -40,6 +40,11 @@ class DynatraceEndpointConfig:max_lookback: Optional[timedelta] = None# Required `entitySelector` for the entities endpoint (must specify a type on the first page).entity_selector: Optional[str] = None+ # Entity type the selector pins. Also the set the tags endpoint is fanned out over.+ entity_type: Optional[str] = None+ # Endpoint has no listing of its own: Dynatrace requires an `entitySelector` naming a single+ # entity type, so it is read once per type the entity tables cover.+ fans_out_over_entity_types: bool = False# Endpoint whose path stands in for this one when probing token scope. The metrics query needs# a metric selector a probe has no way to guess, so it borrows the descriptor endpoint's probe# — both sit behind `metrics.read`.@@ -78,6 +83,7 @@ def _entity_endpoint(name: str, entity_type: str) -> DynatraceEndpointConfig:primary_keys=["entityId"],page_size=100,entity_selector=f'type("{entity_type}")',+ entity_type=entity_type,default_from="now-30d",extra_params={"fields": _ENTITY_FIELDS},)@@ -130,6 +136,25 @@ DYNATRACE_ENDPOINTS: dict[str, DynatraceEndpointConfig] = {primary_keys=["securityProblemId"],page_size=100,),+ "releases": DynatraceEndpointConfig(+ name="releases",+ path="/api/v2/releases",+ data_key="releases",+ # A release carries no id of its own. Dynatrace documents <name, product, stage, version>+ # as the unique tuple.+ primary_keys=["name", "product", "stage", "version"],+ page_size=1000,+ # Dynatrace falls back to the last two weeks when `from` is omitted. A release row carries+ # no timestamp to track a watermark on, so the table is full refresh over a wider window.+ default_from="now-30d",+ ),+ "entity_types": DynatraceEndpointConfig(+ name="entity_types",+ path="/api/v2/entityTypes",+ data_key="types",+ primary_keys=["type"],+ page_size=500,+ ),"hosts": _entity_endpoint("hosts", "HOST"),"services": _entity_endpoint("services", "SERVICE"),"applications": _entity_endpoint("applications", "APPLICATION"),@@ -141,6 +166,22 @@ DYNATRACE_ENDPOINTS: dict[str, DynatraceEndpointConfig] = {"kubernetes_nodes": _entity_endpoint("kubernetes_nodes", "KUBERNETES_NODE"),"cloud_applications": _entity_endpoint("cloud_applications", "CLOUD_APPLICATION"),"custom_devices": _entity_endpoint("custom_devices", "CUSTOM_DEVICE"),+ "entity_tags": DynatraceEndpointConfig(+ name="entity_tags",+ path="/api/v2/tags",+ data_key="tags",+ # Dynatrace returns no identifier for a tag, and the same tag sits on entities of several+ # types, so a row is keyed on the type it was read for plus the tag's canonical string+ # form, which already carries the context, key and value.+ primary_keys=["entityType", "stringRepresentation"],+ # The endpoint takes no pageSize and returns every matching tag in one response.+ page_size=None,+ # Without `from` the endpoint only looks back 24 hours, so tags on entities idle over a+ # weekend would disappear from the table.+ default_from="now-30d",+ fans_out_over_entity_types=True,+ scope_probe_endpoint="hosts",+ ),"metrics": DynatraceEndpointConfig(name="metrics",path="/api/v2/metrics",@@ -200,6 +241,11 @@ DYNATRACE_ENDPOINTS: dict[str, DynatraceEndpointConfig] = {ENDPOINTS = tuple(DYNATRACE_ENDPOINTS.keys())+# Types the tags endpoint is read for, derived from the entity tables so the two can't drift.+TAGGED_ENTITY_TYPES: tuple[str, ...] = tuple(+ config.entity_type for config in DYNATRACE_ENDPOINTS.values() if config.entity_type+)+INCREMENTAL_FIELDS: dict[str, list[IncrementalField]] = {name: config.incremental_fields for name, config in DYNATRACE_ENDPOINTS.items()}@@ -211,6 +257,8 @@ ENDPOINT_SCOPES: dict[str, str] = {"events": "events.read","audit_logs": "auditLogs.read","security_problems": "securityProblems.read",+ "releases": "releases.read",+ "entity_types": "entities.read","hosts": "entities.read","services": "entities.read","applications": "entities.read",@@ -222,6 +270,7 @@ ENDPOINT_SCOPES: dict[str, str] = {"kubernetes_nodes": "entities.read","cloud_applications": "entities.read","custom_devices": "entities.read",+ "entity_tags": "entities.read","metrics": "metrics.read","metric_data_points": "metrics.read","slos": "slo.read",diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/dynatrace/source.py b/products/warehouse_sources/backend/temporal/data_imports/sources/dynatrace/source.pyindex 585086737159..d057f04660ef 100644--- a/products/warehouse_sources/backend/temporal/data_imports/sources/dynatrace/source.py+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/dynatrace/source.py@@ -35,6 +35,8 @@ _SCHEMA_DESCRIPTIONS: dict[str, str] = {"problems": "Only syncs the last 365 days on initial sync","events": "Only syncs the last 30 days on initial sync; limited by your Dynatrace event retention","audit_logs": "Only syncs the last 30 days on initial sync; requires audit logging to be enabled in the environment",+ "releases": "Releases seen in the last 30 days, with the process group instances running them",+ "entity_types": "Every monitored entity type, with the properties and relationships an entity of that type can have","hosts": "Hosts active in the last 30 days","services": "Services active in the last 30 days","applications": "Applications active in the last 30 days",@@ -46,6 +48,7 @@ _SCHEMA_DESCRIPTIONS: dict[str, str] = {"kubernetes_nodes": "Kubernetes nodes active in the last 30 days","cloud_applications": "Kubernetes workloads active in the last 30 days","custom_devices": "Custom devices active in the last 30 days",+ "entity_tags": "Custom tags in use, one row per tag and entity type. Tags Dynatrace applies automatically, and imported tags, are not included","metric_data_points": "One row per metric, dimension and hour, for the metric keys you entered. Only syncs the last 30 days on initial sync","slos": "Includes the current evaluation (status, error budget) of each SLO","synthetic_monitors": "Name, type and enabled state of each synthetic monitor",@@ -75,7 +78,7 @@ class DynatraceSource(ResumableSource[DynatraceSourceConfig, DynatraceResumeConflabel="Dynatrace",releaseStatus=ReleaseStatus.ALPHA,keywords=["apm", "observability", "monitoring"],- caption="""Enter your Dynatrace environment URL and an API access token to sync problems, events, entity inventory, audit logs, vulnerabilities, metrics, SLOs, and synthetic monitoring into the PostHog Data warehouse.+ caption="""Enter your Dynatrace environment URL and an API access token to sync problems, events, entity inventory, tags, releases, audit logs, vulnerabilities, metrics, SLOs, and synthetic monitoring into the PostHog Data warehouse.The environment URL is where you open Dynatrace — for SaaS it looks like `https://abc12345.live.dynatrace.com`; for Managed it's `https://your-domain/e/your-environment-id`.@@ -85,6 +88,7 @@ Create an [access token](https://docs.dynatrace.com/docs/manage/identity-access-- `entities.read`- `auditLogs.read`- `securityProblems.read`+- `releases.read`- `metrics.read`- `slo.read`- `ReadSyntheticData`diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/dynatrace/tests/test_dynatrace.py b/products/warehouse_sources/backend/temporal/data_imports/sources/dynatrace/tests/test_dynatrace.pyindex 63d9c547d7dd..e4617150978f 100644--- a/products/warehouse_sources/backend/temporal/data_imports/sources/dynatrace/tests/test_dynatrace.py+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/dynatrace/tests/test_dynatrace.py@@ -24,6 +24,7 @@ from products.warehouse_sources.backend.temporal.data_imports.sources.dynatrace.normalize_environment_url,validate_credentials,)+from products.warehouse_sources.backend.temporal.data_imports.sources.dynatrace.settings import TAGGED_ENTITY_TYPESBASE_URL = "https://abc12345.live.dynatrace.com"@@ -259,6 +260,17 @@ class TestFirstPageParams:with pytest.raises(ValueError, match="Metric keys"):_source("metric_data_points", mock.MagicMock(), metric_selector=" ")+ @mock.patch(CLIENT_SESSION_PATCH)+ def test_releases_widen_the_default_window(self, MockSession: mock.MagicMock) -> None:+ # Dynatrace only looks back two weeks when `from` is omitted, and a release row carries no+ # timestamp the pipeline could use to catch up on what that window missed.+ session = MockSession.return_value+ params = _wire(session, [_response({"releases": [], "nextPageKey": None})])+ manager, _ = _make_manager()+ _rows(_source("releases", manager))+ assert params[0]["from"] == "now-30d"+ assert params[0]["pageSize"] == "1000"+@mock.patch(CLIENT_SESSION_PATCH)def test_slos_request_evaluation(self, MockSession: mock.MagicMock) -> None:session = MockSession.return_value@@ -345,6 +357,46 @@ class TestPagination:MockSession.assert_not_called()+class TestEntityTagFanOut:+ @mock.patch(CLIENT_SESSION_PATCH)+ def test_each_entity_type_is_read_and_stamped_onto_its_rows(self, MockSession: mock.MagicMock) -> None:+ session = MockSession.return_value+ params = _wire(+ session,+ [+ _response({"tags": [{"stringRepresentation": "owner:team-a"}], "totalCount": 1})+ for _ in TAGGED_ENTITY_TYPES+ ],+ )+ manager, _ = _make_manager()+ rows = _rows(_source("entity_tags", manager))++ # /api/v2/tags requires a selector naming one type, so each type is a request of its own.+ assert [p["entitySelector"] for p in params] == [f'type("{t}")' for t in TAGGED_ENTITY_TYPES]+ assert all(p["from"] == "now-30d" for p in params)+ assert all("pageSize" not in p for p in params)+ # A tag comes back with no entity reference, so the type it was read for is the only link+ # back to the entity tables — and the rest of its primary key.+ assert [row["entityType"] for row in rows] == list(TAGGED_ENTITY_TYPES)++ @mock.patch(CLIENT_SESSION_PATCH)+ def test_a_cursor_does_not_carry_into_the_next_entity_type(self, MockSession: mock.MagicMock) -> None:+ session = MockSession.return_value+ responses = [+ _response({"tags": [{"stringRepresentation": "a"}], "nextPageKey": "key-2"}),+ _response({"tags": [{"stringRepresentation": "b"}]}),+ ]+ responses += [_response({"tags": []}) for _ in TAGGED_ENTITY_TYPES[1:]]+ params = _wire(session, responses)+ manager, _ = _make_manager()+ _rows(_source("entity_tags", manager))++ assert params[1] == {"nextPageKey": "key-2"}+ # The next type starts its own walk; reusing the previous type's cursor would re-read it.+ assert params[2]["entitySelector"] == f'type("{TAGGED_ENTITY_TYPES[1]}")'+ assert "nextPageKey" not in params[2]++class TestDynatraceSourceResponse:@pytest.mark.parametrize(("endpoint", "expected_pks", "expected_sort_mode"),@@ -359,6 +411,10 @@ class TestDynatraceSourceResponse:# A data point is only unique on the metric, its dimension tuple and the timestamp.("metric_data_points", ["metricId", "dimensionKey", "timestamp"], "desc"),("slos", ["id"], "asc"),+ # Dynatrace documents this tuple as a release's unique identity; it has no id field.+ ("releases", ["name", "product", "stage", "version"], "asc"),+ # A tag row is only unique once the entity type it was read for is part of the key.+ ("entity_tags", ["entityType", "stringRepresentation"], "asc"),("synthetic_monitors", ["entityId"], "asc"),("synthetic_executions", ["executionId"], "desc"),],