Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add more metrics #3446

Merged
merged 12 commits into from
Dec 23, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions conf/nebula-graphd.conf.default
Original file line number Diff line number Diff line change
Expand Up @@ -86,3 +86,5 @@
########## experimental feature ##########
# if use experimental features
--enable_experimental_feature=false

--enable_space_level_metrics=false
2 changes: 2 additions & 0 deletions conf/nebula-graphd.conf.production
Original file line number Diff line number Diff line change
Expand Up @@ -84,3 +84,5 @@
########## experimental feature ##########
# if use experimental features
--enable_experimental_feature=false

--enable_space_level_metrics=false
1 change: 1 addition & 0 deletions src/clients/meta/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,5 @@ nebula_add_library(
FileBasedClusterIdMan.cpp
)

nebula_add_subdirectory(stats)
nebula_add_subdirectory(test)
3 changes: 3 additions & 0 deletions src/clients/meta/MetaClient.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
#include <thrift/lib/cpp/util/EnumUtils.h>

#include "clients/meta/FileBasedClusterIdMan.h"
#include "clients/meta/stats/MetaClientStats.h"
#include "common/base/Base.h"
#include "common/base/MurmurHash2.h"
#include "common/conf/Configuration.h"
Expand Down Expand Up @@ -626,6 +627,7 @@ void MetaClient::getResponse(Request req,
bool toLeader,
int32_t retry,
int32_t retryLimit) {
stats::StatsManager::addValue(kNumRpcSentToMetad);
auto* evb = ioThreadPool_->getEventBase();
HostAddr host;
{
Expand Down Expand Up @@ -660,6 +662,7 @@ void MetaClient::getResponse(Request req,
this](folly::Try<RpcResponse>&& t) mutable {
// exception occurred during RPC
if (t.hasException()) {
stats::StatsManager::addValue(kNumRpcSentToMetadFailed);
if (toLeader) {
updateLeader();
} else {
Expand Down
9 changes: 9 additions & 0 deletions src/clients/meta/stats/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Copyright (c) 2021 vesoft inc. All rights reserved.
#
# This source code is licensed under Apache 2.0 License.

nebula_add_library(
meta_client_stats_obj
OBJECT
MetaClientStats.cpp
)
19 changes: 19 additions & 0 deletions src/clients/meta/stats/MetaClientStats.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
/* Copyright (c) 2021 vesoft inc. All rights reserved.
*
* This source code is licensed under Apache 2.0 License.
*/

#include "clients/meta/stats/MetaClientStats.h"

namespace nebula {

stats::CounterId kNumRpcSentToMetad;
stats::CounterId kNumRpcSentToMetadFailed;

void initMetaClientStats() {
kNumRpcSentToMetad = stats::StatsManager::registerStats("num_rpc_sent_to_metad", "rate, sum");
kNumRpcSentToMetadFailed =
stats::StatsManager::registerStats("num_rpc_sent_to_metad_failed", "rate, sum");
}

} // namespace nebula
17 changes: 17 additions & 0 deletions src/clients/meta/stats/MetaClientStats.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
/* Copyright (c) 2021 vesoft inc. All rights reserved.
*
* This source code is licensed under Apache 2.0 License.
*/

#pragma once

#include "common/stats/StatsManager.h"

namespace nebula {

extern stats::CounterId kNumRpcSentToMetad;
extern stats::CounterId kNumRpcSentToMetadFailed;

void initMetaClientStats();

} // namespace nebula
2 changes: 2 additions & 0 deletions src/clients/storage/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,5 @@ nebula_add_library(
InternalStorageClient.cpp
)

nebula_add_subdirectory(stats)

5 changes: 5 additions & 0 deletions src/clients/storage/StorageClientBase-inl.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@

#include <folly/Try.h>

#include "clients/storage/stats/StorageClientStats.h"
#include "common/ssl/SSLConfig.h"
#include "common/stats/StatsManager.h"
#include "common/time/WallClock.h"

namespace nebula {
Expand Down Expand Up @@ -230,6 +232,7 @@ void StorageClientBase<ClientType>::getResponseImpl(
std::pair<HostAddr, Request> request,
RemoteFunc remoteFunc,
std::shared_ptr<folly::Promise<StatusOr<Response>>> pro) {
stats::StatsManager::addValue(kNumRpcSentToStoraged);
using TransportException = apache::thrift::transport::TTransportException;
if (evb == nullptr) {
DCHECK(!!ioThreadPool_);
Expand Down Expand Up @@ -266,6 +269,7 @@ void StorageClientBase<ClientType>::getResponseImpl(
.thenError(folly::tag_t<TransportException>{},
[spaceId, partsId = std::move(partsId), host, pro, this](
TransportException&& ex) mutable {
stats::StatsManager::addValue(kNumRpcSentToStoragedFailed);
if (ex.getType() == TransportException::TIMED_OUT) {
LOG(ERROR) << "Request to " << host << " time out: " << ex.what();
} else {
Expand All @@ -278,6 +282,7 @@ void StorageClientBase<ClientType>::getResponseImpl(
.thenError(folly::tag_t<std::exception>{},
[spaceId, partsId = std::move(partsId), host, pro, this](
std::exception&& ex) mutable {
stats::StatsManager::addValue(kNumRpcSentToStoragedFailed);
// exception occurred during RPC
pro->setValue(Status::Error(
folly::stringPrintf("RPC failure in StorageClient: %s", ex.what())));
Expand Down
9 changes: 9 additions & 0 deletions src/clients/storage/stats/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Copyright (c) 2021 vesoft inc. All rights reserved.
#
# This source code is licensed under Apache 2.0 License.

nebula_add_library(
storage_client_stats_obj
OBJECT
StorageClientStats.cpp
)
20 changes: 20 additions & 0 deletions src/clients/storage/stats/StorageClientStats.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
/* Copyright (c) 2021 vesoft inc. All rights reserved.
*
* This source code is licensed under Apache 2.0 License.
*/

#include "clients/meta/stats/MetaClientStats.h"

namespace nebula {

stats::CounterId kNumRpcSentToStoraged;
stats::CounterId kNumRpcSentToStoragedFailed;

void initStorageClientStats() {
kNumRpcSentToStoraged =
stats::StatsManager::registerStats("num_rpc_sent_to_storaged", "rate, sum");
kNumRpcSentToStoragedFailed =
stats::StatsManager::registerStats("num_rpc_sent_to_storaged_failed", "rate, sum");
}

} // namespace nebula
17 changes: 17 additions & 0 deletions src/clients/storage/stats/StorageClientStats.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
/* Copyright (c) 2021 vesoft inc. All rights reserved.
*
* This source code is licensed under Apache 2.0 License.
*/

#pragma once

#include "common/stats/StatsManager.h"

namespace nebula {

extern stats::CounterId kNumRpcSentToStoraged;
extern stats::CounterId kNumRpcSentToStoragedFailed;

void initStorageClientStats();

} // namespace nebula
3 changes: 3 additions & 0 deletions src/codec/test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ set(CODEC_TEST_LIBS
$<TARGET_OBJECTS:fs_obj>
$<TARGET_OBJECTS:thread_obj>
$<TARGET_OBJECTS:stats_obj>
$<TARGET_OBJECTS:meta_client_stats_obj>
$<TARGET_OBJECTS:storage_client_stats_obj>
$<TARGET_OBJECTS:kv_stats_obj>
$<TARGET_OBJECTS:time_obj>
$<TARGET_OBJECTS:conf_obj>
$<TARGET_OBJECTS:meta_obj>
Expand Down
3 changes: 3 additions & 0 deletions src/common/expression/test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ set(expression_test_common_libs
$<TARGET_OBJECTS:network_obj>
$<TARGET_OBJECTS:fs_obj>
$<TARGET_OBJECTS:stats_obj>
$<TARGET_OBJECTS:graph_stats_obj>
$<TARGET_OBJECTS:meta_client_stats_obj>
$<TARGET_OBJECTS:storage_client_stats_obj>
$<TARGET_OBJECTS:datatypes_obj>
$<TARGET_OBJECTS:time_obj>
$<TARGET_OBJECTS:datetime_parser_obj>
Expand Down
Loading