Repository navigation
feat(AF-984): deployment DORA metrics service and read API - #1188
Merged
Merged
Conversation
Contributor
Contributor
Backend Code Coverage
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #984 (part of epic #983).
Summary
Read-time DORA and approval-SLA metrics for deployment governance. This PR adds the contract that #986 (compliance export) and #987 (page) build on.
GET /api/v1/deployment-pipelines/{id}/metricsandGET /api/v1/deployment-metricsfrom/to(window[from, to), trailing 30 days by default, at most 366 days →400 DEPLOYMENT_METRICS_PERIOD_INVALID) andenvironment(case-insensitive name). The org-wide endpoint also takespipeline_id.DEPLOYMENT_PIPELINE_MANAGE,DEPLOYMENT_REVIEWorQUERY_ADMIN, plus effectivecan_triggerholders, can read it. The org-wide endpoint accepts only the three functional permissions.source), change failure rate, time to restore, approval latency, timeout rate, break-glass count, and a zero-filled UTCdailyseries. Definitions are verbatim from epic decision 2.deploygov.api.DeploymentMetricsService(JDK-only contract).DefaultDeploymentMetricsServiceand a native-SQLDeploymentMetricsRepositoryImpldo the work, with no metrics table and no job.AT TIME ZONE 'UTC'. Every value is a bound parameter; only constant scope fragments are concatenated.deployment_requests.review_started_at, nullable and not backfilled.DeploymentRequestStateServicestamps it on entry toPENDING_REVIEW.af_try_parse_iso_instant(text). It accepts only an ISO-8601 instant with an explicit offset, and works on PostgreSQL 15 and later (pg_input_is_validwould need 16).DeploymentPipelineVisibility, used by the inventory and the metrics.Docs
docs/04-api-spec.md: new "Deployment metrics" section (parameters, response, definitions table). The trigger endpoint'smetadatadescription now names thecommit_timestampkey.docs/03-data-model.md:review_started_at.docs/18-deployment-governance.md: new §10a.CLAUDE.md: deploygov module line.website/, README or help-corpus change. There is no UI or operator setting yet, and deploygov: metrics documentation sweep #988 is the epic's docs sweep. No frontend, so no e2e spec and no screenshots ("No UI change — no screenshots").Deviations from the issue text
DeploymentMetricsControllerTestis a plain unit test. The repo has no@WebMvcTestprecedent; its controller tests follow theDeploymentVersionInventoryControllerTestshape. The 403 (org-wide), 404 (per-pipeline) and 400 (period) responses are checked over real HTTP inDeploymentMetricsIntegrationTest, using MockMvc with API keys.DeploymentRequestStateService:ddl-auto=validate;PENDING_AI → PENDING_REVIEW → APPROVEDbecomes an approval-latency sample.SET LOCAL TIME ZONE 'Pacific/Auckland'inside a transaction. pgjdbc derives the session zone from the JVM zone when a connection opens, so changing the JVM default can't reach connections already in the pool. The test first checks that a baredate_truncdoes move the 23:30 UTC deployment to the next day in that session.APPROVED/REJECTED/EXECUTED/FAILEDwith a decision row). This keeps a partially approved request (still in review, timed out or cancelled) out of the sample, per "only requests decided by a human".SUCCEEDEDexecution on the same pipeline + environment) rather thanLEAD(...), because the immediately next execution may itself have failed. A success that ran before the failure was reported counts as 0 seconds. Lead time is clamped at 0 the same way.sourceare omitted from the JSON (the globalnon_nullinclusion), not sent asnull. The docs say so.Verification
mvn -o -f backend/pom.xml verify -Pcoveragepassed: 11475 tests, 0 failures, 0 errors; Spotless and Checkstyle pass.ApplicationModulesTest,ApiPackageDependencyTestandMessagesParityTestpass.JaCoCo coverage:
DefaultDeploymentMetricsServiceDeploymentMetricsRepositoryImplDeploymentPipelineVisibilityReview notes
Four reviewers ran before this PR was opened. Every blocker they raised is fixed in the second commit:
pg_input_is_valid(af-java-reviewer, af-reviewer)commit_timestampvalue could break the percentiles (infinity/now/ no offset)todefault in the docs (af-content-reviewer)Remaining concerns:
decided_at < :tobound was rejected: it would change which decision counts as a request's "last", and wrongly bring requests decided after the window into it. The tables are small (one row per release) (af-java-reviewer).