Skip to content

feat(scorecard)!: add database and schedulers - #1544

Merged
imykhno merged 18 commits into
redhat-developer:mainfrom
dzemanov:scorecard-db-schedulers
Nov 5, 2025
Merged

feat(scorecard)!: add database and schedulers#1544
imykhno merged 18 commits into
redhat-developer:mainfrom
dzemanov:scorecard-db-schedulers

Conversation

@dzemanov

@dzemanov dzemanov commented Sep 29, 2025

Copy link
Copy Markdown
Member

Hey, I just made a Pull Request!

Adds database.
Adds schedulers.

Fixes

https://issues.redhat.com/browse/RHIDP-8717

How to test

  1. Use sqllite database
backend:
  database:
    client: better-sqlite3
    connection:
      directory: './db'

Creates db directory under scorecard/packages
Or:

backend:
  database:
    client: better-sqlite3
    connection: ':memory:'
  1. Use Postgres db
backend:
  database:
    client: pg
    connection:
      host: localhost
      port: 5432
      user: ${POSTGRES_USER}
      password:${POSTGRES_PASSWORD}

For testing purposes, you can update schedule to fetch metrics more often:

scorecard:
  dataRetentionDays: 1
  plugins:
    jira:
      open_issues:
        schedule:
          frequency: { minutes: 2 }
          timeout: { minutes: 15 }
          initialDelay: { seconds: 3 }
    github:
      open_prs:
        schedule:
          frequency: { minutes: 2 }
          timeout: { minutes: 15 }
          initialDelay: { seconds: 3 }

You should see in logs:

2025-10-03T19:46:36.590Z scorecard info Task worker starting: github.open_prs, {"version":2,"cadence":"PT2M","initialDelayDuration":"PT3S","timeoutAfterDuration":"PT15M"} task="github.open_prs"
2025-10-03T19:46:36.591Z scorecard info Task worker starting: jira.open_issues, {"version":2,"cadence":"PT2M","initialDelayDuration":"PT3S","timeoutAfterDuration":"PT15M"} task="jira.open_issues"
2025-10-03T19:46:36.591Z scorecard info Scheduled 2/2 metric providers 

2025-10-03T19:46:39.595Z scorecard info Refreshing metrics for github.open_prs class="MetricProvidersScheduler" taskId="github.open_prs:refresh" taskInstanceId="8ba58bad-08e8-4005-8b7f-314fde6e3bb9"
2025-10-03T19:46:39.596Z scorecard info Refreshing metrics for jira.open_issues class="MetricProvidersScheduler" taskId="jira.open_issues:refresh" taskInstanceId="026e7e65-085a-4592-956d-df554f697b4c"

2025-10-03T19:46:40.543Z scorecard info Completed metric refresh for jira.open_issues: processed 2 entities class="MetricProvidersScheduler" taskId="jira.open_issues:refresh" taskInstanceId="026e7e65-085a-4592-956d-df554f697b4c"
2025-10-03T19:46:40.758Z scorecard info Completed metric refresh for github.open_prs: processed 3 entities class="MetricProvidersScheduler" taskId="github.open_prs:refresh" taskInstanceId="8ba58bad-08e8-4005-8b7f-314fde6e3bb9"

✔️ Checklist

  • A changeset describing the change and affected packages. (more info)
  • Added or Updated documentation
  • Tests for new functionality and regression tests for bug fixes
  • Screenshots attached (for UI changes)

@rhdh-gh-app

rhdh-gh-app Bot commented Sep 29, 2025

Copy link
Copy Markdown

Important

This PR includes changes that affect public-facing API. Please ensure you are adding/updating documentation for new features or behavior.

Unexpected Changesets

The following changeset(s) reference packages that have not been changed in this PR:

  • /home/runner/work/rhdh-plugins/rhdh-plugins/workspaces/scorecard/.changeset/olive-months-cross.md: @red-hat-developer-hub/backstage-plugin-scorecard

Note that only changes that affect the published package require changesets, for example changes to tests and storybook stories do not require changesets.

Changed Packages

Package Name Package Path Changeset Bump Current Version
@red-hat-developer-hub/backstage-plugin-scorecard-backend-module-github workspaces/scorecard/plugins/scorecard-backend-module-github major v1.0.0
@red-hat-developer-hub/backstage-plugin-scorecard-backend-module-jira workspaces/scorecard/plugins/scorecard-backend-module-jira major v1.0.1
@red-hat-developer-hub/backstage-plugin-scorecard-backend workspaces/scorecard/plugins/scorecard-backend major v1.0.0
@red-hat-developer-hub/backstage-plugin-scorecard-node workspaces/scorecard/plugins/scorecard-node major v1.0.0

