SERVER-115621 Move 'server_status.h' and 'server_status_metric.h' out of query module and mark visibility (#45598)

GitOrigin-RevId: e32b08d83b5e1008e053465134714b150d4f8834
This commit is contained in:
Erin McNulty 2025-12-23 12:07:56 -05:00 committed by MongoDB Bot
parent b6ba59e193
commit 8d9503600a
4 changed files with 14 additions and 19 deletions

View File

@ -180,7 +180,6 @@ query:
- src/mongo/db/commands/profile*
- src/mongo/db/commands/sysprofile*
- src/mongo/db/commands/query_cmd/
- src/mongo/db/commands/server_status*
- src/mongo/db/commands/set_profiling_*
- src/mongo/db/commands/shardsvr_resolve_view_command*
- src/mongo/db/commands/top_command*
@ -587,6 +586,7 @@ observability:
jira: Networking & Observability
fully_marked: true
files:
- src/mongo/db/commands/server_status*
- src/mongo/db/connection_health_metrics_parameter.idl
- src/mongo/db/not_primary_error_tracker*
- src/mongo/db/operation_cpu_timer*

View File

@ -37,6 +37,7 @@
#include "mongo/db/operation_context.h"
#include "mongo/db/stats/counters.h"
#include "mongo/platform/atomic_word.h"
#include "mongo/util/modules.h"
#include <map>
#include <string>
@ -51,7 +52,7 @@ namespace mongo {
* Use ServerStatusSectionBuilder below to build your ServerStatusSection and register it with the
* command. Make sure to perform the registration before the server can run commands.
*/
class ServerStatusSection {
class MONGO_MOD_OPEN ServerStatusSection {
public:
ServerStatusSection(std::string sectionName, ClusterRole role)
: _sectionName(std::move(sectionName)), _role(role) {}
@ -194,7 +195,7 @@ private:
* all sections are registered before serverStatus can be run.
*/
template <typename Section>
class ServerStatusSectionBuilder {
class MONGO_MOD_PUBLIC ServerStatusSectionBuilder {
public:
explicit ServerStatusSectionBuilder(std::string name) : _name(std::move(name)) {}
@ -247,18 +248,21 @@ private:
};
class OpCounterServerStatusSection : public ServerStatusSection {
class MONGO_MOD_PUBLIC OpCounterServerStatusSection : public ServerStatusSection {
public:
OpCounterServerStatusSection(const std::string& sectionName,
ClusterRole role,
OpCounters* counters);
OpCounters* counters)
: ServerStatusSection(sectionName, role), _counters(counters) {}
bool includeByDefault() const override {
return true;
}
BSONObj generateSection(OperationContext* opCtx,
const BSONElement& configElement) const override;
const BSONElement& configElement) const override {
return _counters->getObj();
}
private:
const OpCounters* _counters;
@ -267,7 +271,7 @@ private:
/**
* Publishes an infrequently-changing BSON object as a server status section.
*/
class BSONObjectStatusSection : public ServerStatusSection {
class MONGO_MOD_PUBLIC BSONObjectStatusSection : public ServerStatusSection {
public:
using ServerStatusSection::ServerStatusSection;

View File

@ -36,6 +36,7 @@
#include "mongo/db/topology/cluster_role.h"
#include "mongo/platform/atomic_word.h"
#include "mongo/util/assert_util.h"
#include "mongo/util/modules.h"
#include "mongo/util/synchronized_value.h"
#include <cstdint>
@ -225,7 +226,7 @@ void appendMergedTrees(std::vector<const MetricTree*> trees,
const BSONObj& excludePaths = {});
template <typename Policy>
class CustomMetricBuilder {
class MONGO_MOD_PUBLIC CustomMetricBuilder {
public:
using Metric = BasicServerStatusMetric<Policy>;
@ -318,7 +319,7 @@ using ServerStatusMetricPolicySelectionT = typename ServerStatusMetricPolicySele
* .setPredicate(someNullaryPredicate);
*/
template <typename T>
using MetricBuilder = CustomMetricBuilder<ServerStatusMetricPolicySelectionT<T>>;
using MetricBuilder MONGO_MOD_PUBLIC = CustomMetricBuilder<ServerStatusMetricPolicySelectionT<T>>;
/**
* Leverage `synchronized_value<T>` to make a thread-safe `T` metric, for `T`

View File

@ -341,16 +341,6 @@ void AuthCounter::append(BSONObjBuilder* b) {
b->append("totalAuthenticationTimeMicros", totalAuthenticationTimeMicros);
}
OpCounterServerStatusSection::OpCounterServerStatusSection(const std::string& sectionName,
ClusterRole role,
OpCounters* counters)
: ServerStatusSection(sectionName, role), _counters(counters) {}
BSONObj OpCounterServerStatusSection::generateSection(OperationContext* opCtx,
const BSONElement& configElement) const {
return _counters->getObj();
}
OpCounters& serviceOpCounters(ClusterRole role) {
static StaticImmortal<OpCounters> routerOpCounters;
static StaticImmortal<OpCounters> shardOpCounters;