Separate RedisMetric instrumentation class from counter class logic

Problem

As noted in the parent issue Migrate redis usage_counters to use Metric Inst... (#339445 - closed), we want to switch to using the RedisMetric instrumentation class to instrument regular Redis metrics.

However, the current implementation of RedisMetric depends on legacy counter classes from the Gitlab::UsageDataCounters module to do all interfacing with Redis. counts.source_code_pushes is instrumented using this current implementation as a proof of concept.

Some counter classes like NoteCounter override a lot of the BaseCounter implementation and we'll have to figure out how to integrate or supersede that, but many of them simply override KNOWN_EVENTS and PREFIX constants and are an easy win to migrate. We would like to reimplement parts of BaseCounter in the RedisCounter instrumentation class, then freeze some of the more problematic classes and migrate the simpler ones to a new implementation without the dependency as a first iteration.

Proposal

  • Reimplement parts of BaseCounter in the RedisCounter instrumentation class.
  • Migrate simpler counter classes that do not override any methods from BaseCounter to the new implementation without the dependency.
  • Deprecate using the Gitlab::UsageDataCounters class, since that's only used by Gitlab::UsageData, and enforce using the RedisMetric instrumentation class for any new counter class.
  • Add relevant docs.