feat(export): extract Analytics API hit metrics per product - #57
Merged
Conversation
Introduces metrics config flags with date validation and a new internal/stats package with Analytics client and per-product exporter. Wiring and CLI follow in PR 2. Co-authored-by: Cursor <cursoragent@cursor.com>
Connect Analytics API stats to full export via --include-metrics, add a standalone metrics subcommand, extend manifest/verify layout, and document the stats/ output contract. Co-authored-by: Cursor <cursoragent@cursor.com>
Use errors.Is when asserting ErrInvalidMetricsDateRange so wrapped errors still match in CI. Co-authored-by: Cursor <cursoragent@cursor.com>
Cover metrics config helpers, ValidateOutput with include-metrics, stats parsers, and export ListProducts to restore the 80% coverage gate. Co-authored-by: Cursor <cursoragent@cursor.com>
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.
Proposed change
Adds optional hit-traffic export from the 3scale Analytics API (
GET /stats/services/{id}/usage.json).internal/statsclient/exporter, metrics window validation ininternal/config/metrics.go--include-metricson full export, standalonethreescale-export metricssubcommand, manifest/verify layout forstats/, README and test casesOutput layout (when enabled):
Requires Enterprise tier and a PAT with Analytics scope. Fail-fast when metrics are requested and the Analytics API returns an error.
Type of change
RHCL checklist
go test ./...)Test plan
go test ./...passes locallyTestExportIncludeMetrics/TestVerifyExportWithMetrics— full export with mock Analytics APITestRunMetricsHappyPath— standalonemetricssubcommand writes onlystats/TestExportGoldenLayoutunchanged — default export without--include-metricsstill produces 10 filesstats/products/*/hits.jsonAdditional information
extract-hit-metrics(Engram)1.0; manifest gains optional metrics fields when--include-metricsis setMade with Cursor