Uploaded image for project: 'Core Server'
  1. Core Server
  2. SERVER-65987

ServerStatusMetric API refresh

    • Type: Icon: Bug Bug
    • Resolution: Fixed
    • Priority: Icon: Major - P3 Major - P3
    • 6.1.0-rc0
    • Affects Version/s: None
    • Component/s: None
    • None
    • Fully Compatible
    • ALL
    • Service Arch 2022-05-30, Service Arch 2022-06-13, Service Arch 2022-06-27, Service Arch 2022-07-11, Service Arch 2022-07-25

      The ServerStatusMetric class manipulates the MetricTree singleton directly, passing an incomplete this pointer from the base class constructor. This is a violation of separation of concern. The singleton's state is not ServerStatusMetric's job.

      We have better registry/registration patterns we could use here, including MONGO_INITIALIZER or a more specialized registration API.

      Creation of new ServerStatusMetric instances should be done with a factory that creates them and then registers them only when the instance is fully created. Registering before that is to pass an incomplete object, which is an unnecessary risk.

      What happens now:

      ServerStatusMetric::ServerStatusMetric(const string& nameIn)
          : _name(nameIn), _leafName(_parseLeafName(nameIn)) {
          if (MetricTree::theMetricTree == nullptr)
              MetricTree::theMetricTree = new MetricTree();
          MetricTree::theMetricTree->add(this);
      }
      

      This is a quick cleanup that will make this subsystem cleaner and safer.

            Assignee:
            billy.donahue@mongodb.com Billy Donahue
            Reporter:
            billy.donahue@mongodb.com Billy Donahue
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved: