Running SonarCube 9.9.3
Trying to retrieve metrics for two specific dates (sprint begin, end) in order to calculate DIFF between metrics so that I show increase/decrease during development window or sprint review.
Trying to generate a rough “new_code” type delta between any given adhoc dates as I may not be able to adjust new_code window and/or would like to pull snapshots for multiple dates (not all) to show analysis state at given milestones in our development window.
Example Result - Metrics at end of Development
metric | 23.31 | 23.41 | 24.11 | 24.21 | 24.31 |
---|---|---|---|---|---|
bugs | 120 | 125 | 128 | 95 | 98 |
coverage | 30.5 | 30.1 | 29.5 | 33.2 | 33.2 |
Workaround
- invoke “api/measures/search_history” with single metric
- extract closest BEGIN/END dates from returned analysis results
- invoke "api/measures/search_history with multiple metrics and [from,to] with both explicitly set to BEGIN date
- invoke "api/measures/search_history with multiple metrics and [from,to] with both explicitly set to END date
- manual comparison between BEGIN/END analysis results to show trends
Are there other endpoints that I can use to retrieve this data? The api/project/analyses/search payload appears to be quite large in comparison to single measures/search_history response.
It would be nice to have a few helpers like
api/measures/closest_date?date=yyyy-mm-dd&match=closest|lte|gte&component=my_project
api/measures/closest_dates?dates={delimited-string}
Or perhaps a way to add custom tags to the analysis under activity so that measure snapshots can be retrieved by tags
api/measures/search_history?tags=release
ah — perhaps that is what Creating “Custom Events” is all about, but this would only give me a way to filter to get the analysis dates but would require a separate api call to retrieve each events metrics