diff options
author | XueruiFa <xuerui.fa@mongodb.com> | 2020-08-17 18:40:00 +0000 |
---|---|---|
committer | Evergreen Agent <no-reply@evergreen.mongodb.com> | 2020-08-20 16:12:15 +0000 |
commit | fbde2a22dab3eaf64c5aec542811be954faaf7e1 (patch) | |
tree | bef1dfb4a75953dda9d5a4aba0ccdd691bd84bb7 /src/mongo/s/commands/strategy.cpp | |
parent | 7ab67b9007176b6d80f0e460803c5ffc0737ae2e (diff) | |
download | mongo-fbde2a22dab3eaf64c5aec542811be954faaf7e1.tar.gz |
SERVER-49965: Add apiVersion metrics to serverStatus and remove stale metrics
Diffstat (limited to 'src/mongo/s/commands/strategy.cpp')
-rw-r--r-- | src/mongo/s/commands/strategy.cpp | 24 |
1 files changed, 13 insertions, 11 deletions
diff --git a/src/mongo/s/commands/strategy.cpp b/src/mongo/s/commands/strategy.cpp index fb2e021714d..ba7220b3839 100644 --- a/src/mongo/s/commands/strategy.cpp +++ b/src/mongo/s/commands/strategy.cpp @@ -375,19 +375,13 @@ void runCommand(OperationContext* opCtx, auto const apiParamsFromClient = initializeAPIParameters(request.body, command); auto& readConcernArgs = repl::ReadConcernArgs::get(opCtx); - auto readConcernParseStatus = [&]() { - // We must obtain the client lock to set the ReadConcernArgs on the operation - // context as it may be concurrently read by CurrentOp. + Status readConcernParseStatus = Status::OK(); + { + // We must obtain the client lock to set APIParameters and ReadConcernArgs on the operation + // context, as it may be concurrently read by CurrentOp. stdx::lock_guard<Client> lk(*client); APIParameters::get(opCtx) = APIParameters::fromClient(apiParamsFromClient); - return readConcernArgs.initialize(request.body); - }(); - - auto& apiParams = APIParameters::get(opCtx); - auto& apiVersionMetrics = ApplicationApiVersionMetrics::get(opCtx->getServiceContext()); - const auto& clientMetadata = ClientMetadataIsMasterState::get(client).getClientMetadata(); - if (clientMetadata) { - apiVersionMetrics.update(clientMetadata.get(), apiParams); + readConcernParseStatus = readConcernArgs.initialize(request.body); } if (!readConcernParseStatus.isOK()) { @@ -396,6 +390,14 @@ void runCommand(OperationContext* opCtx, return; } + auto& apiParams = APIParameters::get(opCtx); + auto& apiVersionMetrics = APIVersionMetrics::get(opCtx->getServiceContext()); + const auto& clientMetadata = ClientMetadataIsMasterState::get(client).getClientMetadata(); + if (clientMetadata) { + auto appName = clientMetadata.get().getApplicationName().toString(); + apiVersionMetrics.update(appName, apiParams); + } + boost::optional<RouterOperationContextSession> routerSession; try { rpc::readRequestMetadata(opCtx, request.body, command->requiresAuth()); |