: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
fix(signals): tag inbox ranking dag queries with team_id and query_type (#83835)
Andrew Maguire4abae9c322d6
diff --git a/products/signals/dags/inbox_ranking/dataset/dag.py b/products/signals/dags/inbox_ranking/dataset/dag.pyindex 34a78d0635aa..fbe606dd11ac 100644--- a/products/signals/dags/inbox_ranking/dataset/dag.py+++ b/products/signals/dags/inbox_ranking/dataset/dag.py@@ -80,6 +80,7 @@ from products.signals.dags.inbox_ranking.dataset.queries import (LABEL_DEFAULTS,LABEL_STREAMS,LABELED_REPORT_IDS_SQL,+ LABELS_TEAM_ID,REPORT_EMBEDDINGS_QUERY_SETTINGS,REPORT_EMBEDDINGS_SQL,SIGNAL_EMBEDDINGS_QUERY_SETTINGS,@@ -123,11 +124,14 @@ COMMON_ASSET_KWARGS: dict[str, Any] = {}-def _tag_dagster_queries(context: dagster.AssetExecutionContext) -> None:+def _tag_dagster_queries(context: dagster.AssetExecutionContext, query_type: str) -> None:"""Stamp product + feature + dagster run tags into the thread's query tags so every ClickHousequery this asset issues (sync_execute and HogQL alike) is attributable in system.query_log.- Both product and feature are required: sync_execute refuses an untagged query in local dev."""- tag_queries(product=Product.SIGNALS, feature=Feature.DATA_MODELING)+ Both product and feature are required: sync_execute refuses an untagged query in local dev.+ team_id and query_type are set because sync_execute warns on every call missing either; the+ fleet-wide embedding scans have no single tenant, so they carry the labels team as the owner of+ the dataset they feed (HogQL calls re-tag the team from their own context)."""+ tag_queries(product=Product.SIGNALS, feature=Feature.DATA_MODELING, team_id=LABELS_TEAM_ID, query_type=query_type)get_query_tags().with_dagster(dagster_tags(context))@@ -383,7 +387,7 @@ def spine_report_filter(snapshot_end: datetime.datetime) -> Q:def inbox_report_state(context: dagster.AssetExecutionContext) -> None:if skip_unconfigured(context):return- _tag_dagster_queries(context)+ _tag_dagster_queries(context, query_type="inbox_ranking_report_state")partition_key = context.partition_key_, snapshot_end = snapshot_bounds(partition_key)snapshot_date = datetime.date.fromisoformat(partition_key)@@ -483,7 +487,7 @@ def inbox_report_state(context: dagster.AssetExecutionContext) -> None:def inbox_report_embeddings(context: dagster.AssetExecutionContext) -> None:if skip_unconfigured(context):return- _tag_dagster_queries(context)+ _tag_dagster_queries(context, query_type="inbox_ranking_report_embeddings")partition_key = context.partition_key_, snapshot_end = snapshot_bounds(partition_key)snapshot_date = datetime.date.fromisoformat(partition_key)@@ -584,7 +588,7 @@ def inbox_signal_embeddings(context: dagster.AssetExecutionContext) -> None:"""if skip_unconfigured(context):return- _tag_dagster_queries(context)+ _tag_dagster_queries(context, query_type="inbox_ranking_signal_embeddings")partition_key = context.partition_keywindow_start, window_end = snapshot_bounds(partition_key)snapshot_date = datetime.date.fromisoformat(partition_key)@@ -689,7 +693,7 @@ def inbox_signal_embeddings(context: dagster.AssetExecutionContext) -> None:def inbox_report_labels(context: dagster.AssetExecutionContext) -> None:if skip_unconfigured(context):return- _tag_dagster_queries(context)+ _tag_dagster_queries(context, query_type="inbox_ranking_labels")partition_key = context.partition_key_, snapshot_end = snapshot_bounds(partition_key)team = labels_team()