From 372547fe66e278a437699f592ef86ecc6ed7f15e Mon Sep 17 00:00:00 2001 From: Jason Petersen Date: Mon, 24 Nov 2025 12:51:33 -0700 Subject: [PATCH] Send explicit plan type and source for EXPLAIN To match the `auto_explain` and `explain_analyze` sent by logs- processor. --- postgres/datadog_checks/postgres/statement_samples.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/postgres/datadog_checks/postgres/statement_samples.py b/postgres/datadog_checks/postgres/statement_samples.py index 6b24fc7adafd2..64f778cf7a383 100644 --- a/postgres/datadog_checks/postgres/statement_samples.py +++ b/postgres/datadog_checks/postgres/statement_samples.py @@ -875,6 +875,10 @@ def _collect_plan_for_statement(self, row): if explain_err_code: collection_errors = [{'code': explain_err_code.value, 'message': err_msg if err_msg else None}] + plan_type = "explain" + if explain_err_code == DBExplainError.explained_with_prepared_statement: + plan_type = "explain_generic" + raw_plan, normalized_plan, obfuscated_plan, plan_signature, raw_plan_signature = None, None, None, None, None if plan_dict: raw_plan = json.dumps(plan_dict) @@ -916,6 +920,8 @@ def _collect_plan_for_statement(self, row): "definition": obfuscated_plan, "signature": plan_signature, "collection_errors": collection_errors, + "source": "datadog_agent", + "type": plan_type }, "query_signature": row['query_signature'], "resource_hash": row['query_signature'],