@dzemanov
dzemanov force-pushed the scorecard-db-schedulers branch from 7449254 to 97b6ba1 Compare October 3, 2025 18:10
@imykhno
imykhno force-pushed the scorecard-db-schedulers branch 5 times, most recently from 07a5a55 to 5e87ead Compare October 20, 2025 10:03
@imykhno
imykhno marked this pull request as ready for review October 20, 2025 10:12
Signed-off-by: Dominika Zemanovicova <dzemanov@redhat.com>
Signed-off-by: Dominika Zemanovicova <dzemanov@redhat.com>
Signed-off-by: Dominika Zemanovicova <dzemanov@redhat.com>
Signed-off-by: Dominika Zemanovicova <dzemanov@redhat.com>
Signed-off-by: Dominika Zemanovicova <dzemanov@redhat.com>
Signed-off-by: Dominika Zemanovicova <dzemanov@redhat.com>
Signed-off-by: Dominika Zemanovicova <dzemanov@redhat.com>
Signed-off-by: Dominika Zemanovicova <dzemanov@redhat.com>
Signed-off-by: Dominika Zemanovicova <dzemanov@redhat.com>
Signed-off-by: Dominika Zemanovicova <dzemanov@redhat.com>
Signed-off-by: Dominika Zemanovicova <dzemanov@redhat.com>
Signed-off-by: Dominika Zemanovicova <dzemanov@redhat.com>
Signed-off-by: Dominika Zemanovicova <dzemanov@redhat.com>
Signed-off-by: Dominika Zemanovicova <dzemanov@redhat.com>
Signed-off-by: Ihor Mykhno <imykhno@redhat.com>
@imykhno
imykhno force-pushed the scorecard-db-schedulers branch from 5e87ead to 2883b1d Compare October 24, 2025 12:49
Signed-off-by: Ihor Mykhno <imykhno@redhat.com>
@imykhno
imykhno force-pushed the scorecard-db-schedulers branch from 2883b1d to 2964f31 Compare October 24, 2025 14:18
* limitations under the License.
*/

export const CLEANUP_EXPIRED_METRICS_ID = 'cleanup-expired-metrics' as const;

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would maybe prefix it with scorecard: just to be sure it doesn't intersect anything.

'@red-hat-developer-hub/backstage-plugin-scorecard': minor
---

Adds database persistence and scheduled metric collection.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would add breaking here since we are now requiring getCatalogFilter
**BREAKING**: ...

  • Add information about what is breaking - getCatalogFilter

`Deleted ${deletedCount} expired metrics older than ${dataRetentionDays} days`,
);
} catch (error) {
logger.error(`Failed to cleanup expired metrics:`, error);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need this line here, as it's already on line 61? Or is there another spot where this function is called from that could expect to receive the exception thrown on the next line?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for your comment, this logger is not necessary I will remove it

@imykhno
imykhno force-pushed the scorecard-db-schedulers branch from 1747733 to a127942 Compare October 30, 2025 17:09
Signed-off-by: Ihor Mykhno <imykhno@redhat.com>
@imykhno
imykhno force-pushed the scorecard-db-schedulers branch from a127942 to 12fae92 Compare October 30, 2025 17:15
Signed-off-by: Dominika Zemanovicova <dzemanov@redhat.com>
@sonarqubecloud

sonarqubecloud Bot commented Nov 5, 2025

Copy link
Copy Markdown

@dzemanov

dzemanov commented Nov 5, 2025

Copy link
Copy Markdown
Member Author

Retested again and tested the new deletion functionality, works great, thank you @imykhno.
I updated the changeset to major due this being breaking changes.

@dzemanov dzemanov changed the title feat(scorecard): add database and schedulers feat(scorecard)!: add database and schedulers Nov 5, 2025
@imykhno
imykhno merged commit 5d447f1 into redhat-developer:main Nov 5, 2025
10 checks passed
elai-shalev pushed a commit to elai-shalev/rhdh-plugins that referenced this pull request Jan 21, 2026
* Introduce metric_values db

Signed-off-by: Dominika Zemanovicova <dzemanov@redhat.com>

* Connect metric providers on schedule

Signed-off-by: Dominika Zemanovicova <dzemanov@redhat.com>

* Add catalog entities processing to providers

Signed-off-by: Dominika Zemanovicova <dzemanov@redhat.com>

* Extract to BaseMetricProvider

Signed-off-by: Dominika Zemanovicova <dzemanov@redhat.com>

* Rename metricValue row

Signed-off-by: Dominika Zemanovicova <dzemanov@redhat.com>

* Integrate db read to metrics endpoint

Signed-off-by: Dominika Zemanovicova <dzemanov@redhat.com>

* Use directly catalogService in CatalogMetricService

Signed-off-by: Dominika Zemanovicova <dzemanov@redhat.com>

* Remove not needed readMetricValues

Signed-off-by: Dominika Zemanovicova <dzemanov@redhat.com>

* Switch db value to json

Signed-off-by: Dominika Zemanovicova <dzemanov@redhat.com>

* Extract scheduling to scorecard backend

Signed-off-by: Dominika Zemanovicova <dzemanov@redhat.com>

* Simplify DatabaseMetricValuesStore

Signed-off-by: Dominika Zemanovicova <dzemanov@redhat.com>

* Add tests

Signed-off-by: Dominika Zemanovicova <dzemanov@redhat.com>

* Update docs

Signed-off-by: Dominika Zemanovicova <dzemanov@redhat.com>

* Increate timeout for db

Signed-off-by: Dominika Zemanovicova <dzemanov@redhat.com>

* feat(scorecard): implement cleanup expired metrics mechanism

Signed-off-by: Ihor Mykhno <imykhno@redhat.com>

* refactor(scorecard): logic to load and cleanup metrics

Signed-off-by: Ihor Mykhno <imykhno@redhat.com>

* refactor(scorecard): scorecard metric loading logic

Signed-off-by: Ihor Mykhno <imykhno@redhat.com>

* Update changeset

Signed-off-by: Dominika Zemanovicova <dzemanov@redhat.com>

---------

Signed-off-by: Dominika Zemanovicova <dzemanov@redhat.com>
Signed-off-by: Ihor Mykhno <imykhno@redhat.com>
Co-authored-by: Ihor Mykhno <imykhno@redhat.com>
elai-shalev pushed a commit to elai-shalev/rhdh-plugins that referenced this pull request Jan 21, 2026
* Introduce metric_values db

Signed-off-by: Dominika Zemanovicova <dzemanov@redhat.com>

* Connect metric providers on schedule

Signed-off-by: Dominika Zemanovicova <dzemanov@redhat.com>

* Add catalog entities processing to providers

Signed-off-by: Dominika Zemanovicova <dzemanov@redhat.com>

* Extract to BaseMetricProvider

Signed-off-by: Dominika Zemanovicova <dzemanov@redhat.com>

* Rename metricValue row

Signed-off-by: Dominika Zemanovicova <dzemanov@redhat.com>

* Integrate db read to metrics endpoint

Signed-off-by: Dominika Zemanovicova <dzemanov@redhat.com>

* Use directly catalogService in CatalogMetricService

Signed-off-by: Dominika Zemanovicova <dzemanov@redhat.com>

* Remove not needed readMetricValues

Signed-off-by: Dominika Zemanovicova <dzemanov@redhat.com>

* Switch db value to json

Signed-off-by: Dominika Zemanovicova <dzemanov@redhat.com>

* Extract scheduling to scorecard backend

Signed-off-by: Dominika Zemanovicova <dzemanov@redhat.com>

* Simplify DatabaseMetricValuesStore

Signed-off-by: Dominika Zemanovicova <dzemanov@redhat.com>

* Add tests

Signed-off-by: Dominika Zemanovicova <dzemanov@redhat.com>

* Update docs

Signed-off-by: Dominika Zemanovicova <dzemanov@redhat.com>

* Increate timeout for db

Signed-off-by: Dominika Zemanovicova <dzemanov@redhat.com>

* feat(scorecard): implement cleanup expired metrics mechanism

Signed-off-by: Ihor Mykhno <imykhno@redhat.com>

* refactor(scorecard): logic to load and cleanup metrics

Signed-off-by: Ihor Mykhno <imykhno@redhat.com>

* refactor(scorecard): scorecard metric loading logic

Signed-off-by: Ihor Mykhno <imykhno@redhat.com>

* Update changeset

Signed-off-by: Dominika Zemanovicova <dzemanov@redhat.com>

---------

Signed-off-by: Dominika Zemanovicova <dzemanov@redhat.com>
Signed-off-by: Ihor Mykhno <imykhno@redhat.com>
Co-authored-by: Ihor Mykhno <imykhno@redhat.com>
@dzemanov
dzemanov deleted the scorecard-db-schedulers branch June 16, 2026 07:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants