Concern duplication ::Gitlab::Import::Metrics vs ::Gitlab::GithubImport::ObjectCounter
<!--IssueSummary start--> <details> <summary> Everyone can contribute. [Help move this issue forward](https://handbook.gitlab.com/handbook/marketing/developer-relations/contributor-success/community-contributors-workflows/#contributor-links) while earning points, leveling up and collecting rewards. </summary> - [Close this issue](https://contributors.gitlab.com/manage-issue?action=close&projectId=278964&issueIid=345535) </details> <!--IssueSummary end--> ## Motivation The code review https://gitlab.com/gitlab-org/gitlab/-/merge_requests/74206 made explicit that the importers metrics normalization is more complex than originally estimated. ## Problem to Solve While creating `::Gitlab::GithubImport::ObjectCounter`[^1] to improve the visibility of the Github Importer, some logic duplication was created with `::Gitlab::Import::Metrics`. Currently individual objects, like issues or merge requests, in the Github Importer are being counted with `::Gitlab::GithubImport::ObjectCounter`, but similarly the Bitbucket Importer is counting some objects with `::Gitlab::Import::Metrics`. Besides that, there's some confusion about how to tag some of the counters[^2], either with the `project` or the `importer` type (or maybe both?!) ## Proposed solution _Merge_ the way objects are being counted under the same class to normalize dashboards and increase the maintainability of the code by removing the duplication. For that, I propose picking the best of both existing classes, like: - [ ] Move `::Gitlab::GithubImport::ObjectCounter` logic to within the `::Gitlab::Import::Metrics` - [ ] `::Gitlab::GithubImport::ObjectCounter` counts individual objects on both prometheus and redis, the former for dashboard and the latter to provide a finishing log with the stats of the import; - [ ] `::Gitlab::Import::Metrics`, on the other hand, tracks count of projects imported (started, finished, failed) and a duration metric on prometheus, which is a good data to include on grafana dashboards; - [ ] Replace `::Gitlab::GithubImport::ObjectCounter` calls by `::Gitlab::Import::Metrics` - [ ] Add the stats log that Github Importer have to Bitbucket Importer - [ ] Add the project start/failure that Bitbucket Importer have to Github Importer - [ ] Add the duration panel from Bitbucket Importer [dashboard](https://dashboards.gitlab.net/d/sidekiq-bitbucket-importer/sidekiq-bitbucket-importer?orgId=1) to Github Importer [dashboard](https://dashboards.gitlab.net/d/importers-github-importer/importers-github-importer?orgId=1) - [ ] Use the Github Importer dashboard as template to other importers, like Bitbucket Importer --- [^1]: https://gitlab.com/gitlab-org/gitlab/-/issues/334022 [^2]: https://gitlab.com/gitlab-org/gitlab/-/issues/341958
issue