: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(engineering-analytics): DORA scope, grouping, and report bands on the Health tab (#91274)
Paul D'Ambracfd434805e97
diff --git a/frontend/snapshots.yml b/frontend/snapshots.ymlindex f28e0eb4dfee..4ac293ff75ec 100644--- a/frontend/snapshots.yml+++ b/frontend/snapshots.yml@@ -6649,13 +6649,13 @@ snapshots:scenes-app-engineering-analytics-delivery-pipeline--without-deploys--light:hash: v1.k794b7964.5eaee687a224ef9cd7d3707391948732cacb11769bdd619f315a101abcb85de1.ymQC-4XF77SeJ0AN5SrtlyYKs8Ve29MBfz4J8FGLWtgscenes-app-engineering-analytics-health--health--dark:- hash: v1.k794b7964.0698630f83c06821e9d53560c494f1af19db540011811a1dcdc991ba671d17e1.wGW1HadqzVFD6pQY0t78xDUa_2cRYoVdw3TlTut2Msw+ hash: v1.k794b7964.beb194c79dcda2d45e0b6cd70af895f086f3a69a0a710aab0060d162ed3ef5ec._Vs4eQgavmmj4cIZC4j2KGrex5m6E1xY_h1QWB2m7o0scenes-app-engineering-analytics-health--health--light:- hash: v1.k794b7964.6cbd8e6f7aa43598813da531f94c49b5183eb94657fde7220b5b93827c2416a8.6RZB5K8kWBt7BSu7ISVkrceeM8SrqyjEnXzL0wMol8Y+ hash: v1.k794b7964.4c6326fdacae22c513cc4c22ba4dbeec18e64d7573befbd827a9a067b4032236.LjsN9asnLhIwhjL1nmRKaRPVMJz8p3XXMEniUPRCOJoscenes-app-engineering-analytics-health--health-without-deploy-data--dark:- hash: v1.k794b7964.e64ec2c7f4ed0762b6d3ce9d75ee14d005480b50c9717ff2186760ee44d1ed4e.TqU2tqFhhU9TAMa5r5bYL4sATkxF2gVcbY1KwoBgefE+ hash: v1.k794b7964.fcf17a2c752c6a453a760c7becc9ce9392456414f4a7e1e8a38b66660074c558.B4MjMp8wzV3OLnnbsaCK3yFK4eOuKiMT6fSGlvr8v68scenes-app-engineering-analytics-health--health-without-deploy-data--light:- hash: v1.k794b7964.ba70bf7cbfe68960e5f69d0113958817c0730924483b2d2754d6fb4f69d75521.G4uDkutjqMoenrNbQXODQ8R5Zh3E-CMqWOGIW02FCOo+ hash: v1.k794b7964.5fb1127eed77a6a9db9aceba7b679ddfa5b1e6c6cfcfd1eed7ba64de0bb08de7.G8glZpP9JYR21nolZhaVBuN5ySWpHQbAU1f-5TCUeJAscenes-app-engineering-analytics-lead-time-box-plot--default--dark:hash: v1.k794b7964.a88a986e975778b0ad232c7e8f75211b0d66acb126082b2f781fd9d5641ff28d.P4_7HWOcC-Z8pGr_2GTGkAc_fzupx_TRaZdlauEmVQEscenes-app-engineering-analytics-lead-time-box-plot--default--light:diff --git a/products/engineering_analytics/backend/facade/api.py b/products/engineering_analytics/backend/facade/api.pyindex 31ec904cadfa..ac801c8344b0 100644--- a/products/engineering_analytics/backend/facade/api.py+++ b/products/engineering_analytics/backend/facade/api.py@@ -502,8 +502,9 @@ def get_dora_overview(team: Team,date_from: str | None = None,date_to: str | None = None,- environment: str | None = None,+ environments: list[str] | None = None,github_team: str | None = None,+ granularity: str | None = None,source_id: str | None = None,repo: str | None = None,user_access_control: "UserAccessControl | None" = None,@@ -512,8 +513,9 @@ def get_dora_overview(curated=_authorized_source(team, source_id, user_access_control, repo=repo),date_from=date_from,date_to=date_to,- environment=environment,+ environments=environments,github_team=github_team,+ granularity=granularity,)diff --git a/products/engineering_analytics/backend/facade/contracts.py b/products/engineering_analytics/backend/facade/contracts.pyindex f2a6e525d8af..c90881a639f7 100644--- a/products/engineering_analytics/backend/facade/contracts.py+++ b/products/engineering_analytics/backend/facade/contracts.py@@ -1305,12 +1305,15 @@ class LeadTimeBucket:# PRs whose first post-merge successful deployment landed in this bucket.deployed_pr_count: int# Distribution of the stage's duration, in seconds, over those PRs — the six-number- # summary a box plot draws (box p25→p75, median line, mean marker, whiskers).+ # summary a box plot draws (box p25→p75, median line, mean marker, whiskers), plus+ # p5/p95, the whisker pair the outlier-excluding view draws instead of min/max.min_seconds: float | None+ p05_seconds: float | Nonep25_seconds: float | Nonep50_seconds: float | Nonemean_seconds: float | Nonep75_seconds: float | None+ p95_seconds: float | Nonemax_seconds: float | None@@ -1333,13 +1336,14 @@ class DoraOverview:# False when the deployments/deployment_statuses tables aren't synced for the selected repo.deploy_data_available: bool- # What the environment filter resolved to: 'production' (deployments GitHub marks- # production_environment), an exact environment name (the one the caller passed, or —- # when nothing is marked production — the busiest persistent environment, so a multi-region- # repo doesn't multiply every count), or 'persistent' (no persistent environment deployed in- # the window at all, so every non-transient one counts). Transient environments (ephemeral- # per-PR previews) never join a default scope. The scope resolves from deployments in the- # scan window, so two different windows can resolve different scopes and are not always comparable.+ # What the environment filter resolved to: the exact environment name(s) it matches —+ # the caller's picks (comma-joined when several), or by default the busiest environment+ # GitHub marks production, falling back to the busiest persistent environment, so a+ # multi-region repo doesn't multiply every count — or 'persistent' (no persistent+ # environment deployed in the window at all, so every non-transient one counts). Transient+ # environments (ephemeral per-PR previews) never join a default scope. The scope resolves+ # from deployments in the scan window, so two different windows can resolve different+ # scopes and are not always comparable.environment_scope: str# Distinct persistent environments deployed to in the scan window, most-deployed first — the# picker's options. Transient environments are omitted but stay reachable by exact name.@@ -1399,7 +1403,8 @@ class DoraOverview:# Open-to-deploy distribution over the same deployed PRs and buckets: the full open → first# successful deploy span the two stages above compose into.open_to_deploy_series: list[LeadTimeBucket]- # Bucket width of every series, chosen to fit the window: 'hour', 'day', or 'week'.+ # Bucket width of every series: the caller's granularity when given, else chosen to fit+ # the window: 'hour', 'day', or 'week'.series_granularity: strdiff --git a/products/engineering_analytics/backend/logic/dora.py b/products/engineering_analytics/backend/logic/dora.pyindex 6cf47e30edda..a0a7f36cc86c 100644--- a/products/engineering_analytics/backend/logic/dora.py+++ b/products/engineering_analytics/backend/logic/dora.py@@ -1,25 +1,38 @@"""Orchestration for the DORA deploy-metrics read."""+from typing import cast, get_args+from products.engineering_analytics.backend.facade.contracts import DoraOverviewfrom products.engineering_analytics.backend.logic._shared import _DEFAULT_WINDOW, _parse_window+from products.engineering_analytics.backend.logic.queries._buckets import Granularityfrom products.engineering_analytics.backend.logic.queries._curated import CuratedGitHubSourcefrom products.engineering_analytics.backend.logic.queries.dora import query_dora_overview+_GRANULARITIES: tuple[Granularity, ...] = get_args(Granularity)+def build_dora_overview(*,curated: CuratedGitHubSource,date_from: str | None = None,date_to: str | None = None,- environment: str | None = None,+ environments: list[str] | None = None,github_team: str | None = None,+ granularity: str | None = None,) -> DoraOverview:parsed_from, parsed_to = _parse_window(curated.team, date_from, date_to, default=_DEFAULT_WINDOW)+ parsed_granularity: Granularity | None = None+ if granularity:+ if granularity not in _GRANULARITIES:+ raise ValueError(f"granularity must be one of {', '.join(_GRANULARITIES)}")+ parsed_granularity = cast(Granularity, granularity)+ # Blank means "no filter", matching the branch-filter convention.+ environments_filter = [name.strip() for name in (environments or []) if name.strip()]return query_dora_overview(curated=curated,date_from=parsed_from,date_to=parsed_to,- # Blank means "no filter", matching the branch-filter convention.- environment=(environment or "").strip() or None,+ environments_filter=environments_filter or None,github_team=(github_team or "").strip() or None,+ granularity=parsed_granularity,)diff --git a/products/engineering_analytics/backend/logic/queries/dora.py b/products/engineering_analytics/backend/logic/queries/dora.pyindex 78d22079d31b..b6657392eeb8 100644--- a/products/engineering_analytics/backend/logic/queries/dora.py+++ b/products/engineering_analytics/backend/logic/queries/dora.py@@ -251,11 +251,13 @@ _LEAD_TIME_HEADLINE_SELECT = f"""def _box_stat_columns(column: str, prefix: str) -> str:- """The six-number box-plot summary of ``column``, aliased under ``prefix``."""+ """The box-plot summary of ``column``, aliased under ``prefix``: the six-number summary+ plus p5/p95, the whisker pair the outlier-excluding view draws instead of min/max."""return (- f"min({column}) AS {prefix}_min, quantile(0.25)({column}) AS {prefix}_p25, "- f"quantile(0.5)({column}) AS {prefix}_p50, avg({column}) AS {prefix}_mean, "- f"quantile(0.75)({column}) AS {prefix}_p75, max({column}) AS {prefix}_max"+ f"min({column}) AS {prefix}_min, quantile(0.05)({column}) AS {prefix}_p05, "+ f"quantile(0.25)({column}) AS {prefix}_p25, quantile(0.5)({column}) AS {prefix}_p50, "+ f"avg({column}) AS {prefix}_mean, quantile(0.75)({column}) AS {prefix}_p75, "+ f"quantile(0.95)({column}) AS {prefix}_p95, max({column}) AS {prefix}_max")@@ -263,7 +265,7 @@ def _box_stat_columns(column: str, prefix: str) -> str:# _LEAD_TIME_SERIES_SELECT. _lead_time_bucket's ``stage`` index walks this same list, so the# SQL column order and the Python row-slice order can't drift independently._LEAD_TIME_STAGES = (("mtd", "lead_seconds"), ("otm", "open_to_merge_seconds"), ("otd", "open_to_deploy_seconds"))-_STAGE_STAT_WIDTH = 6 # min, p25, p50, mean, p75, max+_STAGE_STAT_WIDTH = 8 # min, p05, p25, p50, mean, p75, p95, max_STAGE_MERGE_TO_DEPLOY, _STAGE_OPEN_TO_MERGE, _STAGE_OPEN_TO_DEPLOY = range(len(_LEAD_TIME_STAGES))_LEAD_TIME_SERIES_SELECT = f"""@@ -309,10 +311,13 @@ def _date_to_clause(date_to: datetime | None, column: str) -> str:@frozenclass _EnvironmentScope:- # 'production', 'persistent', or the exact environment the caller passed (see DoraOverview).+ # 'persistent', or the exact environment name(s) the scope resolved to (see DoraOverview).scope: str# The trusted SQL predicate variant for the deploys CTE.predicate: str+ # The exact environment names the predicate matches, bound as the {environments} placeholder;+ # None for the predicate variants that match by flag rather than by name.+ values: list[str] | None@frozen@@ -338,30 +343,42 @@ class _DoraScan:return window_buckets(self.date_from, self.date_to, self.granularity)-def _resolve_environment_scope(environment: str | None, environments: list[tuple[str, bool]]) -> _EnvironmentScope:- """Pick the deploy population: the caller's exact environment when given; otherwise the- deployments GitHub marks production; otherwise the busiest environment whose NAME says- production; otherwise the single busiest persistent environment, so a repo that never sets- the production flag still gets numbers instead of a false zero.+def _resolve_environment_scope(+ environments_filter: list[str] | None, environments: list[tuple[str, bool]]+) -> _EnvironmentScope:+ """Pick the deploy population: the caller's exact environment(s) when given; otherwise the+ single busiest environment GitHub marks production; otherwise the busiest environment whose+ NAME says production; otherwise the single busiest persistent environment, so a repo that+ never sets the production flag still gets numbers instead of a false zero.The name tier exists because the ``production_environment`` flag is optional and widelyunset, and a dev or staging environment can deploy more often than production, which wouldput every default DORA figure on that environment.- Busiest-single, not every-name-matched: a multi-region repo deploys each merge to several- production environments, which would multiply every deploy count and hand lead time to- whichever region deploys first. 'persistent' survives only when the window has no persistent- environment at all. Transient environments never join a default scope: they are ephemeral- per-PR previews, and on this repo they outnumber real deploys by an order of magnitude."""- if environment:- return _EnvironmentScope(scope=environment, predicate="d.environment = {environment}")- if any(is_production for _, is_production in environments):- return _EnvironmentScope(scope="production", predicate="d.is_production_environment")- # ``environments`` arrives busiest-first, so the first name match is the busiest match.+ Busiest-single, not every-matching: a multi-region repo deploys each merge to several+ production and persistent environments (and to dev, package registries, ...), which would+ multiply every deploy count and hand lead time to whichever region deploys first.+ 'persistent' survives only when the window has no persistent environment at all. Transient+ environments never join a default scope: they are ephemeral per-PR previews, and on this+ repo they outnumber real deploys by an order of magnitude."""+ if environments_filter:+ return _EnvironmentScope(+ scope=", ".join(environments_filter),+ predicate="d.environment IN {environments}",+ values=environments_filter,+ )+ # ``environments`` arrives busiest-first, so the first match in each tier is the busiest match.+ production = next((name for name, is_production in environments if is_production), None)+ if production is not None:+ return _single_environment_scope(production)named = next((name for name, _ in environments if _PRODUCTION_NAME_PATTERN.match(name)), None)if named is not None:- return _EnvironmentScope(scope=named, predicate="d.environment = {environment}")+ return _single_environment_scope(named)if environments:- return _EnvironmentScope(scope=environments[0][0], predicate="d.environment = {environment}")- return _EnvironmentScope(scope="persistent", predicate="NOT d.is_transient_environment")+ return _single_environment_scope(environments[0][0])+ return _EnvironmentScope(scope="persistent", predicate="NOT d.is_transient_environment", values=None)+++def _single_environment_scope(name: str) -> _EnvironmentScope:+ return _EnvironmentScope(scope=name, predicate="d.environment IN {environments}", values=[name])def _empty_overview(@@ -586,10 +603,11 @@ def query_dora_overview(curated: CuratedGitHubSource,date_from: datetime,date_to: datetime | None,- environment: str | None = None,+ environments_filter: list[str] | None = None,github_team: str | None = None,+ granularity: Granularity | None = None,) -> DoraOverview:- granularity = pick_granularity(date_from, date_to)+ granularity = granularity or pick_granularity(date_from, date_to)deploy_sources = curated.deploy_sources()members_source = curated.members_source()has_membership_data = members_source is not None@@ -598,7 +616,7 @@ def query_dora_overview(if deploy_sources is None:return _empty_overview(deploy_data_available=False,- environment_scope=environment or "persistent",+ environment_scope=", ".join(environments_filter) if environments_filter else "persistent",environments=[],has_membership_data=has_membership_data,github_teams=github_teams,@@ -624,11 +642,11 @@ def query_dora_overview(placeholders=placeholders,date_to_filter=_date_to_clause(date_to, "d.created_at"),)- env_scope = _resolve_environment_scope(environment, environments)- # The busiest-environment fallback binds the same placeholder as an explicit filter: either- # way the scope string IS the environment the predicate matches.- if "{environment}" in env_scope.predicate:- placeholders["environment"] = ast.Constant(value=env_scope.scope)+ env_scope = _resolve_environment_scope(environments_filter, environments)+ # The busiest-environment fallbacks bind the same placeholder as an explicit filter: either+ # way ``values`` holds exactly the environment names the predicate matches.+ if env_scope.values is not None:+ placeholders["environments"] = ast.Tuple(exprs=[ast.Constant(value=name) for name in env_scope.values])scan = _DoraScan(curated=curated,@@ -687,23 +705,27 @@ def _lead_time_bucket(bucket: datetime, stats: tuple[Any, ...] | None, *, stage:bucket_start=bucket,deployed_pr_count=0,min_seconds=None,+ p05_seconds=None,p25_seconds=None,p50_seconds=None,mean_seconds=None,p75_seconds=None,+ p95_seconds=None,max_seconds=None,)n = stats[0]offset = 1 + stage * _STAGE_STAT_WIDTH- min_s, p25, p50, mean, p75, max_s = stats[offset : offset + _STAGE_STAT_WIDTH]+ min_s, p05, p25, p50, mean, p75, p95, max_s = stats[offset : offset + _STAGE_STAT_WIDTH]return LeadTimeBucket(bucket_start=bucket,deployed_pr_count=int(n or 0),min_seconds=opt_float(min_s),+ p05_seconds=opt_float(p05),p25_seconds=opt_float(p25),p50_seconds=opt_float(p50),mean_seconds=opt_float(mean),p75_seconds=opt_float(p75),+ p95_seconds=opt_float(p95),max_seconds=opt_float(max_s),)diff --git a/products/engineering_analytics/backend/presentation/serializers/dora.py b/products/engineering_analytics/backend/presentation/serializers/dora.pyindex c6859fcc8f19..476954cec7d2 100644--- a/products/engineering_analytics/backend/presentation/serializers/dora.py+++ b/products/engineering_analytics/backend/presentation/serializers/dora.py@@ -40,6 +40,11 @@ class LeadTimeBucketSerializer(DataclassSerializer):"help_text": "Fastest duration for this stage in this bucket, in seconds. Null when nothing deployed.","allow_null": True,},+ "p05_seconds": {+ "help_text": "5th percentile of the stage's duration, in seconds — the lower whisker when "+ "outliers are excluded. Null when nothing deployed.",+ "allow_null": True,+ },"p25_seconds": {"help_text": "25th percentile of the stage's duration, in seconds. Null when nothing deployed.","allow_null": True,@@ -56,6 +61,11 @@ class LeadTimeBucketSerializer(DataclassSerializer):"help_text": "75th percentile of the stage's duration, in seconds. Null when nothing deployed.","allow_null": True,},+ "p95_seconds": {+ "help_text": "95th percentile of the stage's duration, in seconds — the upper whisker when "+ "outliers are excluded. Null when nothing deployed.",+ "allow_null": True,+ },"max_seconds": {"help_text": "Slowest duration for this stage in this bucket, in seconds. Null when nothing deployed.","allow_null": True,@@ -72,8 +82,8 @@ class DoraOverviewSerializer(DataclassSerializer):merge_to_deploy_series = LeadTimeBucketSerializer(many=True,help_text="Merge-to-deploy distribution per bucket across the window, oldest first — the box-plot "- "series (min/p25/p50/mean/p75/max seconds per bucket). Empty when the deploy tables aren't synced, "- "or when github_team was passed without membership data synced.",+ "series (min/p5/p25/p50/mean/p75/p95/max seconds per bucket). Empty when the deploy tables aren't "+ "synced, or when github_team was passed without membership data synced.",)open_to_merge_series = LeadTimeBucketSerializer(many=True,@@ -96,12 +106,13 @@ class DoraOverviewSerializer(DataclassSerializer):"selected repo; every other field is then empty or null, never a fake zero."},"environment_scope": {- "help_text": "What the environment filter resolved to: 'production' (deployments GitHub marks "- "production_environment), an exact environment name (the one passed, or the busiest persistent "- "environment when nothing is marked production), or 'persistent' (no persistent environment "- "deployed in the window, so every non-transient one counts). Transient environments (ephemeral "- "per-PR previews) never join a default scope. The scope resolves from deployments in the scan "- "window, so two different windows can resolve different scopes and are not always comparable."+ "help_text": "What the environment filter resolved to: the exact environment name(s) it matches "+ "(the caller's picks, comma-joined when several; by default the busiest production-marked "+ "environment, falling back to the busiest persistent one), or 'persistent' (no persistent "+ "environment deployed in the window, so every non-transient one counts). Transient environments "+ "(ephemeral per-PR previews) never join a default scope. The scope resolves from deployments in "+ "the scan window, so two different windows can resolve different scopes and are not always "+ "comparable."},"environments": {"help_text": "Distinct persistent environments deployed to in the scan window, most-deployed "@@ -199,6 +210,7 @@ class DoraOverviewSerializer(DataclassSerializer):"allow_null": True,},"series_granularity": {- "help_text": "Bucket width of every series, chosen to fit the window: 'hour', 'day', or 'week'."+ "help_text": "Bucket width of every series: the granularity param when given, else chosen to "+ "fit the window: 'hour', 'day', or 'week'."},}diff --git a/products/engineering_analytics/backend/presentation/views/dora.py b/products/engineering_analytics/backend/presentation/views/dora.pyindex 135e02b8b145..cf40532dc6b3 100644--- a/products/engineering_analytics/backend/presentation/views/dora.py+++ b/products/engineering_analytics/backend/presentation/views/dora.py@@ -20,11 +20,26 @@ from products.engineering_analytics.backend.presentation.views._base import (_ENVIRONMENT = OpenApiParameter(name="environment",type=OpenApiTypes.STR,+ many=True,location=OpenApiParameter.QUERY,required=False,- description="Exact deploy environment to scope to (from the response's `environments` list). Omit to scope "- "to production-marked deployments, falling back to every persistent (non-transient) environment when none "- "are marked production.",+ # Explicit explode: the generated client only emits repeated `environment=` keys for params the+ # spec marks explode, and Django's getlist needs repeated keys — a comma-joined value matches no+ # environment.+ explode=True,+ description="Deploy environment(s) to scope to, repeatable (from the response's `environments` list). Omit "+ "to scope to the busiest environment GitHub marks production, falling back to the busiest persistent "+ "(non-transient) environment when none are marked production.",+)++_GRANULARITY = OpenApiParameter(+ name="granularity",+ type=OpenApiTypes.STR,+ location=OpenApiParameter.QUERY,+ required=False,+ enum=["hour", "day", "week"],+ description="Bucket width for every series. Omit to pick one that fits the window: hour up to 48h, day up "+ "to 90 days, week beyond.",)_GITHUB_TEAM = OpenApiParameter(@@ -43,10 +58,10 @@ class DoraActionsMixin(EngineeringAnalyticsViewSetBase):@extend_schema(operation_id="engineering_analytics_dora",- parameters=[_DATE_FROM, _DATE_TO, _ENVIRONMENT, _GITHUB_TEAM, _SOURCE_ID, _REPO],+ parameters=[_DATE_FROM, _DATE_TO, _ENVIRONMENT, _GITHUB_TEAM, _GRANULARITY, _SOURCE_ID, _REPO],responses={200: DoraOverviewSerializer,- 400: OpenApiResponse(description="Invalid date_from, date_to, or source_id."),+ 400: OpenApiResponse(description="Invalid date_from, date_to, granularity, or source_id."),},description=("DORA-style deploy metrics over the GitHub deployments + deployment_statuses warehouse pair, each "@@ -63,12 +78,13 @@ class DoraActionsMixin(EngineeringAnalyticsViewSetBase):team=self.team,date_from=request.query_params.get("date_from") or None,date_to=request.query_params.get("date_to") or None,- environment=request.query_params.get("environment") or None,+ environments=request.query_params.getlist("environment") or None,github_team=request.query_params.get("github_team") or None,+ granularity=request.query_params.get("granularity") or None,source_id=request.query_params.get("source_id") or None,repo=request.query_params.get("repo") or None,user_access_control=self.user_access_control,)except ValueError as exc:- return _bad_request(exc, fallback="Invalid date_from, date_to, or source_id")+ return _bad_request(exc, fallback="Invalid date_from, date_to, granularity, or source_id")return Response(DoraOverviewSerializer(instance=result).data)diff --git a/products/engineering_analytics/backend/tests/test_dora.py b/products/engineering_analytics/backend/tests/test_dora.pyindex 886db6e18253..e57addc6fef5 100644--- a/products/engineering_analytics/backend/tests/test_dora.py+++ b/products/engineering_analytics/backend/tests/test_dora.py@@ -189,7 +189,7 @@ class TestDoraQuery(ClickhouseTestMixin, BaseTest):)assert result.deploy_data_available is True- assert result.environment_scope == "production"+ assert result.environment_scope == "prod" # the busiest (only) production-marked environmentassert result.environments == ["prod", "staging"]assert result.has_membership_data is Falseassert result.github_teams == []@@ -230,6 +230,9 @@ class TestDoraQuery(ClickhouseTestMixin, BaseTest):assert jan_13.deployed_pr_count == 2 # PRs 2 and 6, both deployed by d3assert jan_13.min_seconds == 9000.0assert jan_13.max_seconds == 97200.0+ # ClickHouse quantile interpolates linearly between the two samples.+ assert jan_13.p05_seconds == 13410.0+ assert jan_13.p95_seconds == 92790.0empty = lead[datetime(2026, 1, 15)]assert empty.deployed_pr_count == 0assert empty.p50_seconds is None@@ -422,7 +425,7 @@ class TestDoraQuery(ClickhouseTestMixin, BaseTest):curated=curated,date_from=datetime(2026, 1, 10, tzinfo=UTC),date_to=datetime(2026, 1, 20, tzinfo=UTC),- environment="staging",+ environments_filter=["staging"],)assert result.environment_scope == "staging"@@ -430,3 +433,43 @@ class TestDoraQuery(ClickhouseTestMixin, BaseTest):assert result.failed_deployment_count == 0# PR 1 (merged Jan 12 08:00) reaches staging's 09:00 success: a 1h lead time.assert result.median_merge_to_deploy_seconds == 3600.0++ both = query_dora_overview(+ curated=curated,+ date_from=datetime(2026, 1, 10, tzinfo=UTC),+ date_to=datetime(2026, 1, 20, tzinfo=UTC),+ environments_filter=["staging", "prod"],+ granularity="week",+ )++ assert both.environment_scope == "staging, prod"+ assert both.deployment_count == 2 # the multi-environment scope admits d1 and d4+ assert both.series_granularity == "week" # the caller's override beats the window fit++ def test_default_scope_picks_busiest_production_environment(self):+ # Two production-marked regions: the default scope takes the busiest one, so a+ # multi-region repo doesn't double-count every deploy and hand lead time to+ # whichever region ships first.+ curated = self._curated(+ self.team,+ deployment_rows=[+ _deployment_row(1, "sha-a", "prod-us", "2026-01-12 09:30:00", production=True),+ _deployment_row(2, "sha-b", "prod-us", "2026-01-13 09:30:00", production=True),+ _deployment_row(3, "sha-c", "prod-eu", "2026-01-12 09:30:00", production=True),+ ],+ status_rows=[+ _status_row(11, 1, "success", "prod-us", "2026-01-12 10:00:00"),+ _status_row(21, 2, "success", "prod-us", "2026-01-13 10:00:00"),+ _status_row(31, 3, "success", "prod-eu", "2026-01-12 10:00:00"),+ ],+ pr_rows=[_pr_row(1, "alice", "open", 0, "2026-01-11 08:00:00")],+ )+ result = query_dora_overview(+ curated=curated,+ date_from=datetime(2026, 1, 10, tzinfo=UTC),+ date_to=datetime(2026, 1, 20, tzinfo=UTC),+ )++ assert result.environment_scope == "prod-us"+ assert result.environments == ["prod-us", "prod-eu"]+ assert result.deployment_count == 2diff --git a/products/engineering_analytics/frontend/components/LeadTimeBoxPlot.stories.tsx b/products/engineering_analytics/frontend/components/LeadTimeBoxPlot.stories.tsxindex e98ec8fa6b04..007c3158cc0e 100644--- a/products/engineering_analytics/frontend/components/LeadTimeBoxPlot.stories.tsx+++ b/products/engineering_analytics/frontend/components/LeadTimeBoxPlot.stories.tsx@@ -12,10 +12,12 @@ function bucket(label,count,minSeconds: min,+ p05Seconds: (min + p25) / 2,p25Seconds: p25,p50Seconds: p50,meanSeconds: mean,p75Seconds: p75,+ p95Seconds: (p75 + max) / 2,maxSeconds: max,}}@@ -24,10 +26,12 @@ const EMPTY_BUCKET: BoxPlotBucket = {label: 'Jul 13',count: 0,minSeconds: null,+ p05Seconds: null,p25Seconds: null,p50Seconds: null,meanSeconds: null,p75Seconds: null,+ p95Seconds: null,maxSeconds: null,}diff --git a/products/engineering_analytics/frontend/components/LeadTimeBoxPlot.tsx b/products/engineering_analytics/frontend/components/LeadTimeBoxPlot.tsxindex 92af7018d5ab..ba7caa622d1e 100644--- a/products/engineering_analytics/frontend/components/LeadTimeBoxPlot.tsx+++ b/products/engineering_analytics/frontend/components/LeadTimeBoxPlot.tsx@@ -11,10 +11,12 @@ export interface BoxPlotBucket {/** Samples in the bucket; 0 renders an empty slot. */count: numberminSeconds: number | null+ p05Seconds: number | nullp25Seconds: number | nullp50Seconds: number | nullmeanSeconds: number | nullp75Seconds: number | null+ p95Seconds: number | nullmaxSeconds: number | null}@@ -26,6 +28,8 @@ export interface LeadTimeBoxPlotProps {buckets: BoxPlotBucket[]/** Value formatter for the tooltip rows (seconds in, short label out). */formatSeconds: (seconds: number) => string+ /** Draw the whiskers at p5/p95 instead of min/max, so one extreme PR can't flatten the boxes. */+ excludeOutliers?: booleandataAttr: stringclassName?: string}@@ -35,7 +39,7 @@ interface BucketMeta {counts: number[]}-function toDatum(bucket: BoxPlotBucket): BoxPlotDatum | null {+function toDatum(bucket: BoxPlotBucket, excludeOutliers: boolean): BoxPlotDatum | null {if (bucket.count === 0 ||bucket.minSeconds == null ||@@ -47,13 +51,16 @@ function toDatum(bucket: BoxPlotBucket): BoxPlotDatum | null {) {return null}+ // Older cached responses may lack p5/p95; fall back to the full range rather than dropping the bucket.+ const lower = excludeOutliers ? (bucket.p05Seconds ?? bucket.minSeconds) : bucket.minSeconds+ const upper = excludeOutliers ? (bucket.p95Seconds ?? bucket.maxSeconds) : bucket.maxSecondsreturn {- min: bucket.minSeconds,+ min: lower,p25: bucket.p25Seconds,median: bucket.p50Seconds,mean: bucket.meanSeconds,p75: bucket.p75Seconds,- max: bucket.maxSeconds,+ max: upper,}}@@ -68,6 +75,7 @@ export function LeadTimeBoxPlot({seriesLabel,buckets,formatSeconds,+ excludeOutliers = false,dataAttr,className,}: LeadTimeBoxPlotProps): JSX.Element {@@ -78,11 +86,11 @@ export function LeadTimeBoxPlot({{key: seriesKey,label: seriesLabel,- data: buckets.map(toDatum),+ data: buckets.map((bucket) => toDatum(bucket, excludeOutliers)),meta: { counts: buckets.map((bucket) => bucket.count) },},],- [seriesKey, seriesLabel, buckets]+ [seriesKey, seriesLabel, buckets, excludeOutliers])return (// The chart's root is a `flex-1` child, so the sized wrapper must be a flex column —@@ -94,7 +102,14 @@ export function LeadTimeBoxPlot({theme={theme}config={{ yTickFormatter: formatSeconds }}dataAttr={dataAttr}- tooltip={(ctx) => <BucketTooltip ctx={ctx} dataAttr={dataAttr} formatSeconds={formatSeconds} />}+ tooltip={(ctx) => (+ <BucketTooltip+ ctx={ctx}+ dataAttr={dataAttr}+ formatSeconds={formatSeconds}+ excludeOutliers={excludeOutliers}+ />+ )}/></div>)@@ -104,10 +119,12 @@ function BucketTooltip({ctx,dataAttr,formatSeconds,+ excludeOutliers,}: {ctx: BoxPlotTooltipContext<BucketMeta>dataAttr: stringformatSeconds: (seconds: number) => string+ excludeOutliers: boolean}): JSX.Element | null {const entry = ctx.seriesData[0]const datum = entry?.series.meta?.datums?.[ctx.dataIndex]@@ -116,12 +133,12 @@ function BucketTooltip({}const count = entry?.series.meta?.user?.counts?.[ctx.dataIndex] ?? 0const rows: [string, number][] = [- ['Max', datum.max],+ [excludeOutliers ? '95th percentile' : 'Max', datum.max],['75th percentile', datum.p75],['Median', datum.median],['Mean', datum.mean],['25th percentile', datum.p25],- ['Min', datum.min],+ [excludeOutliers ? '5th percentile' : 'Min', datum.min],]return (<TooltipSurface data-attr={`${dataAttr}-tooltip`}>diff --git a/products/engineering_analytics/frontend/components/MetricTile.tsx b/products/engineering_analytics/frontend/components/MetricTile.tsxindex 725c92c8ead9..63ca3d95f7d0 100644--- a/products/engineering_analytics/frontend/components/MetricTile.tsx+++ b/products/engineering_analytics/frontend/components/MetricTile.tsx@@ -91,11 +91,28 @@ function deltaToChange(delta: TileDelta | undefined): MetricChange | null {return { value: rounded, label: `${display}${delta.unit ?? '%'}` }}+export interface TileBenchmark {+ /** The band name (e.g. 'Elite'), named in the label tooltip. */+ label: string+ band: 'elite' | 'high' | 'medium' | 'low'+ /** The full benchmark ladder, shown in the label tooltip. */+ tooltip: string+}++// Left accent per band: border-l-4 + a token class, the same accent recipe as WorkflowsHealthHeader.+const BENCHMARK_EDGE_CLASS: Record<TileBenchmark['band'], string> = {+ elite: 'border-l-success',+ high: 'border-l-purple',+ medium: 'border-l-warning',+ low: 'border-l-danger',+}+export function MetricTile({label,tooltip,value,delta,+ benchmark,sub,loading = false,className,@@ -106,6 +123,9 @@ export function MetricTile({/** Pre-formatted headline value; '—' for no data. */value: stringdelta?: TileDelta+ /** Where the value lands against a published benchmark ladder, shown as a coloured edge on the+ * card plus the ladder detail in the label tooltip. */+ benchmark?: TileBenchmark | null/** Visible caption — only for an answer worth a glance (what's failing, why there's no value). */sub?: ReactNode/** Backend load in flight: skeleton the value so it doesn't flash a stale/zero number. Only for a@@ -113,8 +133,19 @@ export function MetricTile({loading?: booleanclassName?: string}): JSX.Element {- const labelNode = tooltip ? (- <Tooltip title={tooltip}>+ const tooltipContent =+ tooltip || benchmark ? (+ <div className="flex flex-col gap-1">+ {tooltip && <div>{tooltip}</div>}+ {benchmark && (+ <div>+ DORA band: {benchmark.label.toLowerCase()}. {benchmark.tooltip}+ </div>+ )}+ </div>+ ) : undefined+ const labelNode = tooltipContent ? (+ <Tooltip title={tooltipContent}><span className="cursor-default">{label}</span></Tooltip>) : (@@ -123,7 +154,11 @@ export function MetricTile({return (<LemonCardhoverEffect={false}- className={cn('flex min-w-44 flex-1 flex-col justify-center px-5 py-4', className)}+ className={cn(+ 'flex min-w-44 flex-1 flex-col justify-center px-5 py-4',+ benchmark && `border-l-4 ${BENCHMARK_EDGE_CLASS[benchmark.band]}`,+ className+ )}>{/* MetricCard has no loading prop; skeleton the whole tile on a genuine reload so it neverflashes a stale/zero headline (the loading-states rule). */}diff --git a/products/engineering_analytics/frontend/components/ScopeBar.tsx b/products/engineering_analytics/frontend/components/ScopeBar.tsxindex 808f72d4444b..7fa3ac57b3f1 100644--- a/products/engineering_analytics/frontend/components/ScopeBar.tsx+++ b/products/engineering_analytics/frontend/components/ScopeBar.tsx@@ -23,6 +23,7 @@ import { workflowSwitcherLogic } from '../scenes/workflowSwitcherLogic'export const SCOPE_DATE_OPTIONS = dateMapping.filter(({ key }) =>['Custom',+ 'Today','Last 24 hours','Last 7 days','Last 14 days',diff --git a/products/engineering_analytics/frontend/generated/api.schemas.ts b/products/engineering_analytics/frontend/generated/api.schemas.tsindex d7b35954ab2f..7dd8e3e301bf 100644--- a/products/engineering_analytics/frontend/generated/api.schemas.ts+++ b/products/engineering_analytics/frontend/generated/api.schemas.ts@@ -218,6 +218,11 @@ export interface LeadTimeBucketApi {* @nullable*/min_seconds: number | null+ /**+ * 5th percentile of the stage's duration, in seconds — the lower whisker when outliers are excluded. Null when nothing deployed.+ * @nullable+ */+ p05_seconds: number | null/*** 25th percentile of the stage's duration, in seconds. Null when nothing deployed.* @nullable@@ -238,6 +243,11 @@ export interface LeadTimeBucketApi {* @nullable*/p75_seconds: number | null+ /**+ * 95th percentile of the stage's duration, in seconds — the upper whisker when outliers are excluded. Null when nothing deployed.+ * @nullable+ */+ p95_seconds: number | null/*** Slowest duration for this stage in this bucket, in seconds. Null when nothing deployed.* @nullable@@ -248,7 +258,7 @@ export interface LeadTimeBucketApi {export interface DoraOverviewApi {/** Successful deployments per bucket across the window, oldest first, zero-filled, bucketed by series_granularity. Empty when the deploy tables aren't synced. */deployment_frequency_series: DeploymentFrequencyBucketApi[]- /** Merge-to-deploy distribution per bucket across the window, oldest first — the box-plot series (min/p25/p50/mean/p75/max seconds per bucket). Empty when the deploy tables aren't synced, or when github_team was passed without membership data synced. */+ /** Merge-to-deploy distribution per bucket across the window, oldest first — the box-plot series (min/p5/p25/p50/mean/p75/p95/max seconds per bucket). Empty when the deploy tables aren't synced, or when github_team was passed without membership data synced. */merge_to_deploy_series: LeadTimeBucketApi[]/** Open-to-merge distribution over the SAME deployed PRs and buckets as merge_to_deploy_series, so the two stages compare bucket by bucket. Not the all-merged-PRs cycle time. Empty in the same cases as merge_to_deploy_series. */open_to_merge_series: LeadTimeBucketApi[]@@ -256,7 +266,7 @@ export interface DoraOverviewApi {open_to_deploy_series: LeadTimeBucketApi[]/** False when the deployments/deployment_statuses tables aren't synced for the selected repo; every other field is then empty or null, never a fake zero. */deploy_data_available: boolean- /** What the environment filter resolved to: 'production' (deployments GitHub marks production_environment), an exact environment name (the one passed, or the busiest persistent environment when nothing is marked production), or 'persistent' (no persistent environment deployed in the window, so every non-transient one counts). Transient environments (ephemeral per-PR previews) never join a default scope. The scope resolves from deployments in the scan window, so two different windows can resolve different scopes and are not always comparable. */+ /** What the environment filter resolved to: the exact environment name(s) it matches (the caller's picks, comma-joined when several; by default the busiest production-marked environment, falling back to the busiest persistent one), or 'persistent' (no persistent environment deployed in the window, so every non-transient one counts). Transient environments (ephemeral per-PR previews) never join a default scope. The scope resolves from deployments in the scan window, so two different windows can resolve different scopes and are not always comparable. */environment_scope: string/** Distinct persistent environments deployed to in the scan window, most-deployed first — the environment picker's options. Transient environments are omitted but stay reachable by exact name. */environments: string[]@@ -338,7 +348,7 @@ export interface DoraOverviewApi {* @nullable*/latest_deploy_status_at: string | null- /** Bucket width of every series, chosen to fit the window: 'hour', 'day', or 'week'. */+ /** Bucket width of every series: the granularity param when given, else chosen to fit the window: 'hour', 'day', or 'week'. */series_granularity: string}@@ -1731,13 +1741,17 @@ export type EngineeringAnalyticsDoraParams = {*/date_to?: string/**- * Exact deploy environment to scope to (from the response's `environments` list). Omit to scope to production-marked deployments, falling back to every persistent (non-transient) environment when none are marked production.+ * Deploy environment(s) to scope to, repeatable (from the response's `environments` list). Omit to scope to the busiest environment GitHub marks production, falling back to the busiest persistent (non-transient) environment when none are marked production.*/- environment?: string+ environment?: string[]/*** GitHub team slug (from the response's `github_teams` list) to narrow the PR-scoped merge-to-deploy figures to that team's authors. Deploy counts stay repo-wide. Needs the team-membership snapshot synced; without it the merge-to-deploy figures return empty rather than silently unfiltered.*/github_team?: string+ /**+ * Bucket width for every series. Omit to pick one that fits the window: hour up to 48h, day up to 90 days, week beyond.+ */+ granularity?: EngineeringAnalyticsDoraGranularity/*** 'owner/name' repository to scope to when the selected source syncs several repositories (from the `sources` list). Defaults to the source's first repository.*/@@ -1748,6 +1762,15 @@ export type EngineeringAnalyticsDoraParams = {source_id?: string}+export type EngineeringAnalyticsDoraGranularity =+ (typeof EngineeringAnalyticsDoraGranularity)[keyof typeof EngineeringAnalyticsDoraGranularity]++export const EngineeringAnalyticsDoraGranularity = {+ Day: 'day',+ Hour: 'hour',+ Week: 'week',+} as const+export type EngineeringAnalyticsFlakyTestsParams = {/*** Window start: relative ('-7d', '-30d') or ISO8601. Defaults to -7d; the window may span at most 30 days.diff --git a/products/engineering_analytics/frontend/generated/api.ts b/products/engineering_analytics/frontend/generated/api.tsindex 846645f993ee..2d3a7579ba25 100644--- a/products/engineering_analytics/frontend/generated/api.ts+++ b/products/engineering_analytics/frontend/generated/api.ts@@ -272,6 +272,15 @@ export const getEngineeringAnalyticsDoraUrl = (projectId: string, params?: Enginconst normalizedParams = new URLSearchParams()Object.entries(params || {}).forEach(([key, value]) => {+ const explodeParameters = ['environment']++ if (Array.isArray(value) && explodeParameters.includes(key)) {+ value.forEach((v) => {+ normalizedParams.append(key, v === null ? 'null' : String(v))+ })+ return+ }+if (value !== undefined) {normalizedParams.append(key, value === null ? 'null' : String(value))}diff --git a/products/engineering_analytics/frontend/lib/doraBenchmark.test.ts b/products/engineering_analytics/frontend/lib/doraBenchmark.test.tsnew file mode 100644index 000000000000..09434d6ccfc8--- /dev/null+++ b/products/engineering_analytics/frontend/lib/doraBenchmark.test.ts@@ -0,0 +1,52 @@+import {+ changeFailureBenchmark,+ deploymentFrequencyBenchmark,+ leadTimeBenchmark,+ restoreTimeBenchmark,+} from './doraBenchmark'++describe('doraBenchmark', () => {+ it.each([+ [null, null],+ [0, null],+ [1, 'elite'],+ [0.9, 'high'],+ [1 / 7, 'high'],+ [0.1, 'medium'],+ [1 / 30, 'medium'],+ [0.01, 'low'],+ ])('deploymentFrequencyBenchmark(%p) is %p', (perDay, band) => {+ expect(deploymentFrequencyBenchmark(perDay)?.band ?? null).toBe(band)+ })++ it.each([+ [null, null],+ [3600, 'elite'],+ [86400, 'high'],+ [7 * 86400, 'medium'],+ [30 * 86400, 'low'],+ ])('leadTimeBenchmark(%p) is %p', (seconds, band) => {+ expect(leadTimeBenchmark(seconds)?.band ?? null).toBe(band)+ })++ it.each([+ [null, null],+ [0, 'elite'],+ [0.05, 'elite'],+ [0.1, 'high'],+ [0.15, 'medium'],+ [0.2, 'low'],+ ])('changeFailureBenchmark(%p) is %p', (share, band) => {+ expect(changeFailureBenchmark(share)?.band ?? null).toBe(band)+ })++ it.each([+ [null, null],+ [1800, 'elite'],+ [3600, 'high'],+ [86400, 'medium'],+ [7 * 86400, 'low'],+ ])('restoreTimeBenchmark(%p) is %p', (seconds, band) => {+ expect(restoreTimeBenchmark(seconds)?.band ?? null).toBe(band)+ })+})diff --git a/products/engineering_analytics/frontend/lib/doraBenchmark.ts b/products/engineering_analytics/frontend/lib/doraBenchmark.tsnew file mode 100644index 000000000000..ef01ac16dd9d--- /dev/null+++ b/products/engineering_analytics/frontend/lib/doraBenchmark.ts@@ -0,0 +1,107 @@+// DORA report performance bands for the four deploy metrics, so each Health tile can say+// which band the current window lands in. Thresholds are loosely modeled on the DORA State+// of DevOps report ladders (elite / high / medium / low), not a literal reproduction: the+// deployment-frequency and change-failure-rate bands are tuned tighter than the published+// report. Our change-failure and recovery figures are also deploy-status proxies, so the+// tile tooltips carry that caveat alongside the ladder.++const DAY_SECONDS = 86400+const WEEK_SECONDS = 7 * DAY_SECONDS+const MONTH_SECONDS = 30 * DAY_SECONDS++export type DoraBand = 'elite' | 'high' | 'medium' | 'low'++export interface DoraBenchmark {+ band: DoraBand+ /** The band name, shown in the label tooltip. */+ label: string+ /** The full DORA ladder for the metric, shown in the label tooltip. */+ tooltip: string+}++const BAND_LABELS: Record<DoraBand, string> = {+ elite: 'Elite',+ high: 'High',+ medium: 'Medium',+ low: 'Low',+}++function benchmark(band: DoraBand, ladder: string): DoraBenchmark {+ return { band, label: BAND_LABELS[band], tooltip: ladder }+}++const FREQUENCY_LADDER =+ 'DORA deployment frequency bands: elite deploys on demand (at least daily), high at least weekly, medium at least monthly, low less often.'++export function deploymentFrequencyBenchmark(perDay: number | null | undefined): DoraBenchmark | null {+ if (perDay == null || perDay <= 0) {+ return null+ }+ if (perDay >= 1) {+ return benchmark('elite', FREQUENCY_LADDER)+ }+ if (perDay >= 1 / 7) {+ return benchmark('high', FREQUENCY_LADDER)+ }+ if (perDay >= 1 / 30) {+ return benchmark('medium', FREQUENCY_LADDER)+ }+ return benchmark('low', FREQUENCY_LADDER)+}++const LEAD_TIME_LADDER =+ 'DORA lead time bands: elite under a day, high under a week, medium under a month, low over a month. Measured here as PR open to first successful deploy, a close proxy for DORA’s commit to production.'++export function leadTimeBenchmark(seconds: number | null | undefined): DoraBenchmark | null {+ if (seconds == null) {+ return null+ }+ if (seconds < DAY_SECONDS) {+ return benchmark('elite', LEAD_TIME_LADDER)+ }+ if (seconds < WEEK_SECONDS) {+ return benchmark('high', LEAD_TIME_LADDER)+ }+ if (seconds < MONTH_SECONDS) {+ return benchmark('medium', LEAD_TIME_LADDER)+ }+ return benchmark('low', LEAD_TIME_LADDER)+}++const CHANGE_FAILURE_LADDER =+ 'DORA change failure rate bands: elite 5% or less, high 10% or less, medium 15% or less, low above 15%. Measured here as the failed deployment share, a proxy with no incident data linked.'++export function changeFailureBenchmark(share: number | null | undefined): DoraBenchmark | null {+ if (share == null) {+ return null+ }+ if (share <= 0.05) {+ return benchmark('elite', CHANGE_FAILURE_LADDER)+ }+ if (share <= 0.1) {+ return benchmark('high', CHANGE_FAILURE_LADDER)+ }+ if (share <= 0.15) {+ return benchmark('medium', CHANGE_FAILURE_LADDER)+ }+ return benchmark('low', CHANGE_FAILURE_LADDER)+}++const RESTORE_LADDER =+ 'DORA failed deployment recovery bands: elite under an hour, high under a day, medium under a week, low over a week. Measured here as first failure to the next successful deploy, a proxy that misses non-deploy recoveries.'++export function restoreTimeBenchmark(seconds: number | null | undefined): DoraBenchmark | null {+ if (seconds == null) {+ return null+ }+ if (seconds < 3600) {+ return benchmark('elite', RESTORE_LADDER)+ }+ if (seconds < DAY_SECONDS) {+ return benchmark('high', RESTORE_LADDER)+ }+ if (seconds < WEEK_SECONDS) {+ return benchmark('medium', RESTORE_LADDER)+ }+ return benchmark('low', RESTORE_LADDER)+}diff --git a/products/engineering_analytics/frontend/scenes/EngineeringAnalyticsHealth.stories.tsx b/products/engineering_analytics/frontend/scenes/EngineeringAnalyticsHealth.stories.tsxindex d8e7d38413fc..a100a292f946 100644--- a/products/engineering_analytics/frontend/scenes/EngineeringAnalyticsHealth.stories.tsx+++ b/products/engineering_analytics/frontend/scenes/EngineeringAnalyticsHealth.stories.tsx@@ -44,10 +44,12 @@ function leadTimeSeries(stats: (number[] | null)[]): DoraOverviewApi['merge_to_dbucket_start: `2026-07-${day}T00:00:00Z`,deployed_pr_count: bucket ? bucket[0] : 0,min_seconds: bucket ? bucket[1] : null,+ p05_seconds: bucket ? (bucket[1] + bucket[2]) / 2 : null,p25_seconds: bucket ? bucket[2] : null,p50_seconds: bucket ? bucket[3] : null,mean_seconds: bucket ? bucket[4] : null,p75_seconds: bucket ? bucket[5] : null,+ p95_seconds: bucket ? (bucket[5] + bucket[6]) / 2 : null,max_seconds: bucket ? bucket[6] : null,}})@@ -55,7 +57,7 @@ function leadTimeSeries(stats: (number[] | null)[]): DoraOverviewApi['merge_to_dconst DORA: DoraOverviewApi = {deploy_data_available: true,- environment_scope: 'production',+ environment_scope: 'prod-us',environments: ['prod-us', 'prod-eu', 'dev'],has_membership_data: true,github_teams: ['team-devex', 'team-ingestion', 'team-replay'],@@ -65,16 +67,16 @@ const DORA: DoraOverviewApi = {deployments_per_day_prev: 7.4,median_merge_to_deploy_seconds: 2520,median_merge_to_deploy_seconds_prev: 3300,- median_open_to_deploy_seconds: 63000,- median_open_to_deploy_seconds_prev: 82500,+ median_open_to_deploy_seconds: 172800,+ median_open_to_deploy_seconds_prev: 150000,deployed_pr_count: 103,deployed_pr_count_prev: 88,failed_deployment_count: 2,failed_deployment_count_prev: 4,- failed_deployment_share: 0.032,+ failed_deployment_share: 0.12,failed_deployment_share_prev: 0.071,- median_failed_deploy_to_next_success_seconds: 2280,- median_failed_deploy_to_next_success_seconds_prev: 3540,+ median_failed_deploy_to_next_success_seconds: 691200,+ median_failed_deploy_to_next_success_seconds_prev: 540000,merged_pr_count: 112,unattributed_merged_pr_share: 0.045,latest_deploy_status_at: '2026-07-14T22:00:00Z',@@ -129,12 +131,9 @@ const meta: Meta = {mockDate: '2026-07-15',featureFlags: [FEATURE_FLAGS.ENGINEERING_ANALYTICS],testOptions: {- // Past the skeletons once all three stacked box-plot charts have rendered.- waitForSelector: [- '[data-attr="engineering-analytics-dora-open-to-deploy-box-plot"] canvas',- '[data-attr="engineering-analytics-dora-open-to-merge-box-plot"] canvas',- '[data-attr="engineering-analytics-dora-box-plot"] canvas',- ],+ // Past the skeletons once the open-to-deploy box plot has rendered; the other two+ // stages sit behind the stage toggle and are collapsed by default.+ waitForSelector: '[data-attr="engineering-analytics-dora-open-to-deploy-box-plot"] canvas',},},decorators: [@@ -160,6 +159,14 @@ const meta: Meta = {entries: [],source_url: '',},+ 'api/projects/:team_id/engineering_analytics/trunk_quarantine/': {+ available: false,+ ttl_days: 15,+ repository: 'PostHog/posthog',+ trunk_url: null,+ teams: [],+ tests: [],+ },'api/projects/:team_id/engineering_analytics/flaky_tests/': {items: [],truncated: false,diff --git a/products/engineering_analytics/frontend/scenes/EngineeringAnalyticsHealth.tsx b/products/engineering_analytics/frontend/scenes/EngineeringAnalyticsHealth.tsxindex e877c32131df..33b9bf822c77 100644--- a/products/engineering_analytics/frontend/scenes/EngineeringAnalyticsHealth.tsx+++ b/products/engineering_analytics/frontend/scenes/EngineeringAnalyticsHealth.tsx@@ -1,7 +1,8 @@import { useActions, useValues } from 'kea'import { useMemo } from 'react'-import { LemonBanner, LemonSelect, LemonSkeleton } from '@posthog/lemon-ui'+import { IconChevronDown, IconChevronRight } from '@posthog/icons'+import { LemonBanner, LemonButton, LemonInputSelect, LemonSelect, LemonSkeleton, LemonSwitch } from '@posthog/lemon-ui'import { TimeSeriesBarChart, useChartTheme, type TimeInterval } from '@posthog/quill-charts'import { dayjs } from 'lib/dayjs'@@ -12,6 +13,12 @@ import { LeadTimeBoxPlot } from '../components/LeadTimeBoxPlot'import { MetricTile, percentChange, pointChange } from '../components/MetricTile'import { ScopeBar, SourceScopeChip } from '../components/ScopeBar'import { Section } from '../components/Section'+import {+ changeFailureBenchmark,+ deploymentFrequencyBenchmark,+ leadTimeBenchmark,+ restoreTimeBenchmark,+} from '../lib/doraBenchmark'import { compactAgeLabel } from '../lib/format'import { doraLogic } from './doraLogic'@@ -21,8 +28,9 @@ export function EngineeringAnalyticsHealth(): JSX.Element {dora,doraLoading,doraFailed,- environment,+ environments,githubTeam,+ granularity,boxPlotBuckets,openToMergeBuckets,openToDeployBuckets,@@ -31,8 +39,11 @@ export function EngineeringAnalyticsHealth(): JSX.Element {environmentScopeLabel,environmentOptions,githubTeamOptions,+ showAllLeadTimeStages,+ excludeOutliers,} = useValues(doraLogic)- const { setEnvironment, setGithubTeam, loadDora } = useActions(doraLogic)+ const { setEnvironments, setExcludeOutliers, setGithubTeam, setGranularity, toggleLeadTimeStages, loadDora } =+ useActions(doraLogic)const chartTheme = useChartTheme()const frequencySeries = useMemo(() => [{ key: 'deployments', label: 'Deployments', data: frequencyCounts }],@@ -87,13 +98,17 @@ export function EngineeringAnalyticsHealth(): JSX.Element {</div>) : (<div className="flex flex-wrap items-center gap-2">- <LemonSelect- size="small"- value={environment}- onChange={setEnvironment}- options={environmentOptions}- data-attr="engineering-analytics-dora-environment-select"- />+ <div className="min-w-60" data-attr="engineering-analytics-dora-environment-select">+ <LemonInputSelect+ size="small"+ mode="multiple"+ value={environments}+ onChange={setEnvironments}+ options={environmentOptions}+ placeholder={`Default environment (${environmentScopeLabel})`}+ allowCustomValues={false}+ />+ </div>{dora?.has_membership_data && (<LemonSelectsize="small"@@ -118,156 +133,203 @@ export function EngineeringAnalyticsHealth(): JSX.Element {)}</div>)}- <div className="grid grid-cols-1 gap-3 md:grid-cols-2 xl:grid-cols-4">- <MetricTile- label="Deployment frequency"- tooltip={`Successful deployments per day in the ${environmentScopeLabel} scope: ${dora?.deployment_count ?? 0} in this window.`}- value={dora?.deployments_per_day != null ? `${dora.deployments_per_day.toFixed(1)}/day` : '—'}- delta={{ value: percentChange(dora?.deployments_per_day, dora?.deployments_per_day_prev) }}- sub={- dora && dora.deploy_data_available && dora.deployment_count === 0- ? 'No successful deployments in this window.'- : undefined- }- loading={firstLoad}- />- <MetricTile- label="Open to deploy"- tooltip={`Median from a PR's open to the first successful deployment containing it, over ${dora?.deployed_pr_count ?? 0} deployed PRs (bots and drafts excluded). The full lead time: the box plots below split it into open to merge and merge to deploy.`}- value={- dora?.median_open_to_deploy_seconds != null- ? compactAgeLabel(dora.median_open_to_deploy_seconds)- : '—'- }- delta={{- value: percentChange(- dora?.median_open_to_deploy_seconds,- dora?.median_open_to_deploy_seconds_prev- ),- goodWhenDown: true,- }}- sub={- dora && dora.median_open_to_deploy_seconds == null- ? 'No PRs were deployed in this window.'- : undefined- }- loading={firstLoad}- />- <MetricTile- label="Failed deployment share"- tooltip={`Deployments with a failure or error status over deployments that reached an outcome (${dora?.failed_deployment_count ?? 0} failed here). A change failure proxy: deploys that succeeded but broke production aren't counted, because no incident data is linked.`}- value={- dora?.failed_deployment_share != null- ? `${(dora.failed_deployment_share * 100).toFixed(1)}%`- : '—'- }- delta={{- value: pointChange(dora?.failed_deployment_share, dora?.failed_deployment_share_prev),- unit: 'pt',- goodWhenDown: true,- }}- sub={- dora && dora.failed_deployment_share == null- ? 'No deployments reached an outcome in this window.'- : undefined- }- loading={firstLoad}- />- <MetricTile- label="Failed deploy to next success"- tooltip="Median wait from a deployment's first failure status to the next successful deployment in the same environment. A time to restore proxy: recovery by anything other than a deploy is invisible, and unrecovered failures are excluded."- value={- dora?.median_failed_deploy_to_next_success_seconds != null- ? compactAgeLabel(dora.median_failed_deploy_to_next_success_seconds)- : '—'- }- delta={{- value: percentChange(- dora?.median_failed_deploy_to_next_success_seconds,- dora?.median_failed_deploy_to_next_success_seconds_prev- ),- goodWhenDown: true,- }}- sub={- dora && dora.median_failed_deploy_to_next_success_seconds == null- ? 'No failed deployment recovered in this window.'- : undefined- }- loading={firstLoad}- />- </div>- <Section- id="merge-to-deploy"- title="Lead time distributions"- note="Box per bucket: whisker min to max, box p25 to p75, line at the median, dot at the mean. All three stages cover the same deployed PRs, so they compare bucket by bucket. Buckets key on deploy time."- busy={doraLoading && !!dora}+ <Section id="dora-metrics" title="DORA metrics" busy={doraLoading && !!dora}>+ <div className="grid grid-cols-1 gap-3 md:grid-cols-2 xl:grid-cols-4">+ <MetricTile+ label="Deployment frequency"+ tooltip={`Successful deployments per day in the ${environmentScopeLabel} scope: ${dora?.deployment_count ?? 0} in this window.`}+ value={dora?.deployments_per_day != null ? `${dora.deployments_per_day.toFixed(1)}/day` : '—'}+ delta={{ value: percentChange(dora?.deployments_per_day, dora?.deployments_per_day_prev) }}+ benchmark={deploymentFrequencyBenchmark(dora?.deployments_per_day)}+ sub={+ dora && dora.deploy_data_available && dora.deployment_count === 0+ ? 'No successful deployments in this window.'+ : undefined+ }+ loading={firstLoad}+ />+ <MetricTile+ label="Open to deploy"+ tooltip={`Median from a PR's open to the first successful deployment containing it, over ${dora?.deployed_pr_count ?? 0} deployed PRs (bots and drafts excluded). The full lead time: the box plots below split it into open to merge and merge to deploy.`}+ value={+ dora?.median_open_to_deploy_seconds != null+ ? compactAgeLabel(dora.median_open_to_deploy_seconds)+ : '—'+ }+ delta={{+ value: percentChange(+ dora?.median_open_to_deploy_seconds,+ dora?.median_open_to_deploy_seconds_prev+ ),+ goodWhenDown: true,+ }}+ benchmark={leadTimeBenchmark(dora?.median_open_to_deploy_seconds)}+ sub={+ dora && dora.median_open_to_deploy_seconds == null+ ? 'No PRs were deployed in this window.'+ : undefined+ }+ loading={firstLoad}+ />+ <MetricTile+ label="Failed deployment share"+ tooltip={`Deployments with a failure or error status over deployments that reached an outcome (${dora?.failed_deployment_count ?? 0} failed here). A change failure proxy: deploys that succeeded but broke production aren't counted, because no incident data is linked.`}+ value={+ dora?.failed_deployment_share != null+ ? `${(dora.failed_deployment_share * 100).toFixed(1)}%`+ : '—'+ }+ delta={{+ value: pointChange(dora?.failed_deployment_share, dora?.failed_deployment_share_prev),+ unit: 'pt',+ goodWhenDown: true,+ }}+ benchmark={changeFailureBenchmark(dora?.failed_deployment_share)}+ sub={+ dora && dora.failed_deployment_share == null+ ? 'No deployments reached an outcome in this window.'+ : undefined+ }+ loading={firstLoad}+ />+ <MetricTile+ label="Failed deploy to next success"+ tooltip="Median wait from a deployment's first failure status to the next successful deployment in the same environment. A time to restore proxy: recovery by anything other than a deploy is invisible, and unrecovered failures are excluded."+ value={+ dora?.median_failed_deploy_to_next_success_seconds != null+ ? compactAgeLabel(dora.median_failed_deploy_to_next_success_seconds)+ : '—'+ }+ delta={{+ value: percentChange(+ dora?.median_failed_deploy_to_next_success_seconds,+ dora?.median_failed_deploy_to_next_success_seconds_prev+ ),+ goodWhenDown: true,+ }}+ benchmark={restoreTimeBenchmark(dora?.median_failed_deploy_to_next_success_seconds)}+ sub={+ dora && dora.median_failed_deploy_to_next_success_seconds == null+ ? 'No failed deployment recovered in this window.'+ : undefined+ }+ loading={firstLoad}+ />+ </div>+ </Section>+ <div+ className="flex flex-col gap-4 rounded border bg-surface-primary p-4"+ data-attr="engineering-analytics-dora-grouped-charts">- {firstLoad ? (- <LemonSkeleton className="h-40 w-full" />- ) : boxPlotBuckets.length === 0 ? (- <div className="py-8 text-center text-sm text-secondary">- {githubTeam && dora && !dora.has_membership_data- ? 'Team membership data is not synced, so the team filter cannot be applied.'- : 'No deploy data for this window.'}- </div>- ) : (- <>- <div className="flex flex-col gap-4">- {leadTimeStages.map((stage) => (- <div key={stage.seriesKey} data-attr={stage.wrapperDataAttr}>- <h3 className="m-0 mb-1 text-xs font-semibold text-secondary">{stage.title}</h3>- <LeadTimeBoxPlot- seriesKey={stage.seriesKey}- seriesLabel={stage.seriesLabel}- buckets={stage.buckets}- formatSeconds={compactAgeLabel}- dataAttr={stage.dataAttr}- />- </div>- ))}+ <div className="flex items-center justify-end gap-2">+ <LemonSwitch+ size="small"+ bordered+ label="Exclude outliers"+ checked={excludeOutliers}+ onChange={setExcludeOutliers}+ data-attr="engineering-analytics-dora-exclude-outliers"+ />+ <LemonSelect+ size="small"+ value={granularity}+ onChange={setGranularity}+ options={[+ { value: null, label: 'Group automatically' },+ { value: 'hour' as const, label: 'Group by hour' },+ { value: 'day' as const, label: 'Group by day' },+ { value: 'week' as const, label: 'Group by week' },+ ]}+ data-attr="engineering-analytics-dora-granularity-select"+ />+ </div>+ <Section+ id="merge-to-deploy"+ title="Lead time distributions"+ note={`Box per bucket: whisker ${excludeOutliers ? 'p5 to p95' : 'min to max'}, box p25 to p75, line at the median, dot at the mean. Buckets key on deploy time.`}+ busy={doraLoading && !!dora}+ >+ {firstLoad ? (+ <LemonSkeleton className="h-40 w-full" />+ ) : boxPlotBuckets.length === 0 ? (+ <div className="py-8 text-center text-sm text-secondary">+ {githubTeam && dora && !dora.has_membership_data+ ? 'Team membership data is not synced, so the team filter cannot be applied.'+ : 'No deploy data for this window.'}</div>- {dora?.unattributed_merged_pr_share != null && dora.unattributed_merged_pr_share > 0 && (- <div- className="mt-2 text-xs text-tertiary"- data-attr="engineering-analytics-dora-unattributed"- >- {(dora.unattributed_merged_pr_share * 100).toFixed(1)}% of the {dora.merged_pr_count}{' '}- PRs merged in this window have no deploy attributed yet, usually because their deploy- hasn't happened or synced.+ ) : (+ <>+ <div className="flex flex-col gap-4">+ {(showAllLeadTimeStages ? leadTimeStages : leadTimeStages.slice(0, 1)).map((stage) => (+ <div key={stage.seriesKey} data-attr={stage.wrapperDataAttr}>+ <h3 className="m-0 mb-1 text-xs font-semibold text-secondary">{stage.title}</h3>+ <LeadTimeBoxPlot+ seriesKey={stage.seriesKey}+ seriesLabel={stage.seriesLabel}+ buckets={stage.buckets}+ formatSeconds={compactAgeLabel}+ excludeOutliers={excludeOutliers}+ dataAttr={stage.dataAttr}+ />+ </div>+ ))}</div>- )}- </>- )}- </Section>- <Section- id="deployment-frequency"- title="Deployments over time"- note={`Successful deployments per bucket in the ${environmentScopeLabel} scope.`}- busy={doraLoading && !!dora}- >- {firstLoad ? (- <LemonSkeleton className="h-40 w-full" />- ) : frequencyCounts.length === 0 ? (- <div className="py-8 text-center text-sm text-secondary">No deploy data for this window.</div>- ) : (- // The chart's root is a `flex-1` child, so the sized wrapper must be a flex column.- <div className="flex h-40 flex-col" data-attr="engineering-analytics-dora-frequency-chart">- <TimeSeriesBarChart- series={frequencySeries}- labels={frequencyIsoLabels}- theme={chartTheme}- config={{- xAxis: {- timezone: 'UTC',- interval: (dora?.series_granularity ?? 'day') as TimeInterval,- },- yAxis: { format: 'numeric', decimalPlaces: 0 },- minBarSize: 2,- }}- />- </div>- )}- </Section>+ <div className="mt-2">+ <LemonButton+ size="xsmall"+ type="tertiary"+ icon={showAllLeadTimeStages ? <IconChevronDown /> : <IconChevronRight />}+ onClick={toggleLeadTimeStages}+ data-attr="engineering-analytics-dora-stage-toggle"+ >+ {showAllLeadTimeStages+ ? 'Hide open to merge and merge to deploy'+ : 'Show open to merge and merge to deploy'}+ </LemonButton>+ </div>+ {dora?.unattributed_merged_pr_share != null && dora.unattributed_merged_pr_share > 0 && (+ <div+ className="mt-2 text-xs text-tertiary"+ data-attr="engineering-analytics-dora-unattributed"+ >+ {(dora.unattributed_merged_pr_share * 100).toFixed(1)}% of the{' '}+ {dora.merged_pr_count} PRs merged in this window have no deploy attributed yet,+ usually because their deploy hasn't happened or synced.+ </div>+ )}+ </>+ )}+ </Section>+ <Section+ id="deployment-frequency"+ title="Deployments over time"+ note={`Successful deployments per bucket in the ${environmentScopeLabel} scope.`}+ busy={doraLoading && !!dora}+ >+ {firstLoad ? (+ <LemonSkeleton className="h-40 w-full" />+ ) : frequencyCounts.length === 0 ? (+ <div className="py-8 text-center text-sm text-secondary">No deploy data for this window.</div>+ ) : (+ // The chart's root is a `flex-1` child, so the sized wrapper must be a flex column.+ <div className="flex h-40 flex-col" data-attr="engineering-analytics-dora-frequency-chart">+ <TimeSeriesBarChart+ series={frequencySeries}+ labels={frequencyIsoLabels}+ theme={chartTheme}+ config={{+ xAxis: {+ timezone: 'UTC',+ interval: (dora?.series_granularity ?? 'day') as TimeInterval,+ },+ yAxis: { format: 'numeric', decimalPlaces: 0 },+ minBarSize: 2,+ }}+ />+ </div>+ )}+ </Section>+ </div></div>)}diff --git a/products/engineering_analytics/frontend/scenes/doraLogic.ts b/products/engineering_analytics/frontend/scenes/doraLogic.tsindex dd3631602ba3..11249ae014a1 100644--- a/products/engineering_analytics/frontend/scenes/doraLogic.ts+++ b/products/engineering_analytics/frontend/scenes/doraLogic.ts@@ -2,6 +2,7 @@ import { MakeLogicType, actions, afterMount, connect, kea, listeners, path, reduimport { loaders } from 'kea-loaders'import { ApiConfig } from 'lib/api'+import { intervals } from 'lib/components/IntervalFilter/intervals'import type { BoxPlotBucket } from '../components/LeadTimeBoxPlot'import { engineeringAnalyticsDora } from '../generated/api'@@ -18,10 +19,12 @@ function toBoxPlotBuckets(series: LeadTimeSeriesApi | undefined, granularity: stlabel: formatBucket(bucket.bucket_start, granularity as WorkflowGranularity),count: bucket.deployed_pr_count,minSeconds: bucket.min_seconds,+ p05Seconds: bucket.p05_seconds,p25Seconds: bucket.p25_seconds,p50Seconds: bucket.p50_seconds,meanSeconds: bucket.mean_seconds,p75Seconds: bucket.p75_seconds,+ p95Seconds: bucket.p95_seconds,maxSeconds: bucket.max_seconds,}))}@@ -31,6 +34,8 @@ export interface DoraScopeOption {label: string}+export type DoraGranularity = 'hour' | 'day' | 'week'+// Generated by kea-typegen. Update if you're an agent, ignore if you're human.export interface doraLogicValues {dateFrom: string | null // engineeringAnalyticsFiltersLogic@@ -42,20 +47,26 @@ export interface doraLogicValues {dora: DoraOverviewApi | nulldoraFailed: booleandoraLoading: boolean- environment: string | null- environmentOptions: DoraScopeOption[]+ environmentOptions: {+ key: string+ label: string+ }[]environmentScopeLabel: string+ environments: string[]+ excludeOutliers: booleanfrequencyCounts: number[]frequencyIsoLabels: string[]githubTeam: string | nullgithubTeamOptions: DoraScopeOption[]+ granularity: DoraGranularity | nullopenToDeployBuckets: BoxPlotBucket[]openToMergeBuckets: BoxPlotBucket[]+ showAllLeadTimeStages: boolean}// Generated by kea-typegen. Update if you're an agent, ignore if you're human.export interface doraLogicActions {- loadDora: () => any+ loadDora: (_: void) => voidloadDoraFailure: (error: string,errorObject?: any@@ -65,17 +76,29 @@ export interface doraLogicActions {}loadDoraSuccess: (dora: DoraOverviewApi,- payload?: any+ payload?: void) => {dora: DoraOverviewApi- payload?: any+ payload?: void+ }+ resetGranularity: () => {+ value: true+ }+ setEnvironments: (environments: string[]) => {+ environments: string[]}- setEnvironment: (environment: string | null) => {- environment: string | null+ setExcludeOutliers: (excludeOutliers: boolean) => {+ excludeOutliers: boolean}setGithubTeam: (githubTeam: string | null) => {githubTeam: string | null}+ setGranularity: (granularity: DoraGranularity | null) => {+ granularity: DoraGranularity | null+ }+ toggleLeadTimeStages: () => {+ value: true+ }}// Generated by kea-typegen. Update if you're an agent, ignore if you're human.@@ -86,8 +109,14 @@ export interface doraLogicMeta {openToDeployBuckets: (dora: DoraOverviewApi | null) => BoxPlotBucket[]frequencyCounts: (dora: DoraOverviewApi | null) => number[]frequencyIsoLabels: (dora: DoraOverviewApi | null) => string[]- environmentScopeLabel: (dora: DoraOverviewApi | null) => string- environmentOptions: (dora: DoraOverviewApi | null, environment: string | null) => DoraScopeOption[]+ environmentScopeLabel: (dora: DoraOverviewApi | null, environments: string[]) => string+ environmentOptions: (+ dora: DoraOverviewApi | null,+ environments: string[]+ ) => {+ key: string+ label: string+ }[]githubTeamOptions: (dora: DoraOverviewApi | null) => DoraScopeOption[]}}@@ -107,23 +136,32 @@ export const doraLogic = kea<doraLogicType>([})),actions({- setEnvironment: (environment: string | null) => ({ environment }),+ setEnvironments: (environments: string[]) => ({ environments }),+ setExcludeOutliers: (excludeOutliers: boolean) => ({ excludeOutliers }),setGithubTeam: (githubTeam: string | null) => ({ githubTeam }),+ setGranularity: (granularity: DoraGranularity | null) => ({ granularity }),+ resetGranularity: true,+ toggleLeadTimeStages: true,}),loaders(({ values }) => ({dora: [null as DoraOverviewApi | null,{- loadDora: async (): Promise<DoraOverviewApi> =>- await engineeringAnalyticsDora(projectId(), {+ loadDora: async (_: void, breakpoint): Promise<DoraOverviewApi> => {+ const response = await engineeringAnalyticsDora(projectId(), {date_from: values.dateFrom ?? undefined,date_to: values.dateTo ?? undefined,- environment: values.environment ?? undefined,+ environment: values.environments.length ? values.environments : undefined,github_team: values.githubTeam ?? undefined,+ granularity: values.granularity ?? undefined,source_id: values.sourceId ?? undefined,repo: values.scopeRepo ?? undefined,- }),+ })+ // breakpoint() throws if a newer loadDora call has started, discarding this stale response.+ breakpoint()+ return response+ },},],})),@@ -138,15 +176,35 @@ export const doraLogic = kea<doraLogicType>([loadDoraFailure: () => true,},],- // null means the backend's default scope: production-marked deploys, falling back to all.- // Reset on a source/repo scope change: an environment or team from the old repo may not- // exist on the new one, and would otherwise be sent as a silently-empty exact filter.- environment: [- null as string | null,+ // Empty means the backend's default scope: the busiest production-marked environment,+ // falling back to the busiest persistent one. Reset on a source/repo scope change: an+ // environment or team from the old repo may not exist on the new one, and would+ // otherwise be sent as a silently-empty exact filter.+ environments: [+ [] as string[],{- setEnvironment: (_, { environment }) => environment,- [engineeringAnalyticsLogic.actionTypes.setSourceId]: () => null,- [engineeringAnalyticsLogic.actionTypes.setScope]: () => null,+ setEnvironments: (_, { environments }) => environments,+ [engineeringAnalyticsLogic.actionTypes.setSourceId]: () => [],+ [engineeringAnalyticsLogic.actionTypes.setScope]: () => [],+ },+ ],+ granularity: [+ null as DoraGranularity | null,+ {+ setGranularity: (_, { granularity }) => granularity,+ resetGranularity: () => null,+ },+ ],+ showAllLeadTimeStages: [+ false,+ {+ toggleLeadTimeStages: (state: boolean) => !state,+ },+ ],+ excludeOutliers: [+ false,+ {+ setExcludeOutliers: (_: boolean, { excludeOutliers }: { excludeOutliers: boolean }) => excludeOutliers,},],githubTeam: [@@ -188,32 +246,24 @@ export const doraLogic = kea<doraLogicType>([(dora?.deployment_frequency_series ?? []).map((bucket) => bucket.bucket_start),],environmentScopeLabel: [- (s) => [s.dora],- (dora: DoraOverviewApi | null): string =>- !dora || dora.environment_scope === 'production'- ? 'production'- : dora.environment_scope === 'persistent'- ? 'all persistent environments'- : dora.environment_scope,+ (s) => [s.dora, s.environments],+ (dora: DoraOverviewApi | null, environments: string[]): string =>+ environments.length+ ? environments.join(', ')+ : !dora+ ? 'production'+ : dora.environment_scope === 'persistent'+ ? 'all persistent environments'+ : dora.environment_scope,],+ // With environments selected, environment_scope echoes the picks, so the resolved default+ // can only be offered while the selection is empty; picked names stay selectable options.environmentOptions: [- (s) => [s.dora, s.environment],- (dora: DoraOverviewApi | null, environment: string | null): DoraScopeOption[] => [- {- value: null,- // With an explicit environment selected, environment_scope echoes that pick, so- // it can no longer describe what the default would resolve to.- label:- environment !== null || !dora- ? 'Default environment'- : dora.environment_scope === 'production'- ? 'Production'- : dora.environment_scope === 'persistent'- ? 'All persistent environments'- : `${dora.environment_scope} (default)`,- },- ...(dora?.environments ?? []).map((name) => ({ value: name as string | null, label: name })),- ],+ (s) => [s.dora, s.environments],+ (dora: DoraOverviewApi | null, environments: string[]): { key: string; label: string }[] => {+ const names = new Set([...(dora?.environments ?? []), ...environments])+ return [...names].map((name) => ({ key: name, label: name }))+ },],githubTeamOptions: [(s) => [s.dora],@@ -224,10 +274,30 @@ export const doraLogic = kea<doraLogicType>([],}),- listeners(({ actions }) => ({- setEnvironment: () => actions.loadDora(),+ listeners(({ actions, values, cache }) => ({+ setEnvironments: () => actions.loadDora(),setGithubTeam: () => actions.loadDora(),- [engineeringAnalyticsFiltersLogic.actionTypes.setDateRange]: () => actions.loadDora(),+ // Grouping and the date range co-adjust, sharing insights' interval mechanism: picking a+ // grouping snaps the range to one that fits it (the shared intervals map, e.g. hour ->+ // today), and a range change hands grouping back to the backend's automatic fit — so an+ // hour grouping can never span a year's worth of buckets.+ setGranularity: ({ granularity }) => {+ const newDateFrom = granularity ? intervals[granularity].newDateFrom : undefined+ if (newDateFrom) {+ cache.snappingRangeToGranularity = true+ engineeringAnalyticsFiltersLogic.actions.setDateRange(newDateFrom, null)+ return // the setDateRange listener below reloads+ }+ actions.loadDora()+ },+ [engineeringAnalyticsFiltersLogic.actionTypes.setDateRange]: () => {+ if (cache.snappingRangeToGranularity) {+ cache.snappingRangeToGranularity = false+ } else if (values.granularity !== null) {+ actions.resetGranularity()+ }+ actions.loadDora()+ },[engineeringAnalyticsLogic.actionTypes.setSourceId]: () => actions.loadDora(),[engineeringAnalyticsLogic.actionTypes.refresh]: () => actions.loadDora(),})),diff --git a/products/engineering_analytics/mcp/tools.yaml b/products/engineering_analytics/mcp/tools.yamlindex cbcd8866cd57..22463f6c7e73 100644--- a/products/engineering_analytics/mcp/tools.yaml+++ b/products/engineering_analytics/mcp/tools.yaml@@ -88,15 +88,18 @@ tools:deployed-PR population and buckets — open_to_merge_series (PR open to merge), merge_to_deploy_series (medianseconds from a PR's merge to the first successful deployment at or after it, bots/drafts excluded), andopen_to_deploy_series (the full open-to-deploy span the other two compose into) — each a per-bucket- min/p25/p50/mean/p75/max box-plot series, and two honest proxies: failed_deployment_share (deployments with- a failure/error status over deployments that reached an outcome — NOT true change failure rate, since no- incident data is linked) and median_failed_deploy_to_next_success_seconds (first failure status to the next- successful deploy in the same environment — NOT true time-to-restore, since recovery by anything other than- a deploy is invisible). Environments default to production-marked deploys, falling back to every persistent- (non-transient) environment — ephemeral per-PR preview environments never join a default scope; pass- environment to scope exactly. Pass github_team (a slug from github_teams) to narrow the PR-scoped lead-time- figures to that team's authors — deploy counts stay repo-wide. deploy_data_available is false when the- deployments endpoints aren't synced on the GitHub source; the fix is enabling them, not re-querying.+ min/p5/p25/p50/mean/p75/p95/max box-plot series, bucketed by series_granularity (pass granularity to pin+ hour/day/week, otherwise it's chosen to fit the window), and two honest proxies: failed_deployment_share+ (deployments with a failure/error status over deployments that reached an outcome — NOT true change failure+ rate, since no incident data is linked) and median_failed_deploy_to_next_success_seconds (first failure+ status to the next successful deploy in the same environment — NOT true time-to-restore, since recovery by+ anything other than a deploy is invisible). Environments default to the busiest production-marked+ environment, falling back to the busiest persistent (non-transient) one when none are marked production —+ ephemeral per-PR preview environments never join a default scope; pass environment (repeatable, from the+ response's environments list) to scope exactly. Pass github_team (a slug from github_teams) to narrow the+ PR-scoped lead-time figures to that team's authors — deploy counts stay repo-wide. deploy_data_available is+ false when the deployments endpoints aren't synced on the GitHub source; the fix is enabling them, not+ re-querying.engineering-analytics-flaky-tests:operation: engineering_analytics_flaky_testsenabled: truediff --git a/services/mcp/src/api/generated.ts b/services/mcp/src/api/generated.tsindex 66e6d6bef694..0d8bb7d0302d 100644--- a/services/mcp/src/api/generated.ts+++ b/services/mcp/src/api/generated.ts@@ -29037,6 +29037,11 @@ export namespace Schemas {* @nullable*/min_seconds: number | null;+ /**+ * 5th percentile of the stage's duration, in seconds — the lower whisker when outliers are excluded. Null when nothing deployed.+ * @nullable+ */+ p05_seconds: number | null;/*** 25th percentile of the stage's duration, in seconds. Null when nothing deployed.* @nullable@@ -29057,6 +29062,11 @@ export namespace Schemas {* @nullable*/p75_seconds: number | null;+ /**+ * 95th percentile of the stage's duration, in seconds — the upper whisker when outliers are excluded. Null when nothing deployed.+ * @nullable+ */+ p95_seconds: number | null;/*** Slowest duration for this stage in this bucket, in seconds. Null when nothing deployed.* @nullable@@ -29067,7 +29077,7 @@ export namespace Schemas {export interface DoraOverview {/** Successful deployments per bucket across the window, oldest first, zero-filled, bucketed by series_granularity. Empty when the deploy tables aren't synced. */deployment_frequency_series: DeploymentFrequencyBucket[];- /** Merge-to-deploy distribution per bucket across the window, oldest first — the box-plot series (min/p25/p50/mean/p75/max seconds per bucket). Empty when the deploy tables aren't synced, or when github_team was passed without membership data synced. */+ /** Merge-to-deploy distribution per bucket across the window, oldest first — the box-plot series (min/p5/p25/p50/mean/p75/p95/max seconds per bucket). Empty when the deploy tables aren't synced, or when github_team was passed without membership data synced. */merge_to_deploy_series: LeadTimeBucket[];/** Open-to-merge distribution over the SAME deployed PRs and buckets as merge_to_deploy_series, so the two stages compare bucket by bucket. Not the all-merged-PRs cycle time. Empty in the same cases as merge_to_deploy_series. */open_to_merge_series: LeadTimeBucket[];@@ -29075,7 +29085,7 @@ export namespace Schemas {open_to_deploy_series: LeadTimeBucket[];/** False when the deployments/deployment_statuses tables aren't synced for the selected repo; every other field is then empty or null, never a fake zero. */deploy_data_available: boolean;- /** What the environment filter resolved to: 'production' (deployments GitHub marks production_environment), an exact environment name (the one passed, or the busiest persistent environment when nothing is marked production), or 'persistent' (no persistent environment deployed in the window, so every non-transient one counts). Transient environments (ephemeral per-PR previews) never join a default scope. The scope resolves from deployments in the scan window, so two different windows can resolve different scopes and are not always comparable. */+ /** What the environment filter resolved to: the exact environment name(s) it matches (the caller's picks, comma-joined when several; by default the busiest production-marked environment, falling back to the busiest persistent one), or 'persistent' (no persistent environment deployed in the window, so every non-transient one counts). Transient environments (ephemeral per-PR previews) never join a default scope. The scope resolves from deployments in the scan window, so two different windows can resolve different scopes and are not always comparable. */environment_scope: string;/** Distinct persistent environments deployed to in the scan window, most-deployed first — the environment picker's options. Transient environments are omitted but stay reachable by exact name. */environments: string[];@@ -29157,7 +29167,7 @@ export namespace Schemas {* @nullable*/latest_deploy_status_at: string | null;- /** Bucket width of every series, chosen to fit the window: 'hour', 'day', or 'week'. */+ /** Bucket width of every series: the granularity param when given, else chosen to fit the window: 'hour', 'day', or 'week'. */series_granularity: string;}@@ -93081,13 +93091,17 @@ export namespace Schemas {*/date_to?: string;/**- * Exact deploy environment to scope to (from the response's `environments` list). Omit to scope to production-marked deployments, falling back to every persistent (non-transient) environment when none are marked production.+ * Deploy environment(s) to scope to, repeatable (from the response's `environments` list). Omit to scope to the busiest environment GitHub marks production, falling back to the busiest persistent (non-transient) environment when none are marked production.*/- environment?: string;+ environment?: string[];/*** GitHub team slug (from the response's `github_teams` list) to narrow the PR-scoped merge-to-deploy figures to that team's authors. Deploy counts stay repo-wide. Needs the team-membership snapshot synced; without it the merge-to-deploy figures return empty rather than silently unfiltered.*/github_team?: string;+ /**+ * Bucket width for every series. Omit to pick one that fits the window: hour up to 48h, day up to 90 days, week beyond.+ */+ granularity?: EngineeringAnalyticsDoraGranularity;/*** 'owner/name' repository to scope to when the selected source syncs several repositories (from the `sources` list). Defaults to the source's first repository.*/@@ -93098,6 +93112,15 @@ export namespace Schemas {source_id?: string;};+ export type EngineeringAnalyticsDoraGranularity = typeof EngineeringAnalyticsDoraGranularity[keyof typeof EngineeringAnalyticsDoraGranularity];+++ export const EngineeringAnalyticsDoraGranularity = {+ Day: 'day',+ Hour: 'hour',+ Week: 'week',+ } as const;+export type EngineeringAnalyticsFlakyTestsParams = {/*** Window start: relative ('-7d', '-30d') or ISO8601. Defaults to -7d; the window may span at most 30 days.