: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
refactor(failure-window): Adjust based on interval (#77179)
Tomás Farías Santana5b73eee474a7
diff --git a/products/batch_exports/backend/temporal/pipeline/entrypoint.py b/products/batch_exports/backend/temporal/pipeline/entrypoint.pyindex acac6bc6971d..fee900a3ed03 100644--- a/products/batch_exports/backend/temporal/pipeline/entrypoint.py+++ b/products/batch_exports/backend/temporal/pipeline/entrypoint.py@@ -127,14 +127,6 @@ async def execute_batch_export_using_internal_stage(assert batch_export_inputs.batch_export_id is not Noneassert batch_export_inputs.run_id is not None- finish_inputs = FinishBatchExportRunInputs(- id=batch_export_inputs.run_id,- batch_export_id=batch_export_inputs.batch_export_id,- status=BatchExportRun.Status.COMPLETED,- team_id=batch_export_inputs.team_id,- on_demand=batch_export_inputs.on_demand,- )-if TEST:maximum_attempts = 1@@ -142,18 +134,26 @@ async def execute_batch_export_using_internal_stage(heartbeat_timeout_seconds = settings.BATCH_EXPORT_HEARTBEAT_TIMEOUT_SECONDSoverride_start_to_close_timeout_timedelta = dt.timedelta(seconds=override_start_to_close_timeout_seconds or 0)+ failure_check_window = 50 # Default, overriden based on interval+if interval == "hour":# TODO - we should reduce this to 1 hour once we are more confident about hitting 1 hour SLAs.# TODO: Review timeouts for internal stage activity.main_activity_start_to_close_timeout = max(dt.timedelta(hours=6), override_start_to_close_timeout_timedelta)stage_activity_start_to_close_timeout = dt.timedelta(hours=1)+ failure_check_window = 24 # A day's worth of runs+elif interval == "day":main_activity_start_to_close_timeout = max(dt.timedelta(days=1), override_start_to_close_timeout_timedelta)stage_activity_start_to_close_timeout = dt.timedelta(hours=6)+ failure_check_window = 7 # A week's worth of runs+elif interval == "week":# TODO - review these once we have more users using weekly batch exportsmain_activity_start_to_close_timeout = max(dt.timedelta(days=3), override_start_to_close_timeout_timedelta)stage_activity_start_to_close_timeout = dt.timedelta(days=1)+ failure_check_window = 4 # A (roughly) months' worth of runs+elif interval.startswith("every"):_, value, unit = interval.split(" ")kwargs = {unit: int(value)}@@ -162,9 +162,26 @@ async def execute_batch_export_using_internal_stage(dt.timedelta(minutes=20), dt.timedelta(**kwargs), override_start_to_close_timeout_timedelta)stage_activity_start_to_close_timeout = main_activity_start_to_close_timeout++ if unit == "minutes":+ runs_in_an_hour = 60 // int(value)+ failure_check_window = runs_in_an_hour # Last hour worth of runs+ else:+ # Anything other than minutes is not currently supported, but just+ # setting a default in case we ever add support for, e.g., seconds.+ failure_check_window = 50else:raise ValueError(f"Unsupported interval: '{interval}'")+ finish_inputs = FinishBatchExportRunInputs(+ id=batch_export_inputs.run_id,+ batch_export_id=batch_export_inputs.batch_export_id,+ status=BatchExportRun.Status.COMPLETED,+ team_id=batch_export_inputs.team_id,+ on_demand=batch_export_inputs.on_demand,+ failure_check_window=failure_check_window,+ )+try:stage_inputs = BatchExportInsertIntoInternalStageInputs(team_id=batch_export_inputs.team_id